mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-29 21:41:00 +08:00
merge
This commit is contained in:
commit
4579dc2d8b
@ -1,43 +1,43 @@
|
||||
# dpkg commands to manage packages on Debian Based Systems
|
||||
用 dpkg 命令在 Debian 系的 Linux 系统中管理软件包
|
||||
==================
|
||||
|
||||
[dpkg][7] stands for Debian package manager (dpkg). dpkg is a command-line tool to install, build, remove and manage Debian packages. dpkg uses Aptitude (primary and more user-friendly) as a front-end to perform all the actions.
|
||||
[dpkg][7] 意即 Debian 包管理器(Debian PacKaGe manager)。dpkg 是一个可以安装、构建、删除及管理 Debian 软件包的命令行工具。dpkg 将 Aptitude(首选而更用户友好)作为执行所有操作的前端界面。
|
||||
|
||||
Other utility such as dpkg-deb and dpkg-query uses dpkg as a front-end to perform some action.
|
||||
其它的一些工具如 dpkg-deb 和 dpkg-query 等也使用 dpkg 作为执行某些操作的前端。
|
||||
|
||||
Now a days most of the administrator using Apt, [Apt-Get][6] & Aptitude to manage packages easily without headache and its robust management too.
|
||||
现在大多数系统管理员使用 Apt、[Apt-Get][6] 及 Aptitude 等工具,不用费心就可以轻松地管理软件。
|
||||
|
||||
Even though still we need to use dpkg to perform some software installation where it’s necessary. Some other package manger utilities which are being used widely in Linux are [yum][5], [dnf][4], [apt-get][3], dpkg, [rpm][2], [Zypper][1], pacman, urpmi, etc.,
|
||||
尽管如此,必要的时候还是需要用 dpkg 来安装某些软件。其它的一些在 Linux 系统上广泛使用的包管理工具还有 [yum][5]、[dnf][4]、[apt-get][3]、dpkg、[rpm][2]、[Zypper][1]、pacman、urpmi 等等。
|
||||
|
||||
Now, i’m going to play on our Ubuntu 15.10 box to explain and cover mostly used dpkg commands with examples.
|
||||
现在,我要在装有 Ubuntu 15.10 的机器上用一些实例讲解最常用的 dpkg 命令。
|
||||
|
||||
#### 1) Common syntax/file location for dpkg
|
||||
### 1) dpkg 常见命令的语法及 dpkg 文件位置
|
||||
|
||||
See below for common syntax/ file location of dpkg which will help you if you want to check more about it.
|
||||
下面是 dpkg 常见命令的语法及 dpkg 相关文件的位置,如果想深入了解,这些对你肯定大有益处。
|
||||
|
||||
<iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="90" width="728" id="_mN_gpt_827143833" style="border-width: 0px; border-style: initial; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline;"></iframe>
|
||||
```
|
||||
[General syntax for dpkg]
|
||||
### dpkg 命令的语法
|
||||
$ dpkg -[command] [.deb package name]
|
||||
|
||||
$ dpkg -[command] [package name]
|
||||
|
||||
[dpkg releated files location]
|
||||
### dpkg 相关文件的位置
|
||||
$ /var/lib/dpkg
|
||||
|
||||
[This file contain modified package info by dpkg command like (install, remove, etc..,)]
|
||||
### 这个文件包含了被 dpkg 命令(install、remove 等)所修改的包的信息
|
||||
$ /var/lib/dpkg/status
|
||||
|
||||
[This file contain available package list]
|
||||
### 这个文件包含了可用包的列表
|
||||
$ /var/lib/dpkg/status
|
||||
|
||||
```
|
||||
|
||||
#### 2) Install/Upgrade the package
|
||||
### 2) 安装/升级软件
|
||||
|
||||
Use the below command to install/upgrade .deb packge on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc..,. Here i’m going to install Atom through atom-amd64.deb file. It will upgrade if it’s installed other wise install a fresh one.
|
||||
在基于 Debian 的系统里,比如 Debian、Mint、Ubuntu 和 elementryOS,用以下命令来安装/升级 .deb 软件包。这里我要用 `atom-amd64.deb` 文件安装 Atom。要是已经安装了 Atom,就会升级它。要么就会安装一个新的 Atom。
|
||||
|
||||
```
|
||||
[Install/Upgrade dpkg packages]
|
||||
### 安装或升级 dpkg 软件包
|
||||
$ sudo dpkg -i atom-amd64.deb
|
||||
Selecting previously unselected package atom.
|
||||
(Reading database ... 426102 files and directories currently installed.)
|
||||
@ -52,9 +52,9 @@ Processing triggers for mime-support (3.58ubuntu1) ...
|
||||
|
||||
```
|
||||
|
||||
#### 3) Install a package from folder
|
||||
### 3) 从文件夹里安装软件
|
||||
|
||||
Use the below command to install the packages recursively from directory on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc,. This will install all the *.deb packages under the /opt/software directory.
|
||||
在基于 Debian 的系统里,用下列命令从目录中逐个安装软件。这会安装 `/opt/software` 目录下的所有以 .deb 为后缀的软件。
|
||||
|
||||
```
|
||||
$ sudo dpkg -iR /opt/software
|
||||
@ -70,9 +70,9 @@ Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
|
||||
Processing triggers for mime-support (3.58ubuntu1) ...
|
||||
```
|
||||
|
||||
#### 4) Print the Installed packages list
|
||||
### 4) 显示已安装软件列表
|
||||
|
||||
Use the below command to List all installed packages, along with package version and description on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc..,.
|
||||
以下命令可以列出 Debian 系的系统中所有已安装的软件,同时会显示软件版本和描述信息。
|
||||
|
||||
```
|
||||
$ dpkg -l
|
||||
@ -92,11 +92,10 @@ ii account-plugin-salut 3.12.10-0ubuntu2 amd64
|
||||
|
||||
```
|
||||
|
||||
#### 5) Check particular Installed package
|
||||
### 5) 查看指定的已安装软件
|
||||
|
||||
Use the below command to List individual installed package, along with package version and description on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc..,.
|
||||
用以下命令列出指定的一个已安装软件,同时会显示软件版本和描述信息。
|
||||
|
||||
<iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="90" width="728" id="_mN_gpt_827143833" style="border-width: 0px; border-style: initial; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline;"></iframe>
|
||||
```
|
||||
$ dpkg -l atom
|
||||
Desired=Unknown/Install/Remove/Purge/Hold
|
||||
@ -108,9 +107,9 @@ ii atom 1.5.3 amd64 A hackable text editor for the 21st
|
||||
|
||||
```
|
||||
|
||||
#### 6) Check package Installed Location
|
||||
### 6) 查看软件安装目录
|
||||
|
||||
Use the below command to Check package Installed Location on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc..,.
|
||||
以下命令可以在基于 Debian 的系统上查看软件的安装路径。
|
||||
|
||||
```
|
||||
$ dpkg -L atom
|
||||
@ -128,9 +127,9 @@ $ dpkg -L atom
|
||||
|
||||
```
|
||||
|
||||
#### 7) View deb package content
|
||||
### 7) 查看 deb 包内容
|
||||
|
||||
Use the below command to View deb package content, It will show list of files on inside .deb package.
|
||||
下列命令可以查看 deb 包内容。它会显示 .deb 包中的一系列文件。
|
||||
|
||||
```
|
||||
$ dpkg -c atom-amd64.deb
|
||||
@ -149,9 +148,9 @@ drwxr-xr-x root/root 0 2016-02-13 02:13 ./usr/share/doc/
|
||||
.
|
||||
```
|
||||
|
||||
#### 8) Display details about package
|
||||
### 8) 显示软件的详细信息
|
||||
|
||||
Use the below command to Display detailed information about package, package group, version, maintainer, Architecture, display depends packages, description, etc.,.
|
||||
以下命令可以显示软件的详细信息,如软件名、软件类别、版本、维护者、软件架构、依赖的软件、软件描述等等。
|
||||
|
||||
```
|
||||
$ dpkg -s atom
|
||||
@ -169,9 +168,9 @@ Description: A hackable text editor for the 21st Century.
|
||||
Atom is a free and open source text editor that is modern, approachable, and hackable to the core.</atom@github.com>
|
||||
```
|
||||
|
||||
#### 9) Find what package owns the file
|
||||
### 9) 查看文件属于哪个软件
|
||||
|
||||
Use the below command to find out what package does file belong.
|
||||
用以下命令来查看文件属于哪个软件。
|
||||
|
||||
```
|
||||
$ dpkg -S /usr/bin/atom
|
||||
@ -179,11 +178,11 @@ atom: /usr/bin/atom
|
||||
|
||||
```
|
||||
|
||||
#### 10) Remove/Delete package
|
||||
### 10) 移除/删除软件
|
||||
|
||||
以下命令可以用来移除/删除一个已经安装的软件,但不删除配置文件。
|
||||
|
||||
Use the below command to Remove/Delete an installed package except configuration files.
|
||||
|
||||
<iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="90" width="728" id="_mN_gpt_827143833" style="border-width: 0px; border-style: initial; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline;"></iframe>
|
||||
```
|
||||
$ sudo dpkg -r atom
|
||||
(Reading database ... 426404 files and directories currently installed.)
|
||||
@ -196,9 +195,9 @@ Processing triggers for mime-support (3.58ubuntu1) ...
|
||||
|
||||
```
|
||||
|
||||
#### 11) Purge package
|
||||
### 11) 清除软件
|
||||
|
||||
Use the below command to Remove/Delete everything including configuration files.
|
||||
以下命令可以用来移除/删除包括配置文件在内的所有文件。
|
||||
|
||||
```
|
||||
$ sudo dpkg -P atom
|
||||
@ -212,28 +211,26 @@ Processing triggers for mime-support (3.58ubuntu1) ...
|
||||
|
||||
```
|
||||
|
||||
#### 12) Read more about dpkg
|
||||
### 12) 了解更多
|
||||
|
||||
Use the below commands to read more about dpkg command information.
|
||||
用以下命令来查看更多关于 dpkg 的信息。
|
||||
|
||||
```
|
||||
$ dpkg -help
|
||||
or
|
||||
或
|
||||
$ man dpkg
|
||||
|
||||
```
|
||||
|
||||
Enjoy….)
|
||||
开始体验 dpkg 吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.2daygeek.com/dpkg-command-examples/
|
||||
|
||||
作者:[MAGESH MARUTHAMUTHU ][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
作者:[MAGESH MARUTHAMUTHU][a]
|
||||
译者:[GitFuture](https://github.com/GitFuture)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,140 @@
|
||||
轻轻几个点击,在 AWS 和 Azure 上搭建 Docker 数据中心
|
||||
===================================================
|
||||
|
||||
通过几个点击即可在 “AWS 快速起步”和“Azure 市场”上高效搭建产品级 Docker 数据中心。
|
||||
|
||||
通过 AWS 快速起步的 CloudFormation 模板和在 Azure 市场上的预编译模板来部署 Docker 数据中心使得比以往在公有云基础设施下的部署企业级的 CaaS Docker 环境更加容易。
|
||||
|
||||
Docker 数据中心 CaaS 平台为各种规模的企业的敏捷应用部署提供了容器和集群的编排和管理,使之更简单、安全和可伸缩。使用新为 Docker 数据中心预编译的云模板,开发者和 IT 运维人员可以无缝的把容器化的应用迁移到亚马逊 EC2 或者微软的 Azure 环境而无需修改任何代码。现在,企业可以快速实现更高的计算和运营效率,可以通过短短几步操作实现支持 Docker 的容器管理和编排。
|
||||
|
||||
### 什么是 Docker 数据中心?
|
||||
|
||||
Docker 数据中心包括了 Docker 通用控制面板(Docker Universal Control Plane)(UCP),Docker 可信注册库( Docker Trusted Registry)(UTR)和商用版 Docker 引擎(CS Docker Engine),并带有与客户的应用服务等级协议相匹配的商业支持服务。
|
||||
|
||||
- Docker 通用控制面板(UCP),一种企业级的集群管理方案,帮助客户通过单个管理面板管理整个集群
|
||||
- Docker 可信注册库(DTR), 一种镜像存储管理方案,帮助客户安全存储和管理 Docker 镜像
|
||||
- 商用版的 Docker 引擎
|
||||
|
||||
![](http://img.scoop.it/lVraAJgJbjAKqfWCLtLuZLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
### 在 AWS 上快速布置 Docker 数据中心
|
||||
|
||||
秉承 Docker 与 AWS 最佳实践,参照 AWS 快速起步教程来,你可以在 AWS 云上快速部署 Docker 容器。Docker 数据中心快速起步基于模块化和可定制的 CloudFormation 模板,客户可以在其之上增加额外功能或者为自己的 Docker 部署修改模板。
|
||||
|
||||
- [AWS 的 Docker 数据中心应用说明](https://youtu.be/aUx7ZdFSkXU)
|
||||
|
||||
#### 架构
|
||||
|
||||
![](http://img.scoop.it/sZ3_TxLba42QB-r_6vuApLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
AWS Cloudformation 的安装过程始于创建 AWS 资源,这些 AWS 需要的资源包括:VPC、安全组、公有与私有子网、因特网网关、NAT 网关与 S3 bucket。
|
||||
|
||||
然后,AWS Cloudformation 启动第一个 UCP 控制器实例,紧接着,安装 Docker 引擎和 UCP 容器。它把第一个 UCP 控制器创建的根证书备份到 S3。一旦第一个 UCP 控制器成功运行,其他 UCP 控制器、UCP 集群节点和第一个 DTR 复制的进程就会被触发。和第一个 UCP 控制器节点类似,其他所有节点创建进程也都由商用版 Docker 引擎开始,然后安装并运行 UCP 和 DTR 容器以加入集群。两个弹性负载均衡器(ELB),一个分配给 UCP,另外一个为 DTR 服务,它们启动并自动完成配置来在两个可用区(AZ)之间提供弹性负载均衡。
|
||||
|
||||
除这些之外,如有需要,UCP 控制器和节点在 ASG 中启动并提供扩展功能。这种架构确保 UCP 和 DTR 两者都部署在两个 AZ 上以增强弹性与高可靠性。在公有或者私有 HostedZone 上,Route53 用来动态注册或者配置 UCP 和 DTR。
|
||||
|
||||
![](http://img.scoop.it/HM7Ag6RFvMXvZ_iBxRgKo7nTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
#### 快速起步模板的核心功能如下:
|
||||
|
||||
- 创建 VPC、不同 AZ 上的私有和公有子网、ELB、NAT 网关、因特网网关、自动伸缩组,它们全部基于 AWS 最佳实践
|
||||
- 为 DDC 创建一个 S3 bucket,其用于证书备份和 DTR 映像存储(DTR 需要额外配置)
|
||||
- 在客户的 VPC 范畴,跨多 AZ 部署 3 个 UCP 控制器
|
||||
- 创建预配置正常检测的 UCP ELB
|
||||
- 创建一个 DNS 记录并关联到 UCP ELB
|
||||
- 创建可伸缩的 UCP 节点集群
|
||||
- 在 VPC 范畴内,跨多 AZ 创建 3 个 DTR 副本
|
||||
- 创建一个预配置正常检测的 DTR
|
||||
- 创建一个 DNS 记录,并关联到 DTR ELB
|
||||
|
||||
- [下载 AWS 快速指南](https://s3.amazonaws.com/quickstart-reference/docker/latest/doc/docker-datacenter-on-the-aws-cloud.pdf)
|
||||
|
||||
|
||||
### 在 AWS 使用 Docker 数据中心
|
||||
|
||||
1. 登录 [Docker Store][1] 获取 [30 天免费试用][2]或者[联系销售][4]
|
||||
2. 确认之后,看到提示“Launch Stack”后,客户会被重定向到 AWS Cloudformation 入口
|
||||
3. 确认启动 Docker 的 AWS 区域
|
||||
4. 提供启动参数
|
||||
5. 确认并启动
|
||||
6. 启动完成之后,点击输出标签可以看到 UCP/DTR 的 URL、缺省用户名、密码和 S3 bucket 的名称
|
||||
|
||||
- [Docker 数据中心需要 2000 美刀信用担保](https://aws.amazon.com/mp/contactdocker/)
|
||||
|
||||
### 在 Azure 使用 Azure 市场的预编译模板部署
|
||||
|
||||
在 Azure 市场上,Docker 数据中心是一个预先编译的模板,客户可以在 Azure 横跨全球的数据中心即起即用。客户可以根据自己需求从 Azure 提供的各种 VM 中选择适合自己的 VM 部署 Docker 数据中心。
|
||||
|
||||
#### 架构
|
||||
|
||||
![](http://img.scoop.it/V9SpuBCoAnUnkRL3J-FRFLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
Azure 部署过程始于输入一些基本用户信息,如 ssh 登录的管理员用户名(系统级管理员)和资源组名称。你可以把资源组理解为一组有生命周期和部署边界的资源集合。你可以在这个链接了解更多关于资源组的信息: http://azure.microsoft.com/en-us/documentation/articles/resource-group-overview/ 。
|
||||
|
||||
下一步,输入集群详细信息,包括:UCP 控制器 VM 大小、控制器个数(缺省为 3 个)、UCP 节点 VM 大小、UCP 节点个数(缺省 1,最大值为 10)、DTR 节点 VM 大小、DTR 节点个数、虚拟网络名和地址(例如:10.0.0.1/19)。关于网络,客户可以配置 2 个子网:第一个子网分配给 UCP 控制器 ,第二个分配给 DTC 和 UCP 节点。
|
||||
|
||||
最后,点击 OK 完成部署。对于小集群,服务开通需要大约 15-19 分钟,大集群更久些。
|
||||
|
||||
![](http://img.scoop.it/DXPM5-GXP0j2kEhno0kdRLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
![](http://img.scoop.it/321ElkCf6rqb7u_-nlGPtrnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
#### 如何在 Azure 部署
|
||||
|
||||
1. 注册 [Docker 数据中心 30 天试用][5]许可或者[联系销售][6]
|
||||
2. [跳转到微软 Azure 市场的 Docker 数据中心][7]
|
||||
3. [查看部署文档][8]
|
||||
|
||||
|
||||
---
|
||||
|
||||
通过注册获取 Docker 数据中心许可证开始,然后你就能够通过 AWS 或者 Azure 模板搭建自己的数据中心。
|
||||
|
||||
- [获取 30 天试用许可证][9]
|
||||
- [通过视频理解 Docker 数据中心架构][10]
|
||||
- [观看演示视频][11]
|
||||
- [获取 AWS 提供的部署 Docker 数据中心的 75 美元红包奖励][12]
|
||||
|
||||
了解有关 Docker 的更多信息:
|
||||
|
||||
- 初识 Docker? 尝试一下 10 分钟[在线学习课程][20]
|
||||
- 分享镜像,自动构建,或用一个[免费的 Docker Hub 账号][21]尝试更多
|
||||
- 阅读 [Docker 1.12 发行说明][22]
|
||||
- 订阅 [Docker Weekly][23]
|
||||
- 报名参加即将到来的 [Docker Online Meetups][24]
|
||||
- 参加即将发生的 [Docker Meetups][25]
|
||||
- 观看 [DockerCon EU2015][26]视频
|
||||
- 开始为 [Docker][27] 贡献力量
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.docker.com/2016/06/docker-datacenter-aws-azure-cloud/
|
||||
|
||||
作者:[Trisha McCanna][a]
|
||||
译者:[firstadream](https://github.com/firstadream)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://blog.docker.com/author/trisha/
|
||||
[1]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[2]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[4]: https://goto.docker.com/contact-us.html
|
||||
[5]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[6]: https://goto.docker.com/contact-us.html
|
||||
[7]: https://azure.microsoft.com/en-us/marketplace/partners/docker/dockerdatacenterdocker-datacenter/
|
||||
[8]: https://success.docker.com/Datacenter/Apply/Docker_Datacenter_on_Azure
|
||||
[9]: http://www.docker.com/trial
|
||||
[10]: https://www.youtube.com/playlist?list=PLkA60AVN3hh8tFH7xzI5Y-vP48wUiuXfH
|
||||
[11]: https://www.youtube.com/playlist?list=PLkA60AVN3hh8a8JaIOA5Q757KiqEjPKWr
|
||||
[12]: https://aws.amazon.com/quickstart/promo/
|
||||
[20]: https://docs.docker.com/engine/understanding-docker/
|
||||
[21]: https://hub.docker.com/
|
||||
[22]: https://docs.docker.com/release-notes/
|
||||
[23]: https://www.docker.com/subscribe_newsletter/
|
||||
[24]: http://www.meetup.com/Docker-Online-Meetup/
|
||||
[25]: https://www.docker.com/community/meetup-groups
|
||||
[26]: https://www.youtube.com/playlist?list=PLkA60AVN3hh87OoVra6MHf2L4UR9xwJkv
|
||||
[27]: https://docs.docker.com/contributing/contributing/
|
||||
|
@ -0,0 +1,143 @@
|
||||
2016 年 Linux 下五个最佳视频编辑软件
|
||||
=====================================================
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/linux-video-ditor-software.jpg)
|
||||
|
||||
概要: 在这篇文章中,Tiwo 讨论了 Linux 下最佳视频编辑器的优缺点和在基于 Ubuntu 的发行版中的安装方法。
|
||||
|
||||
在过去,我们已经在类似的文章中讨论了 [Linux 下最佳图像管理应用软件][1],[Linux 上四个最佳的现代开源代码编辑器][2]。今天,我们来看看 Linux 下的最佳视频编辑软件。
|
||||
|
||||
当谈及免费的视频编辑软件,Windows Movie Maker 和 iMovie 是大多数人经常推荐的。
|
||||
|
||||
不幸的是,它们在 GNU/Linux 下都是不可用的。但是你不必担心这个,因为我们已经为你收集了一系列最佳的视频编辑器。
|
||||
|
||||
### Linux下最佳的视频编辑应用程序
|
||||
|
||||
接下来,让我们来看看 Linux 下排名前五的最佳视频编辑软件:
|
||||
|
||||
#### 1. Kdenlive
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/kdenlive-free-video-editor-on-ubuntu.jpg)
|
||||
|
||||
[Kdenlive][3] 是一款来自于 KDE 的自由而开源的视频编辑软件,它提供双视频监视器、多轨时间轴、剪辑列表、可自定义的布局支持、基本效果和基本转换的功能。
|
||||
|
||||
它支持各种文件格式和各种摄像机和相机,包括低分辨率摄像机(Raw 和 AVI DV 编辑):mpeg2、mpeg4 和 h264 AVCHD(小型摄像机和摄像机);高分辨率摄像机文件,包括 HDV 和 AVCHD 摄像机;专业摄像机,包括 XDCAM-HD^TM 流、IMX^TM (D10)流、DVCAM(D10)、DVCAM、DVCPRO^TM 、DVCPRO50^TM 流和 DNxHD^TM 流等等。
|
||||
|
||||
你可以在命令行下运行下面的命令安装 :
|
||||
|
||||
```
|
||||
sudo apt-get install kdenlive
|
||||
```
|
||||
|
||||
或者,打开 Ubuntu 软件中心,然后搜索 Kdenlive。
|
||||
|
||||
#### 2. OpenShot
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/openshot-free-video-editor-on-ubuntu.jpg)
|
||||
|
||||
[OpenShot][5] 是我们这个 Linux 视频编辑软件列表中的第二选择。 OpenShot 可以帮助您创建支持过渡、效果、调整音频电平的电影,当然,它也支持大多数格式和编解码器。
|
||||
|
||||
您还可以将电影导出到 DVD,上传到 YouTube、Vimeo、Xbox 360 和许多其他常见的格式。 OpenShot 比 Kdenlive 更简单。 所以如果你需要一个简单界面的视频编辑器,OpenShot 会是一个不错的选择。
|
||||
|
||||
最新的版本是 2.0.7。您可以从终端窗口运行以下命令安装 OpenShot 视频编辑器:
|
||||
|
||||
```
|
||||
sudo apt-get install openshot
|
||||
```
|
||||
|
||||
它需要下载 25 MB,安装后需要 70 MB 硬盘空间。
|
||||
|
||||
#### 3. Flowblade Movie Editor
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/flowblade-movie-editor-on-ubuntu.jpg)
|
||||
|
||||
[Flowblade Movie Editor][6] 是一个用于 Linux 的多轨非线性视频编辑器。它是自由而开源的。 它配备了一个时尚而现代的用户界面。
|
||||
|
||||
它是用 Python 编写的,旨在提供一个快速、精确的功能。 Flowblade 致力于在 Linux 和其他自由平台上提供最好的体验。 所以现在没有 Windows 和 OS X 版本。
|
||||
|
||||
要在 Ubuntu 和其他基于 Ubuntu 的系统上安装 Flowblade,请使用以下命令:
|
||||
|
||||
```
|
||||
sudo apt-get install flowblade
|
||||
```
|
||||
|
||||
#### 4. Lightworks
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/lightworks-running-on-ubuntu-16.04.jpg)
|
||||
|
||||
如果你要寻找一个有更多功能的视频编辑软件,这会是答案。 [Lightworks][7] 是一个跨平台的专业的视频编辑器,在 Linux、Mac OS X 和 Windows 系统下都可用。
|
||||
|
||||
它是一个获奖的专业的[非线性编辑][8](NLE)软件,支持高达 4K 的分辨率以及标清和高清格式的视频。
|
||||
|
||||
该应用程序有两个版本:Lightworks 免费版和 Lightworks 专业版。不过免费版本不支持 Vimeo(H.264 / MPEG-4)和 YouTube(H.264 / MPEG-4) - 高达 2160p(4K UHD)、蓝光和 H.264 / MP4 导出选项,以及可配置的位速率设置,但是专业版本支持。
|
||||
|
||||
- Lightworks 免费版
|
||||
- Lightworks 专业版
|
||||
|
||||
专业版本有更多的功能,例如更高的分辨率支持,4K 和蓝光支持等。
|
||||
|
||||
##### 怎么安装Lightworks?
|
||||
|
||||
不同于其他的视频编辑器,安装 Lightwork 不像运行单个命令那么直接。别担心,这不会很复杂。
|
||||
|
||||
- 第1步 – 你可以从 [Lightworks 下载页面][9]下载安装包。这个安装包大约 79.5MB。*请注意:这里没有32 位 Linux 的支持。*
|
||||
- 第2步 – 一旦下载,你可以使用 [Gdebi 软件包安装器][10]来安装。Gdebi 会自动下载依赖关系 :
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/Installing-lightworks-on-ubuntu.jpg)
|
||||
- 第3步 – 现在你可以从 Ubuntu 仪表板或您的 Linux 发行版菜单中打开它。
|
||||
- 第4步 – 当你第一次使用它时,需要一个账号。点击 “Not Registerd?” 按钮来注册。别担心,它是免费的。
|
||||
- 第5步 – 在你的账号通过验证后,就可以登录了。
|
||||
|
||||
现在,Lightworks 可以使用了。
|
||||
|
||||
需要 Lightworks 的视频教程? 在 [Lightworks 视频教程页][11]得到它们。
|
||||
|
||||
#### 5. Blender
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/blender-running-on-ubuntu-16.04.jpg)
|
||||
|
||||
|
||||
Blender 是一个专业的,工业级的开源、跨平台的视频编辑器。在 3D 作品的制作中,是非常受欢迎的。 Blender 已被用于几部好莱坞电影的制作,包括蜘蛛侠系列。
|
||||
|
||||
虽然最初是设计用于制作 3D 模型,但它也可以用于各种格式的视频编辑和输入能力。 该视频编辑器包括:
|
||||
|
||||
- 实时预览、亮度波形、色度矢量示波器和直方图显示
|
||||
- 音频混合、同步、擦除和波形可视化
|
||||
- 多达 32 个插槽用于添加视频、图像、音频、场景、面具和效果
|
||||
- 速度控制、调整图层、过渡、关键帧、过滤器等
|
||||
|
||||
最新的版本可以从 [Blender 下载页][12]下载.
|
||||
|
||||
### 哪一个是最好的视频编辑软件?
|
||||
|
||||
如果你需要一个简单的视频编辑器,OpenShot、Kdenlive 和 Flowblade 是一个不错的选择。这些软件是适合初学者的,并且带有标准规范的系统。
|
||||
|
||||
如果你有一个高性能的计算机,并且需要高级功能,你可以使用 Lightworks。如果你正在寻找更高级的功能, Blender 可以帮助你。
|
||||
|
||||
这就是我写的 5 个最佳的视频编辑软件,它们可以在 Ubuntu、Linux Mint、Elementary 和其他 Linux 发行版下使用。 请与我们分享您最喜欢的视频编辑器。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/best-video-editing-software-linux/
|
||||
|
||||
作者:[Tiwo Satriatama][a]
|
||||
译者:[DockerChen](https://github.com/DockerChen)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/tiwo/
|
||||
[1]: https://linux.cn/article-7462-1.html
|
||||
[2]: https://linux.cn/article-7468-1.html
|
||||
[3]: https://kdenlive.org/
|
||||
[4]: https://itsfoss.com/tag/open-source/
|
||||
[5]: http://www.openshot.org/
|
||||
[6]: http://jliljebl.github.io/flowblade/
|
||||
[7]: https://www.lwks.com/
|
||||
[8]: https://en.wikipedia.org/wiki/Non-linear_editing_system
|
||||
[9]: https://www.lwks.com/index.php?option=com_lwks&view=download&Itemid=206
|
||||
[10]: https://itsfoss.com/gdebi-default-ubuntu-software-center/
|
||||
[11]: https://www.lwks.com/videotutorials
|
||||
[12]: https://www.blender.org/download/
|
||||
|
||||
|
||||
|
@ -0,0 +1,166 @@
|
||||
删除一个目录下部分类型之外的所有文件的三种方法
|
||||
=========
|
||||
|
||||
有的时候,你可能会遇到这种情况,你需要删除一个目录下的所有文件,或者只是简单的通过删除除了一些指定类型(以指定扩展名结尾)之外的文件来清理一个目录。
|
||||
|
||||
在这篇文章,我们将会向你展现如何通过 `rm`、 `find` 和 `globignore` 命令删除一个目录下除了指定文件扩展名或者类型的之外的文件。
|
||||
|
||||
在我们进一步深入之前,让我们开始简要的了解一下 Linux 中的一个重要的概念 —— 文件名模式匹配,它可以让我们解决眼前的问题。
|
||||
|
||||
在 Linux 下,一个 shell 模式是一个包含以下特殊字符的字符串,称为通配符或者元字符:
|
||||
|
||||
1. `*` – 匹配 0 个或者多个字符
|
||||
2. `?` – 匹配任意单个字符
|
||||
3. `[序列]` – 匹配序列中的任意一个字符
|
||||
4. `[!序列]` – 匹配任意一个不在序列中的字符
|
||||
|
||||
我们将在这儿探索三种可能的办法,包括:
|
||||
|
||||
### 使用扩展模式匹配操作符删除文件
|
||||
|
||||
下来列出了不同的扩展模式匹配操作符,这些模式列表是一个用 `|` 分割包含一个或者多个文件名的列表:
|
||||
|
||||
1. `*(模式列表)` – 匹配 0 个或者多个出现的指定模式
|
||||
2. `?(模式列表)` – 匹配 0 个或者 1 个出现的指定模式
|
||||
4. `@(模式列表)` – 匹配 1 个或者多个出现的指定模式
|
||||
5. `!(模式列表)` – 匹配除了一个指定模式之外的任何内容
|
||||
|
||||
为了使用它们,需要像下面一样打开 extglob shell 选项:
|
||||
|
||||
```
|
||||
# shopt -s extglob
|
||||
|
||||
```
|
||||
|
||||
**1. 输入以下命令,删除一个目录下除了 filename 之外的所有文件**
|
||||
|
||||
```
|
||||
$ rm -v !("filename")
|
||||
```
|
||||
![删除 Linux 下除了一个文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/DeleteAll-Files-Except-One-File-in-Linux.png)
|
||||
|
||||
*删除 Linux 下除了一个文件之外的所有文件*
|
||||
|
||||
**2. 删除除了 filename1 和 filename2 之外的所有文件**
|
||||
|
||||
```
|
||||
$ rm -v !("filename1"|"filename2")
|
||||
```
|
||||
![在 Linux 下删除除了一些文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Few-Files-in-Linux.png)
|
||||
|
||||
*在 Linux 下删除除了一些文件之外的所有文件*
|
||||
|
||||
**3. 下面的例子显示如何通过交互模式删除除了 `.zip` 之外的所有文件**
|
||||
|
||||
```
|
||||
$ rm -i !(*.zip)
|
||||
```
|
||||
|
||||
![在 Linux 下删除除了 Zip 文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Zip-Files-in-Linux.png)
|
||||
|
||||
*在 Linux 下删除除了 Zip 文件之外的所有文件*
|
||||
|
||||
**4. 接下来,通过如下的方式你可以删除一个目录下除了所有的`.zip` 和 `.odt` 文件的所有文件,并且在删除的时候,显示正在删除的文件:**
|
||||
|
||||
```
|
||||
$ rm -v !(*.zip|*.odt)
|
||||
```
|
||||
![删除除了指定文件扩展的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Certain-File-Extensions.png)
|
||||
|
||||
*删除除了指定文件扩展的所有文件*
|
||||
|
||||
一旦你已经执行了所有需要的命令,你还可以使用如下的方式关闭 extglob shell 选项。
|
||||
|
||||
```
|
||||
$ shopt -u extglob
|
||||
```
|
||||
|
||||
### 使用 Linux 下的 find 命令删除文件
|
||||
|
||||
在这种方法下,我们可以[只使用 find 命令][5]的适当的选项或者采用管道配合 `xargs` 命令,如下所示:
|
||||
|
||||
```
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -delete
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm {}
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm [options] {}
|
||||
```
|
||||
|
||||
**5. 下面的命令将会删除当前目录下除了 `.gz` 之外的所有文件**
|
||||
|
||||
```
|
||||
$ find . -type f -not -name '*.gz' -delete
|
||||
```
|
||||
![find 命令 —— 删除 .gz 之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-gz-Files.png)
|
||||
|
||||
*find 命令 —— 删除 .gz 之外的所有文件*
|
||||
|
||||
**6. 使用管道和 xargs,你可以通过如下的方式修改上面的例子:**
|
||||
|
||||
```
|
||||
$ find . -type f -not -name '*gz' -print0 | xargs -0 -I {} rm -v {}
|
||||
```
|
||||
![使用 find 和 xargs 命令删除文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-Files-Using-Find-and-Xargs-Command.png)
|
||||
|
||||
*使用 find 和 xargs 命令删除文件*
|
||||
|
||||
**7. 让我们看一个额外的例子,下面的命令行将会删除掉当前目录下除了 `.gz`、 `.odt` 和 `.jpg` 之外的所有文件:**
|
||||
|
||||
```
|
||||
$ find . -type f -not \(-name '*gz' -or -name '*odt' -or -name '*.jpg' \) -delete
|
||||
```
|
||||
![删除除了指定扩展文件的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-File-Extensions.png)
|
||||
|
||||
*删除除了指定扩展文件的所有文件*
|
||||
|
||||
### 通过 bash 中的 GLOBIGNORE 变量删除文件
|
||||
|
||||
然而,最后的方法,只适用于 bash。 `GLOBIGNORE` 变量存储了一个路径名展开(pathname expansion)功能的忽略模式(或文件名)列表,以冒号分隔。
|
||||
|
||||
为了使用这种方法,切换到要删除文件的目录,像下面这样设置 `GLOBIGNORE` 变量:
|
||||
|
||||
```
|
||||
$ cd test
|
||||
$ GLOBIGNORE=*.odt:*.iso:*.txt
|
||||
```
|
||||
|
||||
在这种情况下,除了 `.odt`、 `.iso` 和 `.txt` 之外的所有文件,都将从当前目录删除。
|
||||
|
||||
现在,运行如下的命令清空这个目录:
|
||||
|
||||
```
|
||||
$ rm -v *
|
||||
```
|
||||
|
||||
之后,关闭 `GLOBIGNORE` 变量:
|
||||
|
||||
```
|
||||
$ unset GLOBIGNORE
|
||||
```
|
||||
![使用 bash 变量 GLOBIGNORE 删除文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-Files-Using-Bash-GlobIgnore.png)
|
||||
|
||||
*使用 bash 变量 GLOBIGNORE 删除文件*
|
||||
|
||||
注:为了理解上面的命令行采用的标识的意思,请参考我们在每一个插图中使用的命令对应的 man 手册。
|
||||
|
||||
就这些了!如果你知道有实现相同目录的其他命令行技术,不要忘了通过下面的反馈部分分享给我们。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/delete-all-files-in-directory-except-one-few-file-extensions/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[yangmingming](https://github.com/yangmingming)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-Files-Using-Bash-GlobIgnore.png
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-File-Extensions.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-Files-Using-Find-and-Xargs-Command.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-gz-Files.png
|
||||
[5]:http://www.tecmint.com/35-practical-examples-of-linux-find-command/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Certain-File-Extensions.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Zip-Files-in-Linux.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Few-Files-in-Linux.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/10/DeleteAll-Files-Except-One-File-in-Linux.png
|
@ -0,0 +1,27 @@
|
||||
98% 的开发者在工作中使用了开源软件
|
||||
==================
|
||||
|
||||
![developer using open source](http://i0.wp.com/opensourceforu.com/wp-content/uploads/2016/07/developer.jpg?resize=750%2C500)
|
||||
|
||||
开源每天都会达到新的高度。但是一个新的研究表明超过 98% 的开发者在工作中使用开源工具。
|
||||
|
||||
Git 仓库管理软件 [GitLab][1] 进行了一项调查披露了一些关于开源接受度的有趣事实。针对开发人员群体的调查表明 98% 的开发者更喜欢在工作中使用开源,91% 选择在工作和个人项目中选择使用相同的开发工具。此外,92% 的人认为分布式版本控制系统(Git 仓库)在工作中很重要。
|
||||
|
||||
在所有的偏好编程语言中,JavaScript 占了 51% 的受访者比例。它后面是 Python、PHP、Java、Swift 和Objective-C。86% 的开发者认为安全是代码的主要判断标准。
|
||||
|
||||
GitLab 首席执行官兼联合创始人 Sid Sijbrandij 在一次声明中表示:“尽管过程驱动的开发技术在过去已经取得了成功,但开发人员正在寻找一种更自然的软件开发革新以促进项目生命周期内的协作和信息共享。”
|
||||
|
||||
这份报告来自 GitLab 在 7 月 6 日和 27 日之间对使用其存储库平台的 362 家初创企业和企业的 CTO、开发人员和 DevOps 专业人士的调查。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://opensourceforu.com/2016/11/98-percent-developers-use-open-source-at-work/
|
||||
|
||||
作者:[JAGMEET SINGH][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://opensourceforu.com/author/jagmeet-singh/
|
||||
[1]:https://about.gitlab.com/2016/11/02/global-developer-survey-2016/
|
@ -1,148 +0,0 @@
|
||||
TOP 5 BEST VIDEO EDITING SOFTWARE FOR LINUX IN 2016
|
||||
=====================================================
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/linux-video-ditor-software.jpg)
|
||||
|
||||
Brief: Tiwo discusses the best video editors for Linux, their pros and cons and the installation method for Ubuntu-based distros in this article.
|
||||
|
||||
We have discussed [best photo management applications for Linux][1], [best code editors for Linux][2] in similar articles in the past. Today we shall see the best video editing software for Linux.
|
||||
|
||||
When asked about free video editing software, Windows Movie Maker and iMovie is what most people often suggest.
|
||||
|
||||
Unfortunately, both of them are not available for GNU/Linux. But you don’t need to worry about it, we have pooled together a list of best free video editors for you.
|
||||
|
||||
### BEST VIDEO EDITOR APPS FOR LINUX
|
||||
|
||||
Let’s have a look at the top 5 best free video editing software for Linux below :
|
||||
|
||||
#### 1. KDENLIVE
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/kdenlive-free-video-editor-on-ubuntu.jpg)
|
||||
|
||||
[Kdenlive][3] is a free and [open source][4] video editing software from KDE that provides dual video monitors, a multi-track timeline, clip list, customizable layout support, basic effects, and basic transitions.
|
||||
It supports wide variety of file formats and a wide range of camcorders and cameras including Low resolution camcorder (Raw and AVI DV editing), Mpeg2, mpeg4 and h264 AVCHD (small cameras and camcorders), High resolution camcorder files, including HDV and AVCHD camcorders, Professional camcorders, including XDCAM-HD™ streams, IMX™ (D10) streams, DVCAM (D10) , DVCAM, DVCPRO™, DVCPRO50™ streams and DNxHD™ streams.
|
||||
|
||||
You can install it from terminal by running the following command :
|
||||
|
||||
```
|
||||
sudo apt-get install kdenlive
|
||||
```
|
||||
|
||||
Or, open Ubuntu Software Center then search Kdenlive.
|
||||
|
||||
#### 2. OPENSHOT
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/openshot-free-video-editor-on-ubuntu.jpg)
|
||||
|
||||
[OpenShot][5] is the second choice in our list of Linux video editing software. OpenShot can help you create the film that supports for transitions, effects, adjusting audio levels, and of course, it support of most formats and codecs.
|
||||
|
||||
You can also export your film to DVD, upload to YouTube, Vimeo, Xbox 360, and many other common formats. OpenShot is simpler than kdenlive. So if you need a video editor with a simple UI OpenShot is a good choice.
|
||||
|
||||
The latest version is 2.0.7. You can install OpenShot video editor by run the following command from terminal window :
|
||||
|
||||
```
|
||||
sudo apt-get install openshot
|
||||
```
|
||||
|
||||
It needs to download 25 MB, and 70 MB disk space after installed.
|
||||
|
||||
#### 3. FLOWBLADE MOVIE EDITOR
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/flowblade-movie-editor-on-ubuntu.jpg)
|
||||
|
||||
[Flowblade Movie Editor][6] is a multitrack non-linear video editor for Linux. It is free and open source. It comes with a stylish and modern user interface.
|
||||
|
||||
Written in Python, it is designed to provide a fast, and precise. Flowblade has focused on providing the best possible experience on Linux and other free platforms. So there’s no Windows and OS X version for now.
|
||||
|
||||
To install Flowblade in Ubuntu and other Ubuntu based systems, use the command below:
|
||||
|
||||
```
|
||||
sudo apt-get install flowblade
|
||||
```
|
||||
|
||||
#### 4. LIGHTWORKS
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/lightworks-running-on-ubuntu-16.04.jpg)
|
||||
|
||||
If you looking for a video editor software that has more feature, this is the answer. [Lightworks][7] is a cross-platform professional video editor, available for Linux, Mac OS X and Windows.
|
||||
|
||||
It is an award winning professional [non-linear editing][8] (NLE) software that supports resolutions up to 4K as well as video in SD and HD formats.
|
||||
|
||||
This application has two versions: Lightworks Free and Lightworks Pro. While free version doesn’t support Vimeo (H.264 / MPEG-4) and YouTube (H.264 / MPEG-4)- Up to 2160p (4K UHD), Blu-ray, and H.264/MP4 export option with configurable bitrate setting, then pro version is.
|
||||
|
||||
- Lightworks Free
|
||||
- Lightworks Pro
|
||||
|
||||
Pro version has more features such as higher resolution support, 4K and Blue Ray support etc.
|
||||
|
||||
##### HOW TO INSTALL LIGHTWORKS?
|
||||
|
||||
Unlike the other video editors, installing Lightwork is not as straight forward as running a single command. Don’t worry, it’s not that complicated either.
|
||||
|
||||
- Step 1 – You can get the package from [Lightworks Downloads Page][9]. The package’s size about 79,5 MB.
|
||||
|
||||
>Please note: There’s no Linux 32-bit support.
|
||||
|
||||
- Step 2 – Once downloaded, you can install it using [Gdebi package installer][10]. Gdebi automatically downloads the dependency :
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/Installing-lightworks-on-ubuntu.jpg)
|
||||
|
||||
- Step 3 – Now you can open it from Ubuntu dashboard, or your Linux distro’s menu.
|
||||
|
||||
- Step 4 – It needs an account when you use it for first time. Click at Not Registerd? button to register. Don’t worry, it’s free!
|
||||
|
||||
- Step 5 – After your account has been verified, now login.
|
||||
|
||||
Now the Lightworks is ready to use.
|
||||
|
||||
Need Lightworks video tutorial? Get them at [Lightworks video tutorials Page][11].
|
||||
|
||||
#### 5. BLENDER
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/blender-running-on-ubuntu-16.04.jpg)
|
||||
|
||||
Blender is a professional, industry-grade open source, cross platform video editor. It is popular for 3D works. Blender has been used in several Hollywood movies including Spider Man series.
|
||||
|
||||
Although originally designed for produce 3D modeling, but it can also be used for video editing and input capabilities with a variety of formats. The Video Editor includes:
|
||||
|
||||
- Live preview, luma waveform, chroma vectorscope and histogram displays
|
||||
- Audio mixing, syncing, scrubbing and waveform visualization
|
||||
- Up to 32 slots for adding video, images, audio, scenes, masks and effects
|
||||
- Speed control, adjustment layers, transitions, keyframes, filters and more.
|
||||
|
||||
The latest version can be downloaded from [Blender Download Page][12].
|
||||
|
||||
### WHICH IS THE BEST VIDEO EDITING SOFTWARE?
|
||||
|
||||
If you need a simple video editor, OpenShot, Kdenlive or Flowblade is a good choice. These are suitable for beginners and a system with standard specification.
|
||||
|
||||
Then if you have a high-end computer, and need advanced features you can go out with Lightworks. If you are looking for more advanced features, Blender has got your back.
|
||||
|
||||
So that’s all I can write about 5 best video editing software for Linux such as Ubuntu, Linux Mint, Elementary, and other Linux distributions. Share with us which video editor you like the most.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/best-video-editing-software-linux/
|
||||
|
||||
作者:[Tiwo Satriatama][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/tiwo/
|
||||
[1]: https://itsfoss.com/linux-photo-management-software/
|
||||
[2]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/
|
||||
[3]: https://kdenlive.org/
|
||||
[4]: https://itsfoss.com/tag/open-source/
|
||||
[5]: http://www.openshot.org/
|
||||
[6]: http://jliljebl.github.io/flowblade/
|
||||
[7]: https://www.lwks.com/
|
||||
[8]: https://en.wikipedia.org/wiki/Non-linear_editing_system
|
||||
[9]: https://www.lwks.com/index.php?option=com_lwks&view=download&Itemid=206
|
||||
[10]: https://itsfoss.com/gdebi-default-ubuntu-software-center/
|
||||
[11]: https://www.lwks.com/videotutorials
|
||||
[12]: https://www.blender.org/download/
|
||||
|
||||
|
||||
|
@ -1,552 +0,0 @@
|
||||
OneNewLife translating
|
||||
|
||||
# Getting Started with Webpack 2
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/2000/1*yI44h8Df-l-2LUqvXIi8JQ.png)
|
||||
|
||||
Webpack 2 will be out of beta [once the documentation has been finished][26]. But that doesn’t mean you can’t start using version 2 now if you know how to configure it.
|
||||
|
||||
### What is Webpack?
|
||||
|
||||
At its simplest, Webpack is a module bundler for your JavaScript. However, since its release it’s evolved into a manager of all your front-end code (either intentionally or by the community’s will).
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/800/1*yBt2rFj2DbckFliGE0LEyg.png)
|
||||
|
||||
|
||||
A task runner such as _Gulp _can handle many different preprocessers and transpilers, but in all cases, it will take a source _input_ and crunch it into a compiled _output. _However, it does this on a case-by-case basis with no concern for the system at large. That is the burden of the developer: to pick up where the task runner left off and find the proper way for all these moving parts to mesh together in production.
|
||||
|
||||
Webpack attempts to lighten the developer load a bit by asking a bold question: _what if there were a part of the development process that handled dependencies on its own? What if we could simply write code in such a way that the build process managed itself, based on only what was necessary in the end?_
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/800/1*TOFfoH0cXTc8G3Y_F6j3Jg.png)
|
||||
|
||||
If you’ve been a part of the web community for the past few years, you already know the preferred method of solving a problem: _build this with JavaScript._And so Webpack attempts to make the build process easier by passing dependencies through JavaScript. But the true power of its design isn’t simply the code _management_ part; it’s that this management layer is 100% valid JavaScript (with Node features). Webpack gives you the ability to write valid JavaScript that has a better sense of the system at large.
|
||||
|
||||
In other words: _you don’t write code for Webpack. You write code for your projec_t. And Webpack keeps up (with some config, of course).
|
||||
|
||||
In a nutshell, if you’ve ever struggled with any of the following:
|
||||
|
||||
* Accidentally including stylesheets and JS libraries you don’t need into production, bloating the size
|
||||
* Encountering scoping issues—both from CSS and JavaScript
|
||||
* Finding a good system for using Node/Bower modules in your JavaScript, or relying on a crazy backend configuration to properly utilize those modules
|
||||
* Needing to optimize asset delivery better but fearing you’ll break something
|
||||
|
||||
…then you could benefit from Webpack. It handles all the above effortlessly by letting JavaScript worry about your dependencies and load order instead of your developer brain. The best part? Webpack can even run purely on the server side, meaning you can still build [progressively-enhanced][25] websites using Webpack.
|
||||
|
||||
### First Steps
|
||||
|
||||
We’ll use [Yarn][24] (`brew install yarn`) in this tutorial instead of `npm`, but it’s totally up to you; they do the same thing. From our project folder, we’ll run the following in a terminal window to add Webpack 2 to both our global packages and our local project:
|
||||
|
||||
```
|
||||
yarn global add webpack@2.1.0-beta.25 webpack-dev-server@2.1.0-beta.9
|
||||
yarn add --dev webpack@2.1.0-beta.25 webpack-dev-server@2.1.0-beta.9
|
||||
```
|
||||
|
||||
We’ll then declare a webpack configuration with a `webpack.config.js` file in the root of our project directory:
|
||||
|
||||
```
|
||||
`'use strict';
|
||||
|
||||
const webpack = require("webpack");
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
app: "./app.js",
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
};`
|
||||
```
|
||||
|
||||
_Note: _`___dirname_`_ refers to the root of your project._
|
||||
|
||||
Remember that Webpack “knows” what’s going in your project? It _knows_ by reading your code (don’t worry; it signed an NDA). Webpack basically does the following:
|
||||
|
||||
1. Starting from the `context` folder, …
|
||||
2. … it looks for `entry` filenames …
|
||||
3. … and reads the content. Every `import` ([ES6][7]) or `require()` (Node) dependency it finds as it parses the code, it bundles for the final build. It then searches _those_ dependencies, and those dependencies’ dependencies, until it reaches the very end of the “tree”—only bundling what it needed to, and nothing else.
|
||||
4. From there, Webpack bundles everything to the `output.path` folder, naming it using the `output.filename` naming template (`[name]` gets replaced with the object key from `entry`)
|
||||
|
||||
So if our `src/app.js` file looked something like this (assuming we ran `yarn add --dev moment` beforehand):
|
||||
|
||||
```
|
||||
'use strict';
|
||||
```
|
||||
|
||||
```
|
||||
import moment from 'moment';
|
||||
var rightNow = moment().format('MMMM Do YYYY, h:mm:ss a');
|
||||
console.log( rightNow );
|
||||
```
|
||||
|
||||
```
|
||||
// "October 23rd 2016, 9:30:24 pm"
|
||||
```
|
||||
|
||||
We’d run
|
||||
|
||||
```
|
||||
webpack -p
|
||||
```
|
||||
|
||||
_Note: The _`_p_`_ flag is “production” mode and uglifies/minifies output._
|
||||
|
||||
And it would output a `dist/app.bundle.js` that logged the current date & time to the console. Note that Webpack automatically knew what `'moment'`referred to (although if you had a `moment.js` file in your directory, by default Webpack would have prioritized this over your `moment` Node module).
|
||||
|
||||
### Working with Multiple Files
|
||||
|
||||
You can specify any number of entry/output points you wish by modifying only the `entry` object.
|
||||
|
||||
#### Multiple files, bundled together
|
||||
|
||||
```
|
||||
`'use strict';
|
||||
|
||||
const webpack = require("webpack");
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
app: ["./home.js", "./events.js", "./vendor.js"],
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
};`
|
||||
```
|
||||
|
||||
Will all be bundled together as one `dist/app.bundle.js` file, in array order.
|
||||
|
||||
#### Multiple files, multiple outputs
|
||||
|
||||
```
|
||||
`const webpack = require("webpack");
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
home: "./home.js",
|
||||
events: "./events.js",
|
||||
contact: "./contact.js",
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
};`
|
||||
```
|
||||
|
||||
Alternately, you may choose to bundle multiple JS files to break up parts of your app. This will be bundled as 3 files: `dist/home.bundle.js`, `dist/events.bundle.js`, and `dist/contact.bundle.js`.
|
||||
|
||||
#### Advanced auto-bundling
|
||||
|
||||
If you’re breaking up your application into multiple `output` bundles (useful if one part of your app has a ton of JS you don’t need to load up front), there’s a likelihood you may be duplicating code across those files, because it will resolve each dependency separately from one another. Fortunately, Webpack has a built-in _CommonsChunk_ plugin to handle this:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
plugins: [
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: "commons",
|
||||
filename: "commons.js",
|
||||
minChunks: 2,
|
||||
}),
|
||||
],
|
||||
```
|
||||
|
||||
```
|
||||
// …
|
||||
};
|
||||
```
|
||||
|
||||
Now, across your `output` files, if you have any modules that get loaded `2` or more times (set by `minChunks`), it will bundle that into a `commons.js` file which you can then cache on the client side. This will result in an additional header request, sure, but you prevent the client from downloading the same libraries more than once. So there are many scenarios where this is a net gain for speed.
|
||||
|
||||
### Developing
|
||||
|
||||
Webpack actually has its own development server, so whether you’re developing a static site or are just prototyping your front-end, it’s perfect for either. To get that running, just add a `devServer` object to `webpack.config.js`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
app: "./app.js",
|
||||
},
|
||||
output: {
|
||||
filename: "[name].bundle.js",
|
||||
path: __dirname + "/dist/assets",
|
||||
publicPath: "/assets", // New
|
||||
},
|
||||
devServer: {
|
||||
contentBase: __dirname + "/src", // New
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Now make a `src/index.html` file that has:
|
||||
|
||||
```
|
||||
<script src="/assets/app.bundle.js"></script>
|
||||
```
|
||||
|
||||
… and from your terminal, run:
|
||||
|
||||
```
|
||||
webpack-dev-server
|
||||
```
|
||||
|
||||
Your server is now running at `localhost:8080`. _Note how _`_/assets_`_ in the script tag matches _`_output.publicPath_`_—you can name this whatever you want (useful if you need a CDN)._
|
||||
|
||||
Webpack will hotload any JavaScript changes as you make them without the need to refresh your browser. However, any changes to the`webpack.config.js` file will require a server restart to take effect.
|
||||
|
||||
### Globally-accessible methods
|
||||
|
||||
Need to use some of your functions from a global namespace? Simply set `output.library` within `webpack.config.js`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
output: {
|
||||
library: 'myClassName',
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
… and it will attach your bundle to a `window.myClassName` instance. So using that name scope, you could call methods available to that entry point (you can read more about this setting [on the documentation][23]).
|
||||
|
||||
### Loaders
|
||||
|
||||
Up until now, we’ve only covered working with JavaScript. It’s important to start with JavaScript because _that’s the only language Webpack speaks_. We can work with virtually any file type, as long as we pass it into JavaScript. We do that with _Loaders_.
|
||||
|
||||
A loader can refer to a preprocessor such as Sass, or a transpiler such as Babel. On NPM, they’re usually named `*-loader` such as `sass-loader` or `babel-loader`.
|
||||
|
||||
#### Babel + ES6
|
||||
|
||||
If we wanted to use ES6 via [Babel][22] in our project, we’d first install the appropriate loaders locally:
|
||||
|
||||
```
|
||||
yarn add --dev babel-loader babel-core babel-preset-es2015
|
||||
```
|
||||
|
||||
… and then add it to `webpack.config.js` so Webpack knows where to use it.
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: [{
|
||||
loader: "babel-loader",
|
||||
options: { presets: ["es2015"] }
|
||||
}],
|
||||
},
|
||||
|
||||
// Loaders for other file types can go here
|
||||
```
|
||||
|
||||
```
|
||||
],
|
||||
},
|
||||
```
|
||||
|
||||
```
|
||||
// …
|
||||
};
|
||||
```
|
||||
|
||||
_A note for Webpack 1 users: the core concept for Loaders remains the same, but the syntax has improved. Until they finish the docs this may/may not be the exact preferred syntax._
|
||||
|
||||
This looks for the `/\.js$/` RegEx search for any files that end in `.js` to be loaded via Babel. Webpack relies on RegEx tests to give you complete control—it doesn’t limit you to file extensions or assume your code must be organized in a certain way. For example: maybe your `/my_legacy_code/` folder isn’t written in ES6\. So you could modify the `test` above to be `/^((?!my_legacy_folder).)*\.js$/` which would exclude that specific folder, but process the rest with Babel.
|
||||
|
||||
#### CSS + Style Loader
|
||||
|
||||
If we wanted to only load CSS as our application needed, we could do that as well. Let’s say we have an `index.js` file. We’ll import it from there:
|
||||
|
||||
```
|
||||
import styles from './assets/stylesheets/application.css';
|
||||
```
|
||||
|
||||
We’ll get the following error: `You may need an appropriate loader to handle this file type`. Remember that Webpack can only understand JavaScript, so we’ll have to install the appropriate loader:
|
||||
|
||||
```
|
||||
yarn add --dev css-loader style-loader
|
||||
```
|
||||
|
||||
… and then add a rule to `webpack.config.js`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ["style-loader", "css-loader"],
|
||||
},
|
||||
```
|
||||
|
||||
```
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
_Loaders are processed in __reverse array order__. That means _`_css-loader_`_ will run before _`_style-loader_`_._
|
||||
|
||||
You may notice that even in production builds, this actually bundles your CSS in with your bundled JavaScript, and `style-loader` manually writes your styles to the `<head>`. At first glance it may seem a little kooky, but slowly starts to make more sense the more you think about it. You’ve saved a header request—saving valuable time on some connections—and if you’re loading your DOM with JavaScript anyway, this essentially eliminates [FOUC][21] on its own.
|
||||
|
||||
You’ll also notice that—out of the box—Webpack has automatically resolved all of your `@import` queries by packaging those files together as one (rather than relying on CSS’s default import which can result in gratuitious header requests and slow-loading assets).
|
||||
|
||||
Loading CSS from your JS is pretty amazing, because you now can modularize your CSS in powerful new ways. Say you loaded `button.css`only through `button.js`. This would mean if `button.js` is never actually used_, _its CSS wouldn’t bloat out our production build. If you adhere to component-oriented CSS practices such as SMACSS or BEM, you see the value in pairing your CSS more closely with your markup + JavaScript.
|
||||
|
||||
#### CSS + Node modules
|
||||
|
||||
We can use Webpack to take advantage of importing Node modules using Node’s `~` prefix. If we ran `yarn add normalize.css`, we could use:
|
||||
|
||||
```
|
||||
@import "~normalize.css";
|
||||
```
|
||||
|
||||
… and take full advantage of NPM managing our third party styles for us—versioning and all—without any copy + pasting on our part. Further, getting Webpack to bundle CSS for us has obvious advantages over using CSS’s default import, saving the client from gratuitous header requests and slow load times.
|
||||
|
||||
_Update: this and the following section have been updated for accuracy, no longer confusing using CSS Modules to simply import Node modules. Thanks to _[_Albert Fernández_][20]_ for the help!_
|
||||
|
||||
#### CSS Modules
|
||||
|
||||
You may have heard of [CSS Modules][19], which takes the _C_ out of _CSS_. It typically works best only if you’re building the DOM with JavaScript, but in essence, it magically scopes your CSS classes to the JavaScript file that loaded it ([learn more about it here][18]). If you plan on using it, CSS Modules comes packaged with `css-loader` (`yarn add --dev css-loader`):
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
{ loader: "css-loader", options: { modules: true } }
|
||||
],
|
||||
},
|
||||
```
|
||||
|
||||
```
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
_Note: for _`_css-loader_`_ we’re now using the __expanded object syntax__ to pass an option to it. You can use a string instead as shorthand to use the default options, as we’re still doing with _`_style-loader_`_._
|
||||
|
||||
* * *
|
||||
|
||||
It’s worth noting that you can actually drop the `~` when importing Node Modules with CSS Modules enabled (e.g.: `@import "normalize.css";`). However, you may encounter build errors now when you `@import` your own CSS. If you’re getting “can’t find ___” errors, try adding a `resolve` object to `webpack.config.js` to give Webpack a better understanding of your intended module order.
|
||||
|
||||
```
|
||||
const path = require("path");
|
||||
```
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
//…
|
||||
```
|
||||
|
||||
```
|
||||
resolve: {
|
||||
modules: [path.resolve(__dirname, "src"), "node_modules"]
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
We specified our source directory first, and then `node_modules`. So Webpack will handle resolution a little better, first looking through our source directory and then the installed Node modules, in that order (replace `"src"` and `"node_modules"` with your source and Node module directories, respectively).
|
||||
|
||||
#### Sass
|
||||
|
||||
Need to use Sass? No problem. Install:
|
||||
|
||||
```
|
||||
yarn add --dev sass-loader node-sass
|
||||
```
|
||||
|
||||
And add another rule:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(sass|scss)$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
"css-loader",
|
||||
"sass-loader",
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Then when your Javascript calls for an `import` on a `.scss` or `.sass` file, Webpack will do its thing.
|
||||
|
||||
#### CSS bundled separately
|
||||
|
||||
Maybe you’re dealing with progressive enhancement; maybe you need a separate CSS file for some other reason. We can do that easily by swapping out `style-loader` with `extract-text-webpack-plugin` in our config without having to change any code. Take our example `app.js` file:
|
||||
|
||||
```
|
||||
import styles from './assets/stylesheets/application.css';
|
||||
```
|
||||
|
||||
Let’s install the plugin locally (we need the beta version for this as of Oct 2016)…
|
||||
|
||||
```
|
||||
yarn add --dev extract-text-webpack-plugin@2.0.0-beta.4
|
||||
```
|
||||
|
||||
… and add to `webpack.config.js`:
|
||||
|
||||
```
|
||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
```
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
```
|
||||
|
||||
```
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
ExtractTextPlugin.extract("css"),
|
||||
{ loader: "css-loader", options: { modules: true } },
|
||||
],
|
||||
},
|
||||
|
||||
// …
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new ExtractTextPlugin({
|
||||
filename: "[name].bundle.css",
|
||||
allChunks: true,
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
Now when running `webpack -p` you’ll also notice an `app.bundle.css` file in your `output` directory. Simply add a `<link>` tag to that file in your HTML as you would normally.
|
||||
|
||||
#### HTML
|
||||
|
||||
As you might have guessed, there’s also an `[html-loader][6]`[ plugin][17] for Webpack. However, when we get to loading HTML with JavaScript, this is about the point where we branch off into a myriad of differing approaches, and I can’t think of one single example that would set you up for whatever you’re planning on doing next. Typically, you’d load HTML for the purpose of using JavaScript-flavored markup such as [JSX][16] or [Mustache][15] or [Handlebars][14] to be used within a larger system such as [React][13], [Angular][12], [Vue][11], or [Ember][10].
|
||||
|
||||
So I’ll end the tutorial here: you _can_ load markup with Webpack, but by this point you’ll be making your own decisions about your architecture that neither I nor Webpack can make for you. But using the above examples for reference and searching for the right loaders on NPM should be enough to get you going.
|
||||
|
||||
### Thinking in Modules
|
||||
|
||||
In order to get the most out of Webpack, you’ll have to think in modules—small, reusable, self-contained processes that do one thing and one thing well. That means taking something like this:
|
||||
|
||||
```
|
||||
└── js/
|
||||
└── application.js // 300KB of spaghetti code
|
||||
```
|
||||
|
||||
… and turning it into this:
|
||||
|
||||
```
|
||||
└── js/
|
||||
├── components/
|
||||
│ ├── button.js
|
||||
│ ├── calendar.js
|
||||
│ ├── comment.js
|
||||
│ ├── modal.js
|
||||
│ ├── tab.js
|
||||
│ ├── timer.js
|
||||
│ ├── video.js
|
||||
│ └── wysiwyg.js
|
||||
│
|
||||
└── application.js // ~ 1KB of code; imports from ./components/
|
||||
```
|
||||
|
||||
The result is clean, reusable code. Each individual component depends on `import`-ing its own dependencies, and `export`-ing what it wants to make public to other modules. Pair this with Babel + ES6, and you can utilize [JavaScript Classes][9] for great modularity, and _don’t-think-about-it _scoping that just works.
|
||||
|
||||
For more on modules, see [this excellent article by Preethi Kasreddy][8].
|
||||
|
||||
* * *
|
||||
|
||||
### Further Reading
|
||||
|
||||
* [What’s New in Webpack 2][5]
|
||||
* [Webpack Config docs][4]
|
||||
* [Webpack Examples][3]
|
||||
* [React + Webpack Starter Kit][2]
|
||||
* [Webpack How-to][1]
|
||||
|
||||
</section>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.madewithenvy.com/getting-started-with-webpack-2-ed2b86c68783#.oozfpppao
|
||||
|
||||
作者:[Drew Powers][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://blog.madewithenvy.com/@an_ennui
|
||||
[1]:https://github.com/petehunt/webpack-howto
|
||||
[2]:https://github.com/kriasoft/react-starter-kit
|
||||
[3]:https://github.com/webpack/webpack/tree/master/examples
|
||||
[4]:https://webpack.js.org/configuration/
|
||||
[5]:https://gist.github.com/sokra/27b24881210b56bbaff7
|
||||
[6]:https://github.com/webpack/html-loader
|
||||
[7]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
|
||||
[8]:https://medium.freecodecamp.com/javascript-modules-a-beginner-s-guide-783f7d7a5fcc
|
||||
[9]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
|
||||
[10]:http://emberjs.com/
|
||||
[11]:http://vuejs.org/
|
||||
[12]:https://angularjs.org/
|
||||
[13]:https://facebook.github.io/react/
|
||||
[14]:http://handlebarsjs.com/
|
||||
[15]:https://github.com/janl/mustache.js/
|
||||
[16]:https://jsx.github.io/
|
||||
[17]:https://github.com/webpack/html-loader
|
||||
[18]:https://github.com/css-modules/css-modules
|
||||
[19]:https://github.com/css-modules/css-modules
|
||||
[20]:https://medium.com/u/901a038e32e5
|
||||
[21]:https://en.wikipedia.org/wiki/Flash_of_unstyled_content
|
||||
[22]:https://babeljs.io/
|
||||
[23]:https://webpack.js.org/concepts/output/#output-library
|
||||
[24]:https://yarnpkg.com/
|
||||
[25]:https://www.smashingmagazine.com/2009/04/progressive-enhancement-what-it-is-and-how-to-use-it/
|
||||
[26]:https://github.com/webpack/webpack/issues/1545#issuecomment-255446425
|
@ -1,121 +0,0 @@
|
||||
alim0x translating
|
||||
|
||||
How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux
|
||||
===
|
||||
|
||||
Let us start by defining a bad sector/block, it’s a section on a disk drive or flash memory that can not be read from or written to anymore, as a result of a fixed [physical damage on the disk][7] surface or failed flash memory transistors.
|
||||
|
||||
As bad sectors continue to accumulate, they can undesirably or destructively affect your disk drive or flash memory capacity or even lead to a possible hardware failure.
|
||||
|
||||
It is also important to note that the presence of bad blocks should alert you to start thinking of getting a new disk drive or simply mark the bad blocks as unusable.
|
||||
|
||||
Therefore, in this article, we will go through the necessary steps that can enable you determine the presence or absence of bad sectors on your Linux disk drive or flash memory using certain [disk scanning utilities][6].
|
||||
|
||||
That said, below are the methods:
|
||||
|
||||
### Check Bad Sectors in Linux Disks Using badblocks Tool
|
||||
|
||||
A badblocks program enables users to scan a device for bad sectors or blocks. The device can be a hard disk or an external disk drive, represented by a file such as /dev/sdc.
|
||||
|
||||
Firstly, use the [fdisk command][5] with superuser privileges to display information about all your disk drives or flash memory plus their partitions:
|
||||
|
||||
```
|
||||
$ sudo fdisk -l
|
||||
|
||||
```
|
||||
|
||||
[![List Linux Filesystem Partitions](http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Filesystem-Partitions.png)][4]
|
||||
|
||||
List Linux Filesystem Partitions
|
||||
|
||||
Then scan your Linux disk drive to check for bad sectors/blocks by typing:
|
||||
|
||||
```
|
||||
$ sudo badblocks -v /dev/sda10 > badsectors.txt
|
||||
|
||||
```
|
||||
|
||||
[![Scan Hard Disk Bad Sectors in Linux](http://www.tecmint.com/wp-content/uploads/2016/10/Scan-Hard-Disk-Bad-Sectors-in-Linux.png)][3]
|
||||
|
||||
Scan Hard Disk Bad Sectors in Linux
|
||||
|
||||
In the command above, badblocks is scanning device /dev/sda10 (remember to specify your actual device) with the `-v` enabling it to display details of the operation. In addition, the results of the operation are stored in the file badsectors.txt by means of output redirection.
|
||||
|
||||
In case you discover any bad sectors on your disk drive, unmount the disk and instruct the operating system not to write to the reported sectors as follows.
|
||||
|
||||
You will need to employ e2fsck (for ext2/ext3/ext4 file systems) or fsck command with the badsectors.txt file and the device file as in the command below.
|
||||
|
||||
The `-l` option tells the command to add the block numbers listed in the file specified by filename (badsectors.txt) to the list of bad blocks.
|
||||
|
||||
```
|
||||
------------ Specifically for ext2/ext3/ext4 file-systems ------------
|
||||
$ sudo e2fsck -l badsectors.txt /dev/sda10
|
||||
|
||||
OR
|
||||
|
||||
------------ For other file-systems ------------
|
||||
$ sudo fsck -l badsectors.txt /dev/sda10
|
||||
|
||||
```
|
||||
|
||||
### Scan Bad Sectors on Linux Disk Using Smartmontools
|
||||
|
||||
This method is more reliable and efficient for modern disks (ATA/SATA and SCSI/SAS hard drives and solid-state drives) which ship in with a S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) system that helps detect, report and possibly log their health status, so that you can figure out any impending hardware failures.
|
||||
|
||||
You can install smartmontools by running the command below:
|
||||
|
||||
```
|
||||
------------ On Debian/Ubuntu based systems ------------
|
||||
$ sudo apt-get install smartmontools
|
||||
|
||||
------------ On RHEL/CentOS based systems ------------
|
||||
$ sudo yum install smartmontools
|
||||
|
||||
```
|
||||
|
||||
Once the installation is complete, use smartctl which controls the S.M.A.R.T system integrated into a disk. You can look through its man page or help page as follows:
|
||||
|
||||
```
|
||||
$ man smartctl
|
||||
$ smartctl -h
|
||||
|
||||
```
|
||||
|
||||
Now execute the smartctrl command and name your specific device as an argument as in the following command, the flag `-H` or `--health` is included to display the SMART overall health self-assessment test result.
|
||||
|
||||
```
|
||||
$ sudo smartctl -H /dev/sda10
|
||||
|
||||
```
|
||||
|
||||
[![Check Linux Hard Disk Health](http://www.tecmint.com/wp-content/uploads/2016/10/Check-Linux-Hard-Disk-Health.png)][2]
|
||||
|
||||
Check Linux Hard Disk Health
|
||||
|
||||
The result above indicates that your hard disk is healthy, and may not experience hardware failures any soon.
|
||||
|
||||
For an overview of disk information, use the `-a` or `--all` option to print out all SMART information concerning a disk and `-x` or `--xall` which displays all SMART and non-SMART information about a disk.
|
||||
|
||||
In this tutorial, we covered a very important topic concerning [disk drive health diagnostics][1], you can reach us via the feedback section below to share your thoughts or ask any questions and remember to always stay connected to Tecmint.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/
|
||||
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/defragment-linux-system-partitions-and-directories/
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-Linux-Hard-Disk-Health.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Scan-Hard-Disk-Bad-Sectors-in-Linux.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Filesystem-Partitions.png
|
||||
[5]:http://www.tecmint.com/fdisk-commands-to-manage-linux-disk-partitions/
|
||||
[6]:http://www.tecmint.com/ncdu-a-ncurses-based-disk-usage-analyzer-and-tracker/
|
||||
[7]:http://www.tecmint.com/defragment-linux-system-partitions-and-directories/
|
@ -1,146 +0,0 @@
|
||||
# How to Convert Files to UTF-8 Encoding in Linux
|
||||
|
||||
In this guide, we will describe what character encoding and cover a few examples of converting files from one character encoding to another using a command line tool. Then finally, we will look at how to convert several files from any character set (charset) to UTF-8 encoding in Linux.
|
||||
|
||||
As you may probably have in mind already, a computer does not understand or store letters, numbers or anything else that we as humans can perceive except bits. A bit has only two possible values, that is either a `0` or `1`, `true` or `false`, `yes` or `no`. Every other thing such as letters, numbers, images must be represented in bits for a computer to process.
|
||||
|
||||
In simple terms, character encoding is a way of informing a computer how to interpret raw zeroes and ones into actual characters, where a character is represented by set of numbers. When we type text in a file, the words and sentences we form are cooked-up from different characters, and characters are organized into a charset.
|
||||
|
||||
There are various encoding schemes out there such as ASCII, ANSI, Unicode among others. Below is an example of ASCII encoding.
|
||||
|
||||
```
|
||||
Character bits
|
||||
A 01000001
|
||||
B 01000010
|
||||
|
||||
```
|
||||
|
||||
In Linux, the iconv command line tool is used to convert text from one form of encoding to another.
|
||||
|
||||
You can check the encoding of a file using the file command, by using the `-i` or `--mime` flag which enables printing of mime type string as in the examples below:
|
||||
|
||||
```
|
||||
$ file -i Car.java
|
||||
$ file -i CarDriver.java
|
||||
|
||||
```
|
||||
[
|
||||
![Check File Encoding in Linux](http://www.tecmint.com/wp-content/uploads/2016/10/Check-File-Encoding-in-Linux.png)
|
||||
][3]
|
||||
|
||||
Check File Encoding in Linux
|
||||
|
||||
The syntax for using iconv is as follows:
|
||||
|
||||
```
|
||||
$ iconv option
|
||||
$ iconv options -f from-encoding -t to-encoding inputfile(s) -o outputfile
|
||||
|
||||
```
|
||||
|
||||
Where `-f` or `--from-code` means input encoding and `-t` or `--to-encoding` specifies output encoding.
|
||||
|
||||
To list all known coded character sets, run the command below:
|
||||
|
||||
```
|
||||
$ iconv -l
|
||||
|
||||
```
|
||||
[
|
||||
![List Coded Charsets in Linux](http://www.tecmint.com/wp-content/uploads/2016/10/List-Coded-Charsets-in-Linux.png)
|
||||
][2]
|
||||
|
||||
List Coded Charsets in Linux
|
||||
|
||||
### Convert Files from UTF-8 to ASCII Encoding
|
||||
|
||||
Next, we will learn how to convert from one encoding scheme to another. The command below converts from ISO-8859-1 to UTF-8 encoding.
|
||||
|
||||
Consider a file named `input.file` which contains the characters:
|
||||
|
||||
```
|
||||
<EFBFBD> <20> <20> <20>
|
||||
|
||||
```
|
||||
|
||||
Let us start by checking the encoding of the characters in the file and then view the file contents. Closely, we can convert all the characters to ASCII encoding.
|
||||
|
||||
After running the iconv command, we then check the contents of the output file and the new encoding of the characters as below.
|
||||
|
||||
```
|
||||
$ file -i input.file
|
||||
$ cat input.file
|
||||
$ iconv -f ISO-8859-1 -t UTF-8//TRANSLIT input.file -o out.file
|
||||
$ cat out.file
|
||||
$ file -i out.file
|
||||
|
||||
```
|
||||
[
|
||||
![Convert UTF-8 to ASCII in Linux](http://www.tecmint.com/wp-content/uploads/2016/10/Converts-UTF8-to-ASCII-in-Linux.png)
|
||||
][1]
|
||||
|
||||
Convert UTF-8 to ASCII in Linux
|
||||
|
||||
Note: In case the string `//IGNORE` is added to to-encoding, characters that can’t be converted and an error is displayed after conversion.
|
||||
|
||||
Again, supposing the string `//TRANSLIT` is added to to-encoding as in the example above (ASCII//TRANSLIT), characters being converted are transliterated as needed and if possible. Which implies in the event that a character can’t be represented in the target character set, it can be approximated through one or more similar looking characters.
|
||||
|
||||
Consequently, any character that can’t be transliterated and is not in target character set is replaced with a question mark `(?)` in the output.
|
||||
|
||||
### Convert Multiple Files to UTF-8 Encoding
|
||||
|
||||
Coming back to our main topic, to convert multiple or all files in a directory to UTF-8 encoding, you can write a small shell script called encoding.sh as follows:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#enter input encoding here
|
||||
FROM_ENCODING="value_here"
|
||||
#output encoding(UTF-8)
|
||||
TO_ENCODING="UTF-8"
|
||||
#convert
|
||||
CONVERT=" iconv -f $FROM_ENCODING -t $TO_ENCODING"
|
||||
#loop to convert multiple files
|
||||
for file in *.txt; do
|
||||
$CONVERT "$file" -o "${file%.txt}.utf8.converted"
|
||||
done
|
||||
exit 0
|
||||
|
||||
```
|
||||
|
||||
Save the file, then make the script executable. Run it from the directory where your files (`*.txt`) are located.
|
||||
|
||||
```
|
||||
$ chmod +x encoding.sh
|
||||
$ ./encoding.sh
|
||||
|
||||
```
|
||||
|
||||
Important: You can as well use this script for general conversion of multiple files from one given encoding to another, simply play around with the values of the `FROM_ENCODING` and `TO_ENCODING`variable, not forgetting the output file name `"${file%.txt}.utf8.converted"`.
|
||||
|
||||
For more information, look through the iconv man page.
|
||||
|
||||
```
|
||||
$ man iconv
|
||||
|
||||
```
|
||||
|
||||
To sum up this guide, understanding encoding and how to convert from one character encoding scheme to another is necessary knowledge for every computer user more so for programmers when it comes to dealing with text.
|
||||
|
||||
Lastly, you can get in touch with us by using the comment section below for any questions or feedback.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/convert-files-to-utf-8-encoding-in-linux/#
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/wp-content/uploads/2016/10/Converts-UTF8-to-ASCII-in-Linux.png
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Coded-Charsets-in-Linux.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-File-Encoding-in-Linux.png
|
@ -1,286 +0,0 @@
|
||||
(translating by chenzhijun)
|
||||
|
||||
# 4 Easy Ways To Generate A Strong Password In Linux
|
||||
|
||||
|
||||
![Generate a strong password in Linux](https://www.ostechnix.com/wp-content/uploads/2016/11/password-720x340.jpg)
|
||||
Image Courtesy: Google.
|
||||
|
||||
Yesterday, We have covered how to [force users to use a strong password in DEB based systems][8]such as Debian, Ubuntu, Linux Mint, Elementary OS etc. You might wonder how a strong password looks like, and how could I create one? No worries! Here is the 4 easy ways to generate a strong password in Linux. Of course, there are many free tools and ways to accomplish this task, however I consider these methods are simple, and straightforward. Let us get started.
|
||||
|
||||
Download – [Free EBook: “Getting started with Ubuntu 16.04”][7]
|
||||
|
||||
### 1\. Generate a strong password in Linux using OpenSSL
|
||||
|
||||
OpenSSL is available for all Unix-like distributions, Solaris, Mac OS X, and Windows.
|
||||
|
||||
To generate a random password with OpenSSL, fire up your Terminal and run the following command:
|
||||
|
||||
```
|
||||
openssl rand 14 -base64
|
||||
```
|
||||
|
||||
Here, ‘-base64’ string will make sure the password can be typed on a keyboard.
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
wXCHXlxuhrFrFMQLqik=
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_003](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_003.png)
|
||||
][6]
|
||||
|
||||
The above command will generate a random and strong password with length of 14 characters. Remember It is always recommend to generate 14 characters password. Of course you can generate any length of characters using openssl.
|
||||
|
||||
For more details, refer the man pages.
|
||||
|
||||
```
|
||||
man openssl
|
||||
```
|
||||
|
||||
### 2\. Generate a strong password in Linux using Pwgen
|
||||
|
||||
pwgen is simple, yet useful command line utility to generate a random and strong password in seconds. It designs secure passwords that can be easily memorized by humans. It is available in the most Unix-like operating systems.
|
||||
|
||||
To install pwgen in DEB based systems, run:
|
||||
|
||||
```
|
||||
sudo apt-get install pwgen
|
||||
```
|
||||
|
||||
In RPM based systems:
|
||||
|
||||
```
|
||||
sudo yum install pwgen
|
||||
```
|
||||
|
||||
In Arch based systems:
|
||||
|
||||
```
|
||||
sudo pacman -S pwgen
|
||||
```
|
||||
|
||||
Once pwgen installed, generate a random and strong password with length of 14 letters using command:
|
||||
|
||||
```
|
||||
pwgen 14 1
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
Choo4aicozai3a
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_004](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_004.png)
|
||||
][5]
|
||||
|
||||
The above command will create only one password with length of 14 characters. To create 2 different passwords with length of 14 characters, run:
|
||||
|
||||
```
|
||||
pwgen 14 2
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
xee7seerez6Kau Aeshu0geveeji8
|
||||
```
|
||||
|
||||
To crate 100 different passwords (Not necessary though) with length of 14 characters, run:
|
||||
|
||||
```
|
||||
pwgen 14
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
kaeNg3EiVei4ei Oo0iehiJaix5Ae aenuv2eree2Quo iaT7zahH1eN2Aj Bie2owaiFahsie
|
||||
gaan9zu5Xeh5ah ahGeeth8ea5ooh Ir0ueda5poogh5 uo0ohqu2ufaiX2 Mei0pee6Og3zae
|
||||
Oofeiceer8Aipu sheew3aeReidir Dee4Heib2eim2o eig6jar8giPhae Zahde9nae1Niew
|
||||
quatol5Oi3Bah2 quue4eebaiNgaa oGoahieSh5oL4m aequeeQue2piti laige5seePhugo
|
||||
iiGo9Uthee4ros WievaiQu2xech6 shaeve0maaK3ae ool8Pai2eighis EPheiRiet1ohci
|
||||
ZieX9outhoht8N Uh1UoPhah2Thee reaGhohZae5idi oiG4ooshiyi5in keePh1ohshei8y
|
||||
aim5Eevah2thah Xaej8tha5eisho IeGie1Anaalaev gaoY3ohthooh3x chaebeesahTh8e
|
||||
soh7oosieY5eiD ahmoh6Ihii6que Shoowoo5dahbah ieW0aiChubee7I Caet6aikai6aex
|
||||
coo1du2Re9aika Ohnei5Egoh7leV aiyie6Ahdeipho EiV0aeToeth1da iNgaesu4eeyu0S
|
||||
Eeb1suoV3naera railai2Vaina8u xu3OhVee1reeyu Og0eavae3oohoh audahneihaeK8a
|
||||
foo6iechi5Eira oXeixoh6EwuboD we1eiDahNgoh9s ko1Eeju1iedu1z aeP7achiisohr7
|
||||
phang5caeGei5j ait4Shuo5Aitai no4eis9Tohd8oh Quiet6oTaaQuei Dei2pu2NaefeCa
|
||||
Shiim9quiuy0ku yiewooph3thieL thu8Aphai1ieDa Phahnahch1Aam1 oocex7Yaith8oo
|
||||
eraiGaech5ahNg neixa3malif5Ya Eux7chah8ahXix eex1lahXae4Mei uGhahzonu6airu
|
||||
yah8uWahn3jeiW Yi4ye4Choongie io1Vo3aiQuahpi rie4Rucheet6ae Dohbieyaeleis5
|
||||
xi1Zaushohbei7 jeeb9EiSiech0u eewo0Oow7ielie aiquooZamah5th kouj7Jaivohx9o
|
||||
biyeeshesaDi9e she9ooj3zuw6Ah Eit7dei1Yei5la xohN0aeSheipaa Eeg9Phob6neema
|
||||
eengoneo4saeL4 aeghi4feephu6W eiWash2Vie1mee chieceish5ioPe ool4Hongo7ef1o
|
||||
jahBe1pui9thou eeV2choohoa4ee Ohmae0eef4ic8I Eet0deiyohdiew Ke9ue5thohzei3
|
||||
aiyoxeiva8Maih gieRahgh8anahM ve2ath9Eyi5iet quohg6ok3Ahgee theingaech5Nef
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_005](https://www.ostechnix.com/wp-content/plugins/lazy-load/images/1x1.trans.gif)
|
||||
][4]
|
||||
|
||||
To include at least 1 number in the password run:
|
||||
|
||||
```
|
||||
pwgen 14 1 -n 1
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
xoiFush3ceiPhe
|
||||
```
|
||||
|
||||
There are also some useful options available to use with pwgen command.
|
||||
|
||||
```
|
||||
-c or --capitalize (Include at least one capital letter in the password)
|
||||
|
||||
-A or --no-capitalize (Don't include capital letters in the password)
|
||||
|
||||
-n or --numerals (Include at least one number in the password)
|
||||
|
||||
-0 or --no-numerals (Don't include numbers in the password)
|
||||
|
||||
-y or --symbols (Include at least one special symbol in the password)
|
||||
|
||||
-s or --secure (Generate completely random passwords)
|
||||
|
||||
-B or --ambiguous (Don't include ambiguous characters in the password)
|
||||
-h or --help (Print a help message)
|
||||
|
||||
-H or --sha1=path/to/file[#seed] (Use sha1 hash of given file as a (not so) random generator)
|
||||
-C (Print the generated passwords in columns)
|
||||
|
||||
-1 (Don't print the generated passwords in columns)
|
||||
|
||||
-v or --no-vowels (Do not use any vowels so as to avoid accidental nasty words)
|
||||
```
|
||||
|
||||
For more details, check the man pages.
|
||||
|
||||
```
|
||||
man pwgen
|
||||
```
|
||||
|
||||
### 3\. Generate a strong password in Linux using GPG
|
||||
|
||||
GPG (GnuPG or GNU Privacy Guard), is free command-line program and replacement of Symantec’s PGP cryptographic software. It is available for Unix-like operating systems, Microsoft Windows and Android versions.
|
||||
|
||||
To generate a random and strong password with length of 14 characters using GPG, run the following command from the Terminal:
|
||||
|
||||
```
|
||||
gpg --gen-random --armor 1 14
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
DkmsrUy3klzzbIbavx8=
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_006](https://www.ostechnix.com/wp-content/plugins/lazy-load/images/1x1.trans.gif)
|
||||
][3]
|
||||
|
||||
The above command will generate a secure, random, strong and base64 encoded password.
|
||||
|
||||
### 4\. Generate a strong password in Linux using Perl
|
||||
|
||||
Perl is available in the most Linux distribution’s default repositories. Install it using the package manager.
|
||||
|
||||
For example, to install Perl on DEB based systems run:
|
||||
|
||||
```
|
||||
sudo apt-get install perl
|
||||
```
|
||||
|
||||
To install Perl on RPM based systems, run:
|
||||
|
||||
```
|
||||
sudo yum install perl
|
||||
```
|
||||
|
||||
On Arch based systems:
|
||||
|
||||
```
|
||||
sudo pacman -S perl
|
||||
```
|
||||
|
||||
Once Perl installed, create a file:
|
||||
|
||||
```
|
||||
vi password.pl
|
||||
```
|
||||
|
||||
Add the following contents in it.
|
||||
|
||||
```
|
||||
#!/usr/bin/perl
|
||||
|
||||
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
|
||||
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;
|
||||
print "$randpassword\n"
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_001](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_001.png)
|
||||
][2]
|
||||
|
||||
Save and close the file.
|
||||
|
||||
Now, go to the location where you saved the file, and run the following command:
|
||||
|
||||
```
|
||||
perl password.pl
|
||||
```
|
||||
|
||||
Replace password.pl with your own filename.
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
3V4CJJnYd
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_002](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_002.png)
|
||||
][1]
|
||||
|
||||
Note: I couldn’t find the original author of this script. If anyone know the author’s name, please let me know in the comment section below. I will add the author name in this guide.
|
||||
|
||||
Please note that you must memorize or keep the passwords you have generated in a safe place in your computer. I recommend you to memorize the password and delete it from your system. It is much better in case your system is compromised by any hackers.
|
||||
|
||||
That’s all for today folks. I will here with another interesting article soon. Until then, stay tuned with OSTechNix.
|
||||
|
||||
Happy Weekend!
|
||||
|
||||
Cheers!!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/4-easy-ways-to-generate-a-strong-password-in-linux/
|
||||
|
||||
作者:[ SK ][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_002.png
|
||||
[2]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_001.png
|
||||
[3]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_006.png
|
||||
[4]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_005.png
|
||||
[5]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_004.png
|
||||
[6]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_003.png
|
||||
[7]:http://ostechnix.tradepub.com/free/w_ubun08/prgm.cgi?a=1
|
||||
[8]:https://www.ostechnix.com/force-users-use-strong-passwords-debian-ubuntu/
|
@ -1,3 +1,5 @@
|
||||
DockerChen翻译中
|
||||
|
||||
# A Practical Guide to Nmap (Network Security Scanner) in Kali Linux
|
||||
|
||||
In the second Kali Linux article, the network tool known as ‘[nmap][30]‘ will be discussed. While nmap isn’t a Kali only tool, it is one of the most [useful network mapping tools][29] in Kali.
|
||||
|
@ -1,145 +0,0 @@
|
||||
|
||||
聊聊Docker Datacenter在AWS和AZURE上的应用
|
||||
===================================================
|
||||
|
||||
|
||||
三言两语介绍一下AWS快速启动应用和Azure Marketplace上产品化和高可用性的Docker部署模板。
|
||||
|
||||
Docker Datacenter AWS快速启动应用使用CloudFormation模板和AZure Marketpalce上预编译的模板来简化企业CaaS Docker环境在公有云基础设施下的部署。
|
||||
|
||||
|
||||
为敏捷应用而生的CasS平台,为各种规模企业提供容器、集群编排和管理等各种简单、安全和可伸缩的服务。使用为Docker Datacenter预编译的崭新的云模板,开发者和IT运维人员可以无缝的把它们的应用迁移到亚马逊EC2或者微软的Azure环境而无需修改任何代码。现在,企业可以快速实现更高的计算和运营效率,Docker可以通过短短几步操作支持容器管理和编排。
|
||||
|
||||
### 什么是Docker Datacenter ?
|
||||
|
||||
|
||||
Docker Datacenter包括Docker通用控制平面,Docker可信注册表和与客户的应用服务等级协议相匹配的商用CS Docker引擎。
|
||||
|
||||
|
||||
- Docker通用控制平面(UCP),一种企业级的集群管理方案,帮助客户通过单个管理仪表盘管理整个集群
|
||||
- Docker可信注册表(DTR), 一种映像管理方案,帮助客户安全存储和管理Docker映像
|
||||
- 商用版的Docker引擎
|
||||
|
||||
![](http://img.scoop.it/lVraAJgJbjAKqfWCLtLuZLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
### 在AWS上快速布置Docker Datacenter
|
||||
|
||||
秉承Docker与AWS最佳实践,参照AWS快速启动教程,你可以在AWS云上快速部署Docker容器。Docker Datacenter快速应用基于模块化和可定制的CloudFormation模板,客户可以在其之上增加额外功能或者为自己的Docker部署修改模板。
|
||||
|
||||
[AWS的Docker Datacenter应用说明](https://youtu.be/aUx7ZdFSkXU)
|
||||
|
||||
#### 架构
|
||||
|
||||
![](http://img.scoop.it/sZ3_TxLba42QB-r_6vuApLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
AWS Cloudformation通过创建AWS资源开始安装进程,这些AWS需要的资源包括:VPC, 安全组,公有与私有子网,因特网网关,NAT网关与S3 bucket。
|
||||
|
||||
然后,AWS Cloudformation启动第一个UCP控制器实例,紧接着,安装Docker引擎和UCP容器。它把UCP控制器创建的根证书备份到S3。一旦第一个UCP控制器成功运行,其他UCP控制器,UCP集群结点和第一个DTR复制进程就会被触发。和第一个UCP控制器结点类似,其他所有结点创建进程也都由商业版的Docker引擎开始,然后安装并运行UCP和DTR容器以加入集群。两个弹性负载均衡器(ELB),一个分配给UCP,另外一个为DTR服务,它们启动、自动完成配置并在两个可用区(Availability Zone)之间提供弹性负载均衡。
|
||||
|
||||
除些之外,如有需要,UCP控制器和结点在ASG中启动并提供扩展功能。这种架构确保UCP和DTR两者都部署在两个AZ上以增强弹性与高可靠性。在公有或者私有HostedZone,Route53用来动态注册或者配置UCP和DTR 。
|
||||
|
||||
![](http://img.scoop.it/HM7Ag6RFvMXvZ_iBxRgKo7nTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
### 快速启动模板的核心功能如下:
|
||||
|
||||
|
||||
- 创建VPC,不同AZ上的私有和公有子网,ELB,NAT网关,因特网网关,自动伸缩组,它们全部基于AWS最佳实践
|
||||
- 为DDC创建一个S3 bucket,其应用于证书备份和DTR映像存储(DTR需要额外配置)
|
||||
- 在客户的VPC范畴,跨多AZ部署3个UCP控制器
|
||||
- 创建预配置正常检测的UCP ELB
|
||||
- 创建一个DNS记录并关联到UCP ELB
|
||||
- 创建可伸缩的UCP结点集群
|
||||
- 在VPC范畴内,跨多AZ创建3个DTR副本
|
||||
- 创建一个预配置正常检测的DTR
|
||||
- 创建一个DNS记录,并关联到DTR ELB
|
||||
|
||||
[下载AWS快速指南](https://s3.amazonaws.com/quickstart-reference/docker/latest/doc/docker-datacenter-on-the-aws-cloud.pdf)
|
||||
|
||||
|
||||
### 在AWS使用Docker Datacenter
|
||||
|
||||
1. 登录[Docker Store][1]获取[30天免费试用][2]或者[联系销售][4]
|
||||
2. 确认之后,提示“Launch Stack”,客户会被重定向到AWS Cloudformation入口
|
||||
3. 确认启动Docker的AWS区域
|
||||
4. 提供启动参数
|
||||
5. 确认并启动
|
||||
6. 启动完成之后,点击输出分页标签可以看到UCP/DTR的 URL、缺省用户名、密码和S3 bucket的名称
|
||||
|
||||
[Docker Datacenter需要2000美刀信用担保](https://aws.amazon.com/mp/contactdocker/)
|
||||
|
||||
|
||||
### 在Azure使用Azure Marketplace上预编译的模板部署
|
||||
|
||||
在Azure Marketplace上,Docker Datacenter是一个预先编译的模板,客户可以在Azure全球不同的数据中心即起即用。客户可以根据自己需求从Azure提供的各种VM中选择部署适合自己的Docker Datacenter。
|
||||
|
||||
|
||||
#### 架构
|
||||
![](http://img.scoop.it/V9SpuBCoAnUnkRL3J-FRFLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
|
||||
Azure部署进程开始于输入一些基本用户信息,如ssh-ing管理员用户名(系统级管理员)和资源组名称。你可以把资源组理解为一组有生命周期和部署边界的资源集合。你可以在这个链接了解更多关于资源组的信息:[azure.microsoft.com/en-us/documentation/articles/resource-group-overview/](azure.microsoft.com/en-us/documentation/articles/resource-group-overview/)
|
||||
|
||||
下一步,输入集群详细信息,包括:UCP控制器VM大小,控制器个数(缺省为3个),UCP结点VM大小,UCP结点个数(缺省1,最大值为10),DTR结点VM大小,DTR结点个数,虚拟网络名和地址(例如:10.0.0.1/19)。关于网络,客户可以配置2个子网:第一个子网分配给UCP控制器 ,第二个分配给DTC和UCP结点。
|
||||
|
||||
最后,点击OK完成部署。对于小集群,服务开通需要大约15-19分钟,大集群更久些。
|
||||
|
||||
![](http://img.scoop.it/DXPM5-GXP0j2kEhno0kdRLnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
![](http://img.scoop.it/321ElkCf6rqb7u_-nlGPtrnTzqrqzN7Y9aBZTaXoQ8Q=)
|
||||
|
||||
#### 如何在Azure部署
|
||||
|
||||
|
||||
1. 注册[Docker Datacenter30天试用][5]许可或者[联系销售][6]
|
||||
2. [跳转到微软Azure Markplace的Docker Datacenter][7]
|
||||
3. [评审部署文档][8]
|
||||
|
||||
如果客户注册获取Docker Datacenter许可证,那么他们将授权启动AWS或者Azure模板.
|
||||
- [获取30天试用许可证][9]
|
||||
- [通过视频理解Docker Datacenter架构][10]
|
||||
- [观看演示视频][11]
|
||||
- [获取AWS提供的部署Docker Datacenter的75美元红包奖励][12]
|
||||
|
||||
### 了解有关Docker的更多信息
|
||||
- 初识Docker? 尝试一下10分钟[在线学习课程][20]
|
||||
- 分享映像,自动构建,或用一个[免费的Docker Hub账号][21]尝试更多
|
||||
- 阅读[Docker 1.12 发行说明][22]
|
||||
- 订阅[Docker Weekly][23]
|
||||
- 报名参加即将到来的[Docker Online Meetups][24]
|
||||
- 参加即将发生的[Docker Meetups][25]
|
||||
- 观看[DockerCon EU2015][26]视频
|
||||
- 开始为[Docker][27]贡献力量
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.docker.com/2016/06/docker-datacenter-aws-azure-cloud/
|
||||
|
||||
作者:[Trisha McCanna][a]
|
||||
译者:[firstadream](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://blog.docker.com/author/trisha/
|
||||
[1]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[2]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[4]: https://goto.docker.com/contact-us.html
|
||||
[5]: https://store.docker.com/login?next=%2Fbundles%2Fdocker-datacenter%2Fpurchase?plan=free-trial
|
||||
[6]: https://goto.docker.com/contact-us.html
|
||||
[7]: https://azure.microsoft.com/en-us/marketplace/partners/docker/dockerdatacenterdocker-datacenter/
|
||||
[8]: https://success.docker.com/Datacenter/Apply/Docker_Datacenter_on_Azure
|
||||
[9]: http://www.docker.com/trial
|
||||
[10]: https://www.youtube.com/playlist?list=PLkA60AVN3hh8tFH7xzI5Y-vP48wUiuXfH
|
||||
[11]: https://www.youtube.com/playlist?list=PLkA60AVN3hh8a8JaIOA5Q757KiqEjPKWr
|
||||
[12]: https://aws.amazon.com/quickstart/promo/
|
||||
[20]: https://docs.docker.com/engine/understanding-docker/
|
||||
[21]: https://hub.docker.com/
|
||||
[22]: https://docs.docker.com/release-notes/
|
||||
[23]: https://www.docker.com/subscribe_newsletter/
|
||||
[24]: http://www.meetup.com/Docker-Online-Meetup/
|
||||
[25]: https://www.docker.com/community/meetup-groups
|
||||
[26]: https://www.youtube.com/playlist?list=PLkA60AVN3hh87OoVra6MHf2L4UR9xwJkv
|
||||
[27]: https://docs.docker.com/contributing/contributing/
|
||||
|
515
translated/tech/20161024 Getting Started with Webpack 2.md
Normal file
515
translated/tech/20161024 Getting Started with Webpack 2.md
Normal file
@ -0,0 +1,515 @@
|
||||
OneNewLife translated
|
||||
|
||||
# Webpack 2 入门
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/2000/1*yI44h8Df-l-2LUqvXIi8JQ.png)
|
||||
|
||||
Webpack 2 即将退出测试,[一旦文档完成][26]。不过这不意味着你现在不能开始使用第 2 版,前提是你知道怎么配置它。
|
||||
|
||||
### Webpack 是什么
|
||||
|
||||
官方的说法是最简单的 —— Webpack 是一个 JavaScript 模块打包器。然而,自从它发布以来,它发展成为了你所有前端代码的管理工具(有意地或社区的意愿)。
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/800/1*yBt2rFj2DbckFliGE0LEyg.png)
|
||||
|
||||
任务运行器,例如 Gulp,可以处理许多不同的预处理器和转换器,但是在所有的情景下,它都需要一个输入源并将其压缩到一个编译好的输出文件中。然而,它是在个案基础上这样做的,不用担心整个系统。这是开发者的负担:找到任务运行器中断的地方,并找到适当的方式将所有这些模块在生产中联合在一起。
|
||||
|
||||
Webpack 试图通过提出一个大胆的想法来减轻开发者的负担:如果有一部分开发过程可以自动处理依赖关系会怎样?如果我们可以简单地写代码,让构建过程只基于最终需求管理自己会怎样?
|
||||
|
||||
![](https://cdn-images-1.medium.com/max/800/1*TOFfoH0cXTc8G3Y_F6j3Jg.png)
|
||||
|
||||
如果你过去几年一直是 web 社区的一员,你已经知道解决问题的首选方法:使用 JavaScript 来构建。因此 Webpack 尝试通过 JavaScript 传递依赖关系使构建过程更加容易。不过这个设计真正的亮点不是简单的代码管理部分,而是管理层由 100% 有效的 JavaScript 实现(具有 Nodejs 特性)。Webpack 能够让你写有效的 JavaScript,更好更全面地了解系统。
|
||||
|
||||
换句话来说:你不需要为 Webpack 写代码。你只需要写项目代码。而且 Webpack 会持续工作(当然需要一些配置)。
|
||||
|
||||
简而言之,如果你曾经遇到过以下任何一种情况:
|
||||
|
||||
* 意外引入一些你不需要在生产中用上的样式表和 JS 库,使项目膨胀
|
||||
* 遇到作用域的问题 —— CSS 和 JavaScript 都会有
|
||||
* 找到一个好的构建系统让你在 JavaScript 中使用 Node/Bower 模块,或者依靠一个疯狂的后端配置来正确地使用这些模块
|
||||
* 需要优化资产交付,但担心你会弄坏一些东西
|
||||
|
||||
那么你可以从 Webpack 中收益了。它通过让 JavaScript 毫不费力地担心你的依赖关系和加载顺序,而不是开发者的大脑。最好的部分是?Webpack 甚至可以纯粹在服务器端运行,这意味着你还可以使用 Webpack 构建[渐进增强][25]的网站。
|
||||
|
||||
### 第一步
|
||||
|
||||
我们将在本教程中使用 [Yarn][24](运行命令 `brew install yarn`) 代替 `npm`,不过这完全取决于你,它们做同样的事情。在我们的项目文件夹中,我们将在终端窗口中运行以下代码,将 Webpack 2 添加到我们的全局软件包以及本地项目中:
|
||||
|
||||
```
|
||||
yarn global add webpack@2.1.0-beta.25 webpack-dev-server@2.1.0-beta.9
|
||||
yarn add --dev webpack@2.1.0-beta.25 webpack-dev-server@2.1.0-beta.9
|
||||
```
|
||||
|
||||
我们接着会通过项目根目录的一个 `webpack.config.js` 文件来声明 webpack 的配置:
|
||||
|
||||
```
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + '/src',
|
||||
entry: {
|
||||
app: './app.js',
|
||||
},
|
||||
output: {
|
||||
path: __dirname + '/dist',
|
||||
filename: '[name].bundle.js',
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
注意:`__dirname` 是指你的项目根目录
|
||||
|
||||
记住,Webpack “知道”你的项目发生了什么。它通过阅读你的代码来实现(别担心,它签署了一个 NDA 协议)。Webpack 基本上执行以下操作:
|
||||
|
||||
1. 从 `context` 文件夹开始...
|
||||
2. ...它查找 `entry` 的文件名...
|
||||
3. ...并读取内容。每一个 `import`([ES6][7])或 `require()`(Nodejs)的依赖会在它解析代码的时候找到,它会在最终构建的时候打包这些依赖项。然后,它会搜索那些依赖项以及那些依赖项所依赖的依赖项,直到它到达“树”的最底端 —— 只是打包它所需要的,没有其它东西。
|
||||
4. Webpack 从 `context` 文件夹打包所有东西到 `output.path` 文件夹,使用 `output.filename` 命名模板来为其命名(其中 `[name]` 被替换成来自 `entry` 的对象键)。
|
||||
|
||||
所以如果我们的 `src/app.js` 文件看起来像这样(假设我们事先运行了 `yarn add --dev moment`):
|
||||
|
||||
```
|
||||
'use strict';
|
||||
|
||||
import moment from 'moment';
|
||||
var rightNow = moment().format('MMMM Do YYYY, h:mm:ss a');
|
||||
console.log( rightNow );
|
||||
|
||||
// "October 23rd 2016, 9:30:24 pm"
|
||||
```
|
||||
|
||||
我们应该运行:
|
||||
|
||||
```
|
||||
webpack -p
|
||||
```
|
||||
|
||||
注意:`p` 标志表示“生产”模式,这会压缩输出文件。
|
||||
|
||||
它会输出一个 `dist/app.bundle.js`,这会将当前日期和时间打印到控制台。要注意 Webpack 会自动识别 `'moment'` 指代什么(虽然如果你有一个 `moment.js` 文件在你的目录,默认情况下 Webpack 会优先考虑你的 `moment` Node 模块)。
|
||||
|
||||
### 使用多个文件
|
||||
|
||||
你可以通过仅仅修改 `entry` 对象来指定任意数量的输入/输出点。
|
||||
|
||||
#### 打包多个文件
|
||||
|
||||
```
|
||||
`'use strict';
|
||||
|
||||
const webpack = require("webpack");
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
app: ["./home.js", "./events.js", "./vendor.js"],
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
};`
|
||||
```
|
||||
|
||||
所有文件都会按照数组的顺序一起被打包成一个 `dist/app.bundle.js` 文件。
|
||||
|
||||
#### 输出多个文件
|
||||
|
||||
```
|
||||
`const webpack = require("webpack");
|
||||
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
home: "./home.js",
|
||||
events: "./events.js",
|
||||
contact: "./contact.js",
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
};`
|
||||
```
|
||||
|
||||
或者,你可以选择打包成多个 JS 文件以便于分割应用的某些模块。这将被打包成 3 个文件:`dist/home.bundle.js`,`dist/events.bundle.js` 和 `dist/contact.bundle.js`。
|
||||
|
||||
#### 高级打包自动化
|
||||
|
||||
如果你将你的应用分割成多个 `output` 输出项(如果你的应用的一部分有大量你不需要预加载的 JS,这会很有用),你可能会重用这些文件的代码,因为它将分别解析每个依赖关系。幸运的是,Webpack 有一个内置的 `CommonsChunk` 插件来处理这个:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
plugins: [
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: "commons",
|
||||
filename: "commons.bundle.js",
|
||||
minChunks: 2,
|
||||
}),
|
||||
],
|
||||
|
||||
// …
|
||||
};
|
||||
```
|
||||
|
||||
现在,在你的 `output` 文件中,如果你有任何模块被加载 2 次以上(通过 `minChunks` 设置),它会把那个模块打包到 `common.js` 文件中,然后你可以将其缓存在客户端。这将生成一个额外的请求头,但是你防止了客户端多次下载同一个库。因此,在很多情景下,这会大大提升速度。
|
||||
|
||||
### 开发
|
||||
|
||||
Webpack actually has its own development server, so whether you’re developing a static site or are just prototyping your front-end, it’s perfect for either. To get that running, just add a `devServer` object to `webpack.config.js`:
|
||||
Webpack 实际上有自己的开发服务器,所以无论你是开发一个静态网站还是只是你的网站前端原型,它都是无可挑剔的。要运行那个服务器,只需要添加一个 `devServer` 对象到 `webpack.config.js`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
context: __dirname + "/src",
|
||||
entry: {
|
||||
app: "./app.js",
|
||||
},
|
||||
output: {
|
||||
filename: "[name].bundle.js",
|
||||
path: __dirname + "/dist/assets",
|
||||
publicPath: "/assets", // New
|
||||
},
|
||||
devServer: {
|
||||
contentBase: __dirname + "/src", // New
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
现在创建一个包含以下代码的 `src/index.html` 文件:
|
||||
|
||||
```
|
||||
<script src="/assets/app.bundle.js"></script>
|
||||
```
|
||||
|
||||
... 在你的终端运行:
|
||||
|
||||
```
|
||||
webpack-dev-server
|
||||
```
|
||||
|
||||
你的服务器现在运行在 `localhost:8080`。注意 `script` 标签里面的 `/assets` 是怎么匹配到 `output.publicPath` 的 —— 你可以随意更改它的名称(如果你需要一个 CDN 的时候这会很有用)。
|
||||
|
||||
Webpack 会热加载所有 JavaScript 更改,而不需要刷新你的浏览器。但是,所有 `webpack.config.js` 文件里面的更改都需要重新启动服务器才能生效。
|
||||
|
||||
### 全局访问方法
|
||||
|
||||
需要在全局空间使用你的函数?在 `webpack.config.js` 里面简单地设置 `output.library`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
output: {
|
||||
library: 'myClassName',
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
这会将你打包好的文件附加到一个 `window.myClassName` 实例。因此,使用该命名空间,你可以调用入口文件的可用方法(可以在[文档][23]中阅读有关此设置的更多信息)。
|
||||
|
||||
### 加载器
|
||||
|
||||
到目前为止,我们所做的一切只涉及 JavaScript。从一开始使用 JavaScript 是重要的,因为它是 Webpack 唯一支持的语言。事实上我们可以处理几乎所有文件类型,只要我们将其转换成 JavaScript。我们用加载器来实现这个功能。
|
||||
|
||||
加载器可以是 Sass 这样的预处理器,或者是 Babel 这样的转译器。在 NPM 上,它们通常被命名为 `*-loader`,例如 `sass-loader` 和 `babel-loader`。
|
||||
|
||||
#### Babel 和 ES6
|
||||
|
||||
如果我们想在项目中通过 [Babel][22] 来使用 ES6,我们首先需要在本地安装合适的加载器:
|
||||
|
||||
```
|
||||
yarn add --dev babel-loader babel-core babel-preset-es2015
|
||||
```
|
||||
|
||||
然后将它添加到 `webpack.config.js`,让 Webpack 知道在哪里使用它。
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: [{
|
||||
loader: "babel-loader",
|
||||
options: { presets: ["es2015"] }
|
||||
}],
|
||||
},
|
||||
|
||||
// Loaders for other file types can go here
|
||||
],
|
||||
},
|
||||
|
||||
// …
|
||||
};
|
||||
```
|
||||
|
||||
Webpack 1 的用户注意:加载器的核心概念没有任何改变,但是语法改进了。直到官方文档完成之前,这可能不是确切的首选语法。
|
||||
|
||||
`/\.js$/` 这个正则表达式查找所有以 `.js` 结尾的待通过 Babel 加载的文件。Webpack 依靠正则检查给予你完全的控制权 —— 它不限制你的文件扩展名或者假设你的代码必须以某种方式组织。例如:也许你的 `/my_legacy_code/` 文件夹下的内容不是用 ES6 写的。所以你可以修改上述的 `test` 为 `/^((?!my_legacy_folder).)\.js$/`,这将会排除那个特定的文件夹,不过会用 Babel 处理其余的文件。
|
||||
|
||||
#### CSS 和 Style 加载器
|
||||
|
||||
如果我们只想加载 CSS 作为我们的应用程序,我们也可以这样做。假设我们有一个 `index.js` 文件,我们将从那里引入:
|
||||
|
||||
```
|
||||
import styles from './assets/stylesheets/application.css';
|
||||
```
|
||||
|
||||
我们会得到以下错误:`你可能需要一个合适的加载器来处理这种类型的文件`。记住,Webpack 只能识别 JavaScript,所以我们必须安装合适的加载器:
|
||||
|
||||
```
|
||||
yarn add --dev css-loader style-loader
|
||||
```
|
||||
|
||||
然后添加一条规则到 `webpack.config.js`:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ["style-loader", "css-loader"],
|
||||
},
|
||||
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
加载器以数组的逆序处理。这意味着 `css-loader` 会比 `style-loader` 先执行。
|
||||
|
||||
你可能会注意到,即使在生产版本中,这实际上是将你的 CSS 和 JavaScript 打包在一起,`style-loader` 手动将你的样式写到 `<head>`。乍一看,它可能看起来有点怪异,但你仔细想想这就慢慢开始变得更加有意义了。你已经节省了一个头部请求 —— 节省了一些连接上的时间。如果你用 JavaScript 来加载你的 DOM,无论如何,这从本质上消除了 [FOUC][21]。
|
||||
|
||||
你还会注意到一个开箱即用的特性 —— Webpack 已经通过将这些文件打包在一起以自动解决你所有的 `@import` 查询(而不是依靠 CSS 默认的 import 方式,这会导致无谓的头部请求以及资源加载缓慢)。
|
||||
|
||||
从你的 JS 加载 CSS 是非常惊人的,因为你现在可以用一种新的强大的方式将你的 CSS 模块化。仅仅通过加载 `button.js` 来加载 `button.css`。这将意味着如果 `button.js` 从来没有真正使用过的话,它的 CSS 就不会膨胀我们的生产版本。如果你坚持面向组件的 CSS 实践,如 SMACSS 或 BEM,你会看到更紧密地结合你的 CSS 和你的标记 + JavaScript 的价值。
|
||||
|
||||
#### CSS 和 Node 模块
|
||||
|
||||
我们可以使用 Webpack 来利用 Node 的使用 `~` 前缀导入 Node 模块的优势。如果我们运行 `yarn add normalize.css`,我们可以使用:
|
||||
|
||||
```
|
||||
@import "~normalize.css";
|
||||
```
|
||||
|
||||
并且充分利用 NPM 来管理我们的第三方样式 —— 版本控制、没有任何副本和粘贴的部分。此外,让 Webpack 为我们打包 CSS 比起使用 CSS 的默认导入方式有明显的优势 —— 节省无谓的头部请求和加载时间。
|
||||
|
||||
更新:这一节和下面一节已经更新为准确的用法,不再使用 CSS 模块简单地导入 Node 模块。感谢 [Albert Fernández][20] 的帮助!
|
||||
|
||||
#### CSS 模块
|
||||
|
||||
你可能听说过 [CSS 模块][19],它消除了 CSS 的层叠性。通常它的最适用场景是只有当你使用 JavaScript 构建 DOM 的时候,但实质上,它神奇地将你的 CSS 类放置到加载它的 JavaScript 文件([在这里了解更多][18])。如果你打算使用它,CSS 模块已经与 `css-loader` 封装在一起(`yarn add --dev css-loader`):
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
{ loader: "css-loader", options: { modules: true } }
|
||||
],
|
||||
},
|
||||
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
注意:对于 `css-loader`,我们现在使用扩展对象语法来给它传递一个选项。你可以使用一个更为精简的字符串来取代默认选项,正如我们仍然使用了 `'style-loader'`。
|
||||
|
||||
* * *
|
||||
|
||||
值得注意的是,当允许导入 CSS 模块的时候(例如:`@import 'normalize.css';`),你完全可以删除掉 `~`。但是,当你 `@import` 你自己的 CSS 的时候,你可能会遇到构建错误。如果你遇到“无法找到 ____”的错误,尝试添加一个 `resolve` 对象到 `webpack.config.js`,让 Webpack 更好地理解你的模块加载顺序。
|
||||
|
||||
```
|
||||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
//…
|
||||
|
||||
resolve: {
|
||||
modules: [path.resolve(__dirname, "src"), "node_modules"]
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
我们首先指定源目录,然后指定 `node_modules`。因此,Webpack 会更好地处理解析度,按照既定的顺序(分别用你的源目录和 Node 模块的目录替换 `'src'` 和 `'node_modules'`),首先查找我们的源目录,然后再查找已安装的 Node 模块。
|
||||
|
||||
#### Sass
|
||||
|
||||
需要使用 Sass?没问题。安装:
|
||||
|
||||
```
|
||||
yarn add --dev sass-loader node-sass
|
||||
```
|
||||
|
||||
并添加新的规则:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(sass|scss)$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
"css-loader",
|
||||
"sass-loader",
|
||||
]
|
||||
}
|
||||
|
||||
// …
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
然后当你的 Javascript 对一个 `.scss` 或 `.sass` 文件调用 `import` 方法的时候,Webpack 会处理的。
|
||||
|
||||
#### CSS 独立打包
|
||||
|
||||
或许你在处理渐进增强的问题;或许你因为其它原因需要一个单独的 CSS 文件。我们可以通过在我们的配置中用 `extract-text-webpack-plugin` 替换 `style-loader` 而轻易地做到这一点,这不需要更改任何代码。以我们的 `app.js` 文件为例:
|
||||
|
||||
```
|
||||
import styles from './assets/stylesheets/application.css';
|
||||
```
|
||||
|
||||
让我们安装这个插件到本地(我们需要 2016 年 10 月的 测试版本):
|
||||
|
||||
```
|
||||
yarn add --dev extract-text-webpack-plugin@2.0.0-beta.4
|
||||
```
|
||||
|
||||
并且添加到 `webpack.config.js`:
|
||||
|
||||
```
|
||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
|
||||
module.exports = {
|
||||
// …
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
ExtractTextPlugin.extract("css"),
|
||||
{ loader: "css-loader", options: { modules: true } },
|
||||
],
|
||||
},
|
||||
|
||||
// …
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new ExtractTextPlugin({
|
||||
filename: "[name].bundle.css",
|
||||
allChunks: true,
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
现在当运行 `webpack -p` 的时候,你的 `output` 目录还会有一个 `app.bundle.css` 文件。只需要像往常一样简单地在你的 HTML 中向该文件添加一个 `<link>` 标签即可。
|
||||
|
||||
#### HTML
|
||||
|
||||
正如你可能已经猜到,Webpack 还有一个 `[html-loader][6]` 插件。但是,当我们用 JavaScript 加载 HTML 时,我们针对不同的场景分成了不同的方法,我无法想出一个单一的例子来为你计划下一步做什么。通常,你需要加载 HTML 以便于在更大的系统(如 [React][13]、[Angular][12]、[Vue][11] 或 [Ember][10])中使用 JavaScript 风格的标记,如 [JSX][16]、[Mustache][15] 或 [Handlebars][14]。
|
||||
|
||||
教程到此为止了:你可以用 Webpack 加载标记,但是进展到这一步的时候,关于你的架构,你将做出自己的决定,我和 Webpack 都无法左右你。不过参考以上的例子以及搜索 NPM 上适用的加载器应该足够你发展下去了。
|
||||
|
||||
### 从模块的角度思考
|
||||
|
||||
为了充分使用 Webpack,你必须从模块的角度来思考 —— 细粒度的、可复用的、用于高效处理每一件事的独立的处理程序。这意味着采取这样的方式:
|
||||
|
||||
```
|
||||
└── js/
|
||||
└── application.js // 300KB of spaghetti code
|
||||
```
|
||||
|
||||
将其转变成这样:
|
||||
|
||||
```
|
||||
└── js/
|
||||
├── components/
|
||||
│ ├── button.js
|
||||
│ ├── calendar.js
|
||||
│ ├── comment.js
|
||||
│ ├── modal.js
|
||||
│ ├── tab.js
|
||||
│ ├── timer.js
|
||||
│ ├── video.js
|
||||
│ └── wysiwyg.js
|
||||
│
|
||||
└── application.js // ~ 1KB of code; imports from ./components/
|
||||
```
|
||||
|
||||
结果呈现了整洁的、可复用的代码。每一个独立的组件依赖于 `import` 自身的依赖,并 `export` 它想要暴露给其它模块的部分。结合 Babel 和 ES6,你可以利用 [JavaScript 类][9] 来实现更强大的模块化,而不用考虑它的工作原理。
|
||||
|
||||
有关模块的更多信息,请参阅 Preethi Kasreddy [这篇优秀的文章][8].
|
||||
|
||||
* * *
|
||||
|
||||
### 延伸阅读
|
||||
|
||||
* [Webpack 2 的新特性][5]
|
||||
* [Webpack 配置文档][4]
|
||||
* [Webpack 范例][3]
|
||||
* [React + Webpack 入门套件][2]
|
||||
* [怎么使用 Webpack][1]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.madewithenvy.com/getting-started-with-webpack-2-ed2b86c68783#.oozfpppao
|
||||
|
||||
作者:[Drew Powers][a]
|
||||
|
||||
译者:[OneNewLife](https://github.com/OneNewLife)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://blog.madewithenvy.com/@an_ennui
|
||||
[1]:https://github.com/petehunt/webpack-howto
|
||||
[2]:https://github.com/kriasoft/react-starter-kit
|
||||
[3]:https://github.com/webpack/webpack/tree/master/examples
|
||||
[4]:https://webpack.js.org/configuration/
|
||||
[5]:https://gist.github.com/sokra/27b24881210b56bbaff7
|
||||
[6]:https://github.com/webpack/html-loader
|
||||
[7]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
|
||||
[8]:https://medium.freecodecamp.com/javascript-modules-a-beginner-s-guide-783f7d7a5fcc
|
||||
[9]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
|
||||
[10]:http://emberjs.com/
|
||||
[11]:http://vuejs.org/
|
||||
[12]:https://angularjs.org/
|
||||
[13]:https://facebook.github.io/react/
|
||||
[14]:http://handlebarsjs.com/
|
||||
[15]:https://github.com/janl/mustache.js/
|
||||
[16]:https://jsx.github.io/
|
||||
[17]:https://github.com/webpack/html-loader
|
||||
[18]:https://github.com/css-modules/css-modules
|
||||
[19]:https://github.com/css-modules/css-modules
|
||||
[20]:https://medium.com/u/901a038e32e5
|
||||
[21]:https://en.wikipedia.org/wiki/Flash_of_unstyled_content
|
||||
[22]:https://babeljs.io/
|
||||
[23]:https://webpack.js.org/concepts/output/#output-library
|
||||
[24]:https://yarnpkg.com/
|
||||
[25]:https://www.smashingmagazine.com/2009/04/progressive-enhancement-what-it-is-and-how-to-use-it/
|
||||
[26]:https://github.com/webpack/webpack/issues/1545#issuecomment-255446425
|
@ -1,178 +0,0 @@
|
||||
# 删除在一个目录下除了一个或者一些带扩展名文件的其他所有文件的三种方法
|
||||
|
||||
有的时候,你可能会遇到这种情况,你需要删除一个目录下的所有文件,或者只是简单的通过删除除了一些指定类型(以指定扩展名结尾)的文件来清空一个目录。
|
||||
|
||||
在这篇文章,我们将会向你展现如何通过 rm、 find 和 globignore 命令删除一个目录下除了指定文件后缀或者类型的的文件。
|
||||
|
||||
在我们进一步深入之前,让我们开始简要的了解一下 Linux 中的一个重要的概念 —— 文件名模式匹配,它可以让我们解决眼前的问题。
|
||||
|
||||
在 Linux 下,一个 shell 模式一个包含以下特殊字符的字符串,称为通配符或者元字符:
|
||||
|
||||
1. `*` – 匹配 0 个或者多个字符
|
||||
2. `?` – 匹配任意单个字符
|
||||
3. `[seq]` – 匹配序列中的任意一个字符
|
||||
4. `[!seq]` – 匹配任意一个不再序列中的字符
|
||||
|
||||
我们将在这儿探索三种可能的办法,包括:
|
||||
|
||||
### 使用扩展模式匹配操作符删除文件
|
||||
|
||||
下来列出了不同的扩展模式匹配操作符,这些模式列表是一个用 `|` 分割包含一个或者多个文件名的列表:
|
||||
|
||||
1. `*(pattern-list)` – 匹配 0 个或者多个出现的指定模式
|
||||
2. `?(pattern-list)` – 匹配 0 个或者 1 个出现的指定模式
|
||||
4. `@(pattern-list)` – 匹配 1 个或者多个出现的指定模式
|
||||
5. `!(pattern-list)` – 匹配除了一个指定模式之外的任何内容
|
||||
|
||||
为了使用它们,像下面一样打开 extglob shell 选项:
|
||||
|
||||
```
|
||||
# shopt -s extglob
|
||||
|
||||
```
|
||||
|
||||
#### 1. 输入以下命令,删除一个目录下除了 filename 之外的所有文件
|
||||
|
||||
```
|
||||
$ rm -v !("filename")
|
||||
|
||||
```
|
||||
[![删除 Linux 下除了一个文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/DeleteAll-Files-Except-One-File-in-Linux.png)][9]
|
||||
|
||||
删除 Linux 下除了一个文件之外的所有文件
|
||||
|
||||
#### 2. 删除除了 filename1 和 filename2 之外的所有文件
|
||||
|
||||
```
|
||||
$ rm -v !("filename1"|"filename2")
|
||||
|
||||
```
|
||||
[![在 Linux 下删除除了一些文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Few-Files-in-Linux.png)][8]
|
||||
|
||||
在 Linux 下删除除了一些文件之外的所有文件
|
||||
|
||||
#### 3. 下面的例子显示如何通过交互模式删除除了 `.zip` 之外的所有文件
|
||||
|
||||
```
|
||||
$ rm -i !(*.zip)
|
||||
|
||||
```
|
||||
[![在 Linux 下删除除了 Zip 文件之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Zip-Files-in-Linux.png)][7]
|
||||
|
||||
在 Linux 下删除除了 Zip 文件之外的所有文件
|
||||
|
||||
#### 4. 接下来,通过如下的方式你可以删除一个目录下除了所有的`.zip` 和 `.odt` 文件的所有文件,并且在删除的时候,显示正在删除的文件:
|
||||
|
||||
```
|
||||
$ rm -v !(*.zip|*.odt)
|
||||
|
||||
```
|
||||
[![删除除了指定文件扩展的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Certain-File-Extensions.png)][6]
|
||||
|
||||
删除除了指定文件扩展的所有文件
|
||||
|
||||
一旦你已经执行了所有需要的命令,使用如下的方式关闭 extglob shell 选项。
|
||||
|
||||
```
|
||||
$ shopt -u extglob
|
||||
|
||||
```
|
||||
|
||||
### 使用 Linux 下的 find 命令删除文件
|
||||
|
||||
在这种方法下,我们可以[只使用 find 命令][5]的适当的选项或者采用管道配合 xargs 命令,如下所示:
|
||||
|
||||
```
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -delete
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm {}
|
||||
$ find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm [options] {}
|
||||
|
||||
```
|
||||
|
||||
#### 5. 下面的命令将会删除当前目录下除了 `.gz` 之外的所有文件
|
||||
|
||||
```
|
||||
$ find . -type f -not -name '*.gz' -delete
|
||||
|
||||
```
|
||||
[![find 命令 —— 删除 .gz 之外的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-gz-Files.png)][4]
|
||||
|
||||
find 命令 —— 删除 .gz 之外的所有文件
|
||||
|
||||
#### 6. 使用管道和 xargs,你可以通过如下的方式修改上面的例子:
|
||||
|
||||
```
|
||||
$ find . -type f -not -name '*gz' -print0 | xargs -0 -I {} rm -v {}
|
||||
|
||||
```
|
||||
[![使用 find 和 xargs 命令删除文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-Files-Using-Find-and-Xargs-Command.png)][3]
|
||||
|
||||
使用 find 和 xargs 命令删除文件
|
||||
|
||||
#### 7. 让我们看一个额外的例子,下面的命令行将会抹除掉当前目录下除了 `.gz`、 `.odt` 和 `.jpg` 之外的所有文件:
|
||||
|
||||
```
|
||||
$ find . -type f -not \(-name '*gz' -or -name '*odt' -or -name '*.jpg' \) -delete
|
||||
|
||||
```
|
||||
[![删除除了指定扩展文件的所有文件](http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-File-Extensions.png)][2]
|
||||
|
||||
删除除了指定扩展文件的所有文件
|
||||
|
||||
### 通过 bash 中的 GLOBIGNORE 变量删除文件
|
||||
|
||||
然而,最后的方法,只适用于 bash。 GLOBIGNORE 变量存储了一个通过路径名扩展忽略的分离的模式(或者文件名)列表。
|
||||
|
||||
为了使用这种方法,移动到要删除文件的目录,像下面这样设置 GLOBIGNORE 变量:
|
||||
|
||||
```
|
||||
$ cd test
|
||||
$ GLOBIGNORE=*.odt:*.iso:*.txt
|
||||
|
||||
```
|
||||
|
||||
在这种情况下,除了 `.odt`、 `.iso` 和 `.txt` 之外的所有文件,都将从当前目录删除。
|
||||
|
||||
现在,运行如下的命令清空这个目录:
|
||||
|
||||
```
|
||||
$ rm -v *
|
||||
|
||||
```
|
||||
|
||||
之后,关闭 GLOBIGNORE 变量:
|
||||
|
||||
```
|
||||
$ unset GLOBIGNORE
|
||||
|
||||
```
|
||||
[![使用 bash 变量 GLOBIGNORE 删除文件](http://www.tecmint.com/wp-content/uploads/2016/10/Delete-Files-Using-Bash-GlobIgnore.png)][1]
|
||||
|
||||
使用 bash 变量 GLOBIGNORE 删除文件
|
||||
|
||||
注:为了理解上面的命令行采用的标识的意思,请参考我们在每一个插图中使用的命令对应的 man 手册。
|
||||
|
||||
就这些了!如果你心里有实现相同目录的其他命令行技术,不要忘了通过下面的反馈部分分享给我们。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/delete-all-files-in-directory-except-one-few-file-extensions/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29
|
||||
|
||||
作者:[ Aaron Kili][a]
|
||||
|
||||
译者:[yangmingming](https://github.com/yangmingming)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-Files-Using-Bash-GlobIgnore.png
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-File-Extensions.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-Files-Using-Find-and-Xargs-Command.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/Remove-All-Files-Except-gz-Files.png
|
||||
[5]:http://www.tecmint.com/35-practical-examples-of-linux-find-command/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Certain-File-Extensions.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Zip-Files-in-Linux.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/10/Delete-All-Files-Except-Few-Files-in-Linux.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/10/DeleteAll-Files-Except-One-File-in-Linux.png
|
@ -0,0 +1,119 @@
|
||||
在 Linux 上检测硬盘坏道和坏块
|
||||
===
|
||||
|
||||
让我们从定义坏道和坏块开始说起,它们是一块磁盘或闪存上不再能够被读写的部分,一般是由于磁盘表面特定的[物理损坏][7]或闪存晶体管失效导致的。
|
||||
|
||||
随着坏道的继续积累,它们会对你的磁盘或闪存容量产生令人不快或破坏性的影响,甚至可能会导致硬件失效。
|
||||
|
||||
同时还需要注意的是坏块的存在警示你应该开始考虑买块新磁盘了,或者简单地将坏块标记为不可用。
|
||||
|
||||
因此,在这篇文章中,我们通过几个必要的步骤,使用特定的[磁盘扫描工具][6]让你能够判断 Linux 磁盘或闪存是否存在坏道。
|
||||
|
||||
以下就是步骤:
|
||||
|
||||
### 在 Linux 上使用坏块工具检查坏道
|
||||
|
||||
坏块工具可以让用户扫描设备检查坏道或坏块。设备可以是一个磁盘或外置磁盘,由一个如 /dev/sdc 这样的文件代表。
|
||||
|
||||
首先,通过超级用户权限执行 [fdisk 命令][5]来显示你的所有磁盘或闪存的信息以及它们的分区信息:
|
||||
|
||||
```
|
||||
$ sudo fdisk -l
|
||||
|
||||
```
|
||||
|
||||
[![列出 Linux 文件系统分区](http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Filesystem-Partitions.png)][4]
|
||||
|
||||
列出 Linux 文件系统分区
|
||||
|
||||
然后用这个命令检查你的 Linux 硬盘上的坏道/坏块:
|
||||
|
||||
```
|
||||
$ sudo badblocks -v /dev/sda10 > badsectors.txt
|
||||
|
||||
```
|
||||
|
||||
[![在 Linux 上扫描硬盘坏道](http://www.tecmint.com/wp-content/uploads/2016/10/Scan-Hard-Disk-Bad-Sectors-in-Linux.png)][3]
|
||||
|
||||
在 Linux 上扫描硬盘坏道
|
||||
|
||||
上面的命令中,badblocks 扫描设备 /dev/sda10(记得指定你的实际设备),-v 选项让它显示操作的详情。另外,这里使用了输出重定向将操作结果重定向到了文件 badsectors.txt。
|
||||
|
||||
如果你在你的磁盘上发现任何坏道,卸载磁盘并像下面这样让系统不要将数据写入回报的扇区中。
|
||||
|
||||
你需要执行 e2fsck(针对 ext2/ext3/ext4 文件系统)或 fsck 命令,命令中还需要用到 badsectors.txt 文件和设备文件。
|
||||
|
||||
`-l` 选项告诉命令将指定文件名文件(badsectors.txt)中列出的扇区号码加入坏块列表。
|
||||
|
||||
```
|
||||
------------ 针对 for ext2/ext3/ext4 文件系统 ------------
|
||||
$ sudo e2fsck -l badsectors.txt /dev/sda10
|
||||
|
||||
或
|
||||
|
||||
------------ 针对其它文件系统 ------------
|
||||
$ sudo fsck -l badsectors.txt /dev/sda10
|
||||
|
||||
```
|
||||
|
||||
### 在 Linux 上使用 Smartmontools 工具扫描坏道
|
||||
|
||||
这个方法对带有 S.M.A.R.T(Self-Monitoring, Analysis and Reporting Technology,自我监控分析报告技术)系统的现代磁盘(ATA/SATA 和 SCSI/SAS 硬盘以及固态硬盘)更加的可靠和高效。S.M.A.R.T 系统能够帮助检测,报告,以及可能记录它们的健康状况,这样你就可以找出任何可能出现的硬件失效。
|
||||
|
||||
你可以使用以下命令安装 smartmontools:
|
||||
|
||||
```
|
||||
------------ 在基于 Debian/Ubuntu 的系统上 ------------
|
||||
$ sudo apt-get install smartmontools
|
||||
|
||||
------------ 在基于 RHEL/CentOS 的系统上 ------------
|
||||
$ sudo yum install smartmontools
|
||||
|
||||
```
|
||||
|
||||
安装完成之后,使用 smartctl 控制磁盘集成的 S.M.A.R.T 系统。你可以这样查看它的手册或帮助:
|
||||
|
||||
```
|
||||
$ man smartctl
|
||||
$ smartctl -h
|
||||
|
||||
```
|
||||
|
||||
然后执行 smartctrl 命令并在命令中指定你的设备作为参数,以下命令包含了参数 `-H` 或 `--health` 以显示 SMART 整体健康自我评估测试结果。
|
||||
|
||||
```
|
||||
$ sudo smartctl -H /dev/sda10
|
||||
|
||||
```
|
||||
|
||||
[![检查 Linux 硬盘健康](http://www.tecmint.com/wp-content/uploads/2016/10/Check-Linux-Hard-Disk-Health.png)][2]
|
||||
|
||||
检查 Linux 硬盘健康
|
||||
|
||||
上面的结果指出你的硬盘很健康,近期内不大可能发生硬件失效。
|
||||
|
||||
要获取磁盘信息总览,使用 `-a` 或 `--all` 选项来显示关于磁盘所有的 SMART 信息,`-x` 或 `--xall` 来显示所有关于磁盘的 SMART 信息以及非 SMART 信息。
|
||||
|
||||
在这个教程中,我们覆盖了有关[磁盘健康诊断][1]的重要话题,你可以下面的反馈区来分享你的想法或提问,并且记得多回来看看。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/
|
||||
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[alim0x](https://github.com/alim0x)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/defragment-linux-system-partitions-and-directories/
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-Linux-Hard-Disk-Health.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Scan-Hard-Disk-Bad-Sectors-in-Linux.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Filesystem-Partitions.png
|
||||
[5]:http://www.tecmint.com/fdisk-commands-to-manage-linux-disk-partitions/
|
||||
[6]:http://www.tecmint.com/ncdu-a-ncurses-based-disk-usage-analyzer-and-tracker/
|
||||
[7]:http://www.tecmint.com/defragment-linux-system-partitions-and-directories/
|
@ -0,0 +1,138 @@
|
||||
# 如何在 Linux 中将文件编码转换为 UTF-8
|
||||
|
||||
在这篇教程中,我们将解释字符编码的含义,然后给出一些使用命令行工具将使用某种字符编码的文件转化为另一种编码的例子。最后,我们将一起看一看如何在 Linux 下将使用各种字符编码的文件转化为 UTF-8 编码。
|
||||
|
||||
你可能已经知道,计算机是不会理解和存储字符、数字或者任何人类能够理解的东西的,除了二进制数据。一个二进制位只有两种可能的值,也就是 `0` 或 `1`,`真`或`假`,`对`或`错`。其它的任何事物,比如字符、数据和图片,必须要以二进制的形式来表现,以供计算机处理。
|
||||
|
||||
简单来说,字符编码是一种可以指示电脑来将原始的 0 和 1 解释成实际字符的方式,在这些字符编码中,字符都可以用数字串来表示。
|
||||
|
||||
字符编码方案有很多种,比如 ASCII, ANCI, Unicode 等等。下面是 ASCII 编码的一个例子。
|
||||
|
||||
```
|
||||
字符 二进制
|
||||
A 01000001
|
||||
B 01000010
|
||||
```
|
||||
|
||||
在 Linux 中,命令行工具 `iconv` 用来将使用一种编码的文本转化为另一种编码。
|
||||
|
||||
你可以使用 `file` 命令,并添加 `-i` 或 `--mime` 参数来查看一个文件的字符编码,这个参数可以让程序像下面的例子一样输出字符串的 mime (Multipurpose Internet Mail Extensions) 数据:
|
||||
|
||||
```
|
||||
$ file -i Car.java
|
||||
$ file -i CarDriver.java
|
||||
```
|
||||
[
|
||||
![在 Linux 中查看文件的编码](http://www.tecmint.com/wp-content/uploads/2016/10/Check-File-Encoding-in-Linux.png)
|
||||
][3]
|
||||
|
||||
在 Linux 中查看文件的编码
|
||||
|
||||
iconv 工具的使用方法如下:
|
||||
|
||||
```
|
||||
$ iconv option
|
||||
$ iconv options -f from-encoding -t to-encoding inputfile(s) -o outputfile
|
||||
```
|
||||
|
||||
在这里,`-f` 或 `--from-code` 标明了输入编码,而 `-t` 或 `--to-encoding` 指定了输出编码。
|
||||
|
||||
为了列出所有已有编码的字符集,你可以使用以下命令:
|
||||
|
||||
```
|
||||
$ iconv -l
|
||||
```
|
||||
[
|
||||
![列出所有已有编码字符集](http://www.tecmint.com/wp-content/uploads/2016/10/List-Coded-Charsets-in-Linux.png)
|
||||
][2]
|
||||
|
||||
列出所有已有编码字符集
|
||||
|
||||
### 将文件从 ISO-8859-1 编码转换为 UTF-8 编码
|
||||
|
||||
下面,我们将学习如何将一种编码方案转换为另一种编码方案。下面的命令将会将 ISO-8859-1 编码转换为 UTF-8 编码。
|
||||
|
||||
Consider a file named `input.file` which contains the characters:
|
||||
考虑如下文件 `input.file`,其中包含这几个字符:
|
||||
|
||||
```
|
||||
<EFBFBD> <20> <20> <20>
|
||||
```
|
||||
|
||||
我们从查看这个文件的编码开始,然后来查看文件内容。最后,我们可以把所有字符转换为 UTF-8 编码。
|
||||
|
||||
在运行 `iconv` 命令之后,我们可以像下面这样检查输出文件的内容,和它使用的字符编码。
|
||||
|
||||
```
|
||||
$ file -i input.file
|
||||
$ cat input.file
|
||||
$ iconv -f ISO-8859-1 -t UTF-8//TRANSLIT input.file -o out.file
|
||||
$ cat out.file
|
||||
$ file -i out.file
|
||||
```
|
||||
[
|
||||
![在 Linux 中将 ISO-8859-1 转化为 UTF-8](http://www.tecmint.com/wp-content/uploads/2016/10/Converts-UTF8-to-ASCII-in-Linux.png)
|
||||
][1]
|
||||
|
||||
在 Linux 中将 ISO-8859-1 转化为 UTF-8
|
||||
|
||||
注意:如果输出编码后面添加了 `//IGNORE` 字符串,那些不能被转换的字符将不会被转换,并且在转换后,程序会显示一条错误信息。
|
||||
|
||||
好,如果字符串 `//TRANSLIT` 被添加到了上面例子中的输出编码之后 (UTF-8//TRANSLIT),待转换的字符会尽量采用形译原则。也就是说,如果某个字符在输出编码方案中不能被表示的话,它将会被替换为一个形状比较相似的字符。
|
||||
|
||||
而且,如果一个字符不在输出编码中,而且不能被形译,它将会在输出文件中被一个问号标记 `(?)` 代替。
|
||||
|
||||
### 将多个文件转换为 UTF-8 编码
|
||||
|
||||
回到我们的主题。如果你想将多个文件甚至某目录下所有文件转化为 UTF-8 编码,你可以像下面一样,编写一个简单的 shell 脚本,并将其命名为 `encoding.sh`:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
# 将 values_here 替换为输入编码
|
||||
FROM_ENCODING="value_here"
|
||||
# 输出编码 (UTF-8)
|
||||
TO_ENCODING="UTF-8"
|
||||
# 转换命令
|
||||
CONVERT=" iconv -f $FROM_ENCODING -t $TO_ENCODING"
|
||||
# 使用循环转换多个文件
|
||||
for file in *.txt; do
|
||||
$CONVERT "$file" -o "${file%.txt}.utf8.converted"
|
||||
done
|
||||
exit 0
|
||||
```
|
||||
|
||||
保存文件,然后为它添加可执行权限。在待转换文件 (*.txt) 所在的目录中运行这个脚本。
|
||||
|
||||
```
|
||||
$ chmod +x encoding.sh
|
||||
$ ./encoding.sh
|
||||
```
|
||||
|
||||
重要事项:你也可以使这个脚本变得更通用,比如转换任意特定的字符编码到另一种编码。为了达到这个目的,你只需要改变 `FROM_ENCODING` 及 `TO_ENCODING` 变量的值。别忘了改一下输出文件的文件名 `"${file%.txt}.utf8.converted"`.
|
||||
|
||||
若要了解更多信息,可以查看 `iconv` 的手册页 (man page)。
|
||||
|
||||
```
|
||||
$ man iconv
|
||||
```
|
||||
|
||||
将这篇指南总结一下,理解字符编码的概念、了解如何将一种编码方案转换为另一种,是一个电脑用户处理文本时必须要掌握的知识,程序员更甚。
|
||||
|
||||
最后,你可以在下面的评论部分中与我们联系,提出问题或反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/convert-files-to-utf-8-encoding-in-linux/#
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[StdioA](https://github.com/StdioA)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/wp-content/uploads/2016/10/Converts-UTF8-to-ASCII-in-Linux.png
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Coded-Charsets-in-Linux.png
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-File-Encoding-in-Linux.png
|
@ -1,29 +0,0 @@
|
||||
# 98%的开发者在工作中使用开源软件
|
||||
|
||||
![developer using open source](http://i0.wp.com/opensourceforu.com/wp-content/uploads/2016/07/developer.jpg?resize=750%2C500)
|
||||
|
||||
开源每天会达到新的高度。但是一个新的研究表明超过98%的开发者在工作中使用开源工具。
|
||||
|
||||
Git仓库管理[GitLab][1]进行了一项调查披露了一些关于开源接受度的有趣事实。由开发人员引导的调查声称98%的开发者更喜欢在工作中使用开源,91%选择在工作和个人项目中使用相同的开发工具。此外,92%的人认为分布式版本控制系统(Git仓库)在工作中很重要。
|
||||
|
||||
在所有的偏好编程语言中,JavaScript占了51%的受访者。它后面是Python、PHP、Java、Swift和Objective-C。86%的开发者认为安全是代码的主要判断标准。
|
||||
|
||||
GitLab首席执行官兼联合创始人Sid Sijbrandij在一次声明中表示:“尽管过程驱动的开发技术在过去已经取得了成功,但开发人员正在寻找一种更自然的软件开发演进以促进项目生命周期内的协作和信息共享”。
|
||||
|
||||
GitLab surveyed 362 startup and enterprise CTOs, developers and DevOps professionals who used its repository platform between July 6 and 27.
|
||||
GitLab调查了在7月6日和27日之间使用其存储库平台的362家创业和企业CTO,开发人员和DevOps专业人士。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://opensourceforu.com/2016/11/98-percent-developers-use-open-source-at-work/
|
||||
|
||||
作者:[JAGMEET SINGH ][a]
|
||||
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://opensourceforu.com/author/jagmeet-singh/
|
||||
[1]:https://about.gitlab.com/2016/11/02/global-developer-survey-2016/
|
@ -0,0 +1,287 @@
|
||||
# 4 种简单方法让你在 Linux 下生成一个高强度密码
|
||||
|
||||
![在 Linux 下生成一个高强度密码](https://www.ostechnix.com/wp-content/uploads/2016/11/password-720x340.jpg)
|
||||
图片来源: Google.
|
||||
|
||||
昨天,我们已经分享了如何 [要求用户在基于 DEB 的系统中使用一个高强度的密码][8],例如在 Debian,Ubuntu,Linux Mint, Elementary OS 等系统中。那么,你可能会疑惑一个高强度的密码究竟是什么样的呢?怎么才能生成一个那样的密码呢?不用担心,下面我们将介绍 4 种简单方法让你在 Linux 中生成一个高强度密码。当然,已经有很多免费的工具或者方式来完成这个任务,但这里我们仅考虑那些简单直接的方法。下面就让我们开始吧。
|
||||
|
||||
下载 – [免费电子书:“Ubuntu 16.04 入门”][7]
|
||||
|
||||
### 1. 在 Linux 中使用 OpenSSL 来生成一个高强度密码
|
||||
|
||||
OpenSSL 在所有的类 Unix 发行版本,Solaris,Mac OS X 和 Windows 中都可以获取到。
|
||||
|
||||
要使用 OpenSSL 生成一个随机密码,唤起你的终端并运行下面的命令:
|
||||
|
||||
```
|
||||
openssl rand 14 -base64
|
||||
```
|
||||
|
||||
上面的 `-base64` 字符串将确保生成的密码可以被键盘敲出来。
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
wXCHXlxuhrFrFMQLqik=
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_003](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_003.png)
|
||||
][6]
|
||||
|
||||
上面的命令将生成一个随机的、长度为 14 个字符的高强度密码。记住我们强烈推荐你生成 14 个字符的密码。
|
||||
当然你可以使用 OpenSSL 生成任意长度的密码。
|
||||
|
||||
要了解更多信息,可以参考联机手册:
|
||||
|
||||
```
|
||||
man openssl
|
||||
```
|
||||
|
||||
### 2. 在 Linux 中使用 Pwgen 来生成一个高强度密码
|
||||
|
||||
pwgen 是一个简单却非常有用的命令行工具,用它可以在短时间内生成一个随机且高强度的密码。它设计出的安全密码可以被人们更容易地记住。在大多数的类 Unix 系统中都可以获取到它。
|
||||
|
||||
在基于 DEB 的系统中安装 pwgen 请运行:
|
||||
|
||||
```
|
||||
sudo apt-get install pwgen
|
||||
```
|
||||
|
||||
在基于 RPM 的系统中,运行:
|
||||
|
||||
```
|
||||
sudo yum install pwgen
|
||||
```
|
||||
|
||||
在基于 Arch 的系统中,则运行:
|
||||
|
||||
```
|
||||
sudo pacman -S pwgen
|
||||
```
|
||||
|
||||
一旦 pwgen 安装完成后,便可以使用下面的命令来生成 1 个长度为 14 个字符的随机高强度密码:
|
||||
|
||||
```
|
||||
pwgen 14 1
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
Choo4aicozai3a
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_004](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_004.png)
|
||||
][5]
|
||||
|
||||
上面的命令将只生成 1 个长度为 14 个字符的密码,如果要生成 2 个长度为 14 个字符的不同密码,则可以运行:
|
||||
|
||||
```
|
||||
pwgen 14 2
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
xee7seerez6Kau Aeshu0geveeji8
|
||||
```
|
||||
|
||||
如果要生成 100 个(尽管可能没有必要生成那么多)长度为 14 个字符的不同密码,则可以运行:
|
||||
|
||||
```
|
||||
pwgen 14
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
kaeNg3EiVei4ei Oo0iehiJaix5Ae aenuv2eree2Quo iaT7zahH1eN2Aj Bie2owaiFahsie
|
||||
gaan9zu5Xeh5ah ahGeeth8ea5ooh Ir0ueda5poogh5 uo0ohqu2ufaiX2 Mei0pee6Og3zae
|
||||
Oofeiceer8Aipu sheew3aeReidir Dee4Heib2eim2o eig6jar8giPhae Zahde9nae1Niew
|
||||
quatol5Oi3Bah2 quue4eebaiNgaa oGoahieSh5oL4m aequeeQue2piti laige5seePhugo
|
||||
iiGo9Uthee4ros WievaiQu2xech6 shaeve0maaK3ae ool8Pai2eighis EPheiRiet1ohci
|
||||
ZieX9outhoht8N Uh1UoPhah2Thee reaGhohZae5idi oiG4ooshiyi5in keePh1ohshei8y
|
||||
aim5Eevah2thah Xaej8tha5eisho IeGie1Anaalaev gaoY3ohthooh3x chaebeesahTh8e
|
||||
soh7oosieY5eiD ahmoh6Ihii6que Shoowoo5dahbah ieW0aiChubee7I Caet6aikai6aex
|
||||
coo1du2Re9aika Ohnei5Egoh7leV aiyie6Ahdeipho EiV0aeToeth1da iNgaesu4eeyu0S
|
||||
Eeb1suoV3naera railai2Vaina8u xu3OhVee1reeyu Og0eavae3oohoh audahneihaeK8a
|
||||
foo6iechi5Eira oXeixoh6EwuboD we1eiDahNgoh9s ko1Eeju1iedu1z aeP7achiisohr7
|
||||
phang5caeGei5j ait4Shuo5Aitai no4eis9Tohd8oh Quiet6oTaaQuei Dei2pu2NaefeCa
|
||||
Shiim9quiuy0ku yiewooph3thieL thu8Aphai1ieDa Phahnahch1Aam1 oocex7Yaith8oo
|
||||
eraiGaech5ahNg neixa3malif5Ya Eux7chah8ahXix eex1lahXae4Mei uGhahzonu6airu
|
||||
yah8uWahn3jeiW Yi4ye4Choongie io1Vo3aiQuahpi rie4Rucheet6ae Dohbieyaeleis5
|
||||
xi1Zaushohbei7 jeeb9EiSiech0u eewo0Oow7ielie aiquooZamah5th kouj7Jaivohx9o
|
||||
biyeeshesaDi9e she9ooj3zuw6Ah Eit7dei1Yei5la xohN0aeSheipaa Eeg9Phob6neema
|
||||
eengoneo4saeL4 aeghi4feephu6W eiWash2Vie1mee chieceish5ioPe ool4Hongo7ef1o
|
||||
jahBe1pui9thou eeV2choohoa4ee Ohmae0eef4ic8I Eet0deiyohdiew Ke9ue5thohzei3
|
||||
aiyoxeiva8Maih gieRahgh8anahM ve2ath9Eyi5iet quohg6ok3Ahgee theingaech5Nef
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_005](https://www.ostechnix.com/wp-content/plugins/lazy-load/images/1x1.trans.gif)
|
||||
][4]
|
||||
|
||||
如果要在密码中包含至少 1 个数字,则可以运行:
|
||||
|
||||
```
|
||||
pwgen 14 1 -n 1
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
xoiFush3ceiPhe
|
||||
```
|
||||
|
||||
另外,pwgen 命令还有一些很实用的选项:
|
||||
|
||||
```
|
||||
-c 或 --capitalize (在密码中包含至少一个大写字母)
|
||||
|
||||
-A 或 --no-capitalize (在密码中不包含大写字母)
|
||||
|
||||
-n 或 --numerals (在密码中包含至少一个数字)
|
||||
|
||||
-0 或 --no-numerals (在密码中不包含数字)
|
||||
|
||||
-y 或 --symbols (在密码中包含至少一个特殊字符)
|
||||
|
||||
-s 或 --secure (生成完全随机的密码)
|
||||
|
||||
-B 或 --ambiguous (在密码中不包含双关词语)
|
||||
|
||||
-h 或 --help (输出帮助信息)
|
||||
|
||||
-H 或 --sha1=path/to/file[#seed] (使用某个给定文件的 sha1 哈希值来作为随机数的生成种子)
|
||||
|
||||
-C (按列输出生成好的密码)
|
||||
|
||||
-1 (不按列输出生成好的密码)
|
||||
|
||||
-v 或 --no-vowels (不使用任何元音字母,以防止生成下流的词语)
|
||||
```
|
||||
|
||||
若想了解更多信息,请查阅其联机手册:
|
||||
|
||||
```
|
||||
man pwgen
|
||||
```
|
||||
|
||||
### 3. 在 Linux 中使用 GPG 来生成一个高强度密码
|
||||
|
||||
GPG (GnuPG or GNU Privacy Guard) 是一个免费的命令行程序,可以用于替代赛门铁克的 PGP 加密软件。在类 Unix 操作系统、Microsoft Windows 和 Android 中都可以获取到它。
|
||||
|
||||
要使用 PGP 生成 1 个长度为 14 个字符的高强度密码,请在终端中运行下面的命令:
|
||||
|
||||
```
|
||||
gpg --gen-random --armor 1 14
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
DkmsrUy3klzzbIbavx8=
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_006](https://www.ostechnix.com/wp-content/plugins/lazy-load/images/1x1.trans.gif)
|
||||
][3]
|
||||
|
||||
上面的命令将生成一个安全、随机、高强度且基于 base64 编码的密码。
|
||||
|
||||
### 4. 在 Linux 中使用 Perl 来生成一个高强度密码
|
||||
|
||||
Perl 在大多数 Linux 发行版本的默认软件仓库中都可以获取到,你可以使用相应的包管理器来安装它。
|
||||
|
||||
例如在基于 DEB 的系统中,可以运行下面的命令来安装 Perl:
|
||||
|
||||
```
|
||||
sudo apt-get install perl
|
||||
```
|
||||
|
||||
在基于 RPM 的系统中安装 Perl ,可以运行:
|
||||
|
||||
```
|
||||
sudo yum install perl
|
||||
```
|
||||
|
||||
在基于 Arch 的系统中,则运行:
|
||||
|
||||
```
|
||||
sudo pacman -S perl
|
||||
```
|
||||
|
||||
一旦 Perl 安装完成,使用下面的命令创建一个文件:
|
||||
|
||||
```
|
||||
vi password.pl
|
||||
```
|
||||
|
||||
接着添加下面的内容到这个文件中:
|
||||
|
||||
```
|
||||
#!/usr/bin/perl
|
||||
|
||||
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
|
||||
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;
|
||||
print "$randpassword\n"
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_001](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_001.png)
|
||||
][2]
|
||||
|
||||
保存并关闭该文件。
|
||||
|
||||
接着,切换到你刚才保存文件的地方,并运行下面的命令:
|
||||
|
||||
```
|
||||
perl password.pl
|
||||
```
|
||||
|
||||
使用你自己定义的文件名来替换上面命令中的 `password.pl` 。
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
3V4CJJnYd
|
||||
```
|
||||
|
||||
[
|
||||
![sksk_002](http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_002.png)
|
||||
][1]
|
||||
|
||||
注: 我无法找到这个脚本的原有作者,假如你知道作者的名字,请在下面的评论部分让我知晓,我将在这篇指南中添加上该作者的名字。
|
||||
|
||||
Please note that you must memorize or keep the passwords you have generated in a safe place in your computer. I recommend you to memorize the password and delete it from your system. It is much better in case your system is compromised by any hackers.
|
||||
请注意:对于你生成的密码,你必须记住它,或者将它保存到你电脑中一个安全的地方。我建议你记住密码并将它从你的系统中删除,因为这总比你的系统被黑客控制要好。
|
||||
|
||||
伙计们,今天就是这么多了。不久我将带来另一篇有意思的文章。在此之前,敬请关注 OSTechNix。
|
||||
|
||||
Happy Weekend!
|
||||
|
||||
Cheers!!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/4-easy-ways-to-generate-a-strong-password-in-linux/
|
||||
|
||||
作者:[ SK ][a]
|
||||
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_002.png
|
||||
[2]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_001.png
|
||||
[3]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_006.png
|
||||
[4]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_005.png
|
||||
[5]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_004.png
|
||||
[6]:http://www.ostechnix.com/wp-content/uploads/2016/11/sk@sk_003.png
|
||||
[7]:http://ostechnix.tradepub.com/free/w_ubun08/prgm.cgi?a=1
|
||||
[8]:https://www.ostechnix.com/force-users-use-strong-passwords-debian-ubuntu/
|
Loading…
Reference in New Issue
Block a user