mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
Merge branch 'master' of https://github.com/LCTT/TranslateProject into translating
This commit is contained in:
commit
e3278dcac2
117
published/20200228 Getting started with Linux firewalls.md
Normal file
117
published/20200228 Getting started with Linux firewalls.md
Normal file
@ -0,0 +1,117 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lxbwolf)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12130-1.html)
|
||||
[#]: subject: (Getting started with Linux firewalls)
|
||||
[#]: via: (https://opensource.com/article/20/2/firewall-cheat-sheet)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Linux 防火墙入门教程
|
||||
======
|
||||
|
||||
> 防火墙是你的计算机防止网络入侵的第一道屏障。为确保你的安全,请下载我们的备忘单。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202004/20/104205paugcytauqctqw6c.jpg)
|
||||
|
||||
合理的防火墙是你的计算机防止网络入侵的第一道屏障。你在家里上网,通常互联网服务提供会在路由中搭建一层防火墙。当你离开家时,那么你计算机上的那层防火墙就是仅有的一层,所以配置和控制好你 Linux 电脑上的防火墙很重要。如果你维护一台 Linux 服务器,那么知道怎么去管理你的防火墙同样重要,只要掌握了这些知识你才能保护你的服务器免于本地或远程非法流量的入侵。
|
||||
|
||||
### 安装防火墙
|
||||
|
||||
很多 Linux 发行版本已经自带了防火墙,通常是 `iptables`。它很强大并可以自定义,但配置起来有点复杂。幸运的是,有开发者写出了一些前端程序来帮助用户控制防火墙,而不需要写冗长的 iptables 规则。
|
||||
|
||||
在 Fedora、CentOS、Red Hat 和一些类似的发行版本上,默认安装的防火墙软件是 `firewalld`,通过 `firewall-cmd` 命令来配置和控制。在 Debian 和大部分其他发行版上,可以从你的软件仓库安装 firewalld。Ubuntu 自带的是<ruby>简单防火墙<rt>Uncomplicated Firewall</rt></ruby>(ufw),所以要使用 firewalld,你必须启用 `universe` 软件仓库:
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository universe
|
||||
$ sudo apt install firewalld
|
||||
```
|
||||
|
||||
你还需要停用 ufw:
|
||||
|
||||
```
|
||||
$ sudo systemctl disable ufw
|
||||
```
|
||||
|
||||
没有理由*不用* ufw。它是一个强大的防火墙前端。然而,本文重点讲 firewalld,因为大部分发行版都支持它而且它集成到了 systemd,systemd 是几乎所有发行版都自带的。
|
||||
|
||||
不管你的发行版是哪个,都要先激活防火墙才能让它生效,而且需要在启动时加载:
|
||||
|
||||
```
|
||||
$ sudo systemctl enable --now firewalld
|
||||
```
|
||||
|
||||
### 理解防火墙的域
|
||||
|
||||
Firewalld 旨在让防火墙的配置工作尽可能简单。它通过建立<ruby>域<rt>zone</rt></ruby>来实现这个目标。一个域是一组的合理、通用的规则,这些规则适配大部分用户的日常需求。默认情况下有九个域。
|
||||
|
||||
* `trusted`:接受所有的连接。这是最不偏执的防火墙设置,只能用在一个完全信任的环境中,如测试实验室或网络中相互都认识的家庭网络中。
|
||||
* `home`、`work`、`internal`:在这三个域中,接受大部分进来的连接。它们各自排除了预期不活跃的端口进来的流量。这三个都适合用于家庭环境中,因为在家庭环境中不会出现端口不确定的网络流量,在家庭网络中你一般可以信任其他的用户。
|
||||
* `public`:用于公共区域内。这是个偏执的设置,当你不信任网络中的其他计算机时使用。只能接收选定的常见和最安全的进入连接。
|
||||
* `dmz`:DMZ 表示隔离区。这个域多用于可公开访问的、位于机构的外部网络、对内网访问受限的计算机。对于个人计算机,它没什么用,但是对某类服务器来说它是个很重要的选项。
|
||||
* `external`:用于外部网络,会开启伪装(你的私有网络的地址被映射到一个外网 IP 地址,并隐藏起来)。跟 DMZ 类似,仅接受经过选择的传入连接,包括 SSH。
|
||||
* `block`:仅接收在本系统中初始化的网络连接。接收到的任何网络连接都会被 `icmp-host-prohibited` 信息拒绝。这个一个极度偏执的设置,对于某类服务器或处于不信任或不安全的环境中的个人计算机来说很重要。
|
||||
* `drop`:接收的所有网络包都被丢弃,没有任何回复。仅能有发送出去的网络连接。比这个设置更极端的办法,唯有关闭 WiFi 和拔掉网线。
|
||||
|
||||
你可以查看你发行版本的所有域,或通过配置文件 `/usr/lib/firewalld/zones` 来查看管理员设置。举个例子:下面是 Fefora 31 自带的 `FedoraWorkstation` 域:
|
||||
|
||||
```
|
||||
$ cat /usr/lib/firewalld/zones/FedoraWorkstation.xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<zone>
|
||||
<short>Fedora Workstation</short>
|
||||
<description>Unsolicited incoming network packets are rejected from port 1 to 1024, except for select network services. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
|
||||
<service name="dhcpv6-client"/>
|
||||
<service name="ssh"/>
|
||||
<service name="samba-client"/>
|
||||
<port protocol="udp" port="1025-65535"/>
|
||||
<port protocol="tcp" port="1025-65535"/>
|
||||
</zone>
|
||||
```
|
||||
|
||||
### 获取当前的域
|
||||
|
||||
任何时候你都可以通过 `--get-active-zones` 选项来查看你处于哪个域:
|
||||
|
||||
```
|
||||
$ sudo firewall-cmd --get-active-zones
|
||||
```
|
||||
|
||||
输出结果中,会有当前活跃的域的名字和分配给它的网络接口。笔记本电脑上,在默认域中通常意味着你有个 WiFi 卡:
|
||||
|
||||
```
|
||||
FedoraWorkstation
|
||||
interfaces: wlp61s0
|
||||
```
|
||||
|
||||
### 修改你当前的域
|
||||
|
||||
要更改你的域,请将网络接口重新分配到不同的域。例如,把例子中的 `wlp61s0` 卡修改为 public 域:
|
||||
|
||||
```
|
||||
$ sudo firewall-cmd --change-interface=wlp61s0 --zone=public
|
||||
```
|
||||
|
||||
你可以在任何时候、任何理由改变一个接口的活动域 —— 无论你是要去咖啡馆,觉得需要增加笔记本的安全策略,还是要去上班,需要打开一些端口进入内网,或者其他原因。在你凭记忆学会 `firewall-cmd` 命令之前,你只要记住了关键词 `change` 和 `zone`,就可以慢慢掌握,因为按下 `Tab` 时,它的选项会自动补全。
|
||||
|
||||
### 更多信息
|
||||
|
||||
你可以用你的防火墙干更多的事,比如自定义已存在的域,设置默认域,等等。你对防火墙越了解,你在网上的活动就越安全,所以我们创建了一个[备忘单][2]便于速查和参考。
|
||||
|
||||
- 下载你的 [防火墙备忘单][2]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/2/firewall-cheat-sheet
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[lxbwolf](https://github.com/lxbwolf)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_cheat_sheet.png?itok=lYkNKieP (Cheat Sheet cover image)
|
||||
[2]: https://opensource.com/downloads/firewall-cmd-cheat-sheet
|
@ -1,47 +1,46 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12131-1.html)
|
||||
[#]: subject: (How I'm using AI to translate 'wash your hands' in 500 languages)
|
||||
[#]: via: (https://opensource.com/article/20/4/ai-translation)
|
||||
[#]: author: (Daniel Whitenack https://opensource.com/users/datadan)
|
||||
|
||||
我是如何用 AI 把 “请洗手”翻译成 500 种语言的?
|
||||
我是如何用 AI 把“请洗手”翻译成 500 种语言的?
|
||||
======
|
||||
|
||||
> 通过使用人类和机器生成的翻译,可以将关键的健康短语翻译成世界各地的当地语言。
|
||||
|
||||
![Two diverse hands holding a globe][1]
|
||||
![](https://img.linux.net.cn/data/attachment/album/202004/20/184427f1a2t5z61m5xxo1t.jpg)
|
||||
|
||||
你可能不知道,目前世界上有 [7117 种语言][2],不是方言,而是在用的语言! 然而,世界上大部分的数字媒体只采用几十种语言,而像谷歌翻译这样的翻译平台只支持 100 种左右的语言。这样的现实意味着,由于缺乏及时获取信息的机会,全世界有数十亿人被边缘化。当前的冠状病毒(COVID-19)大流行已经让人痛苦地意识到了这一点,凸显了将健康相关的短语(如“<ruby>请洗手<rt>wash your hands</rt></ruby>”或“保持距离”等)即时、快速翻译成小众语言的必要性。
|
||||
你可能不知道,目前世界上有 [7117 种语言][2]在使用,不是方言,而是在用的语言! 然而,世界上许多数字媒体只能使用几十种语言,而像谷歌翻译这样的翻译平台只支持 100 种左右的语言。这样的现实意味着,由于缺乏及时获取信息的机会,全世界有数十亿人被边缘化。当前的冠状病毒(COVID-19)大流行已经让人痛苦地意识到了这一点,凸显了将健康相关的短语(如“<ruby>请洗手<rt>wash your hands</rt></ruby>”或“保持距离”等)即时、快速翻译成小众语言的必要性。
|
||||
|
||||
为此,我应用了最先进的AI技术,用 544 种语言构建出了与“请洗手”相近的短语并进行了统计(我的 GPU 还在运行)。<ruby>多语言无监督和监督嵌入<rt>Multilingual Unsupervised and Supervised Embeddings</rt></ruby>(MUSE)方法被用来训练这 544 种语言和英语之间的跨语言单词嵌入。然后,这些嵌入方法可以从现有文档中提取出与目标短语相似的短语。
|
||||
为此,我应用了最先进的 AI 技术,用 544 种语言构建出了与“请洗手”相近的短语并进行了统计(我的 GPU 还在运行)。<ruby>多语言无监督和受监督嵌入<rt>Multilingual Unsupervised and Supervised Embeddings</rt></ruby>(MUSE)方法被用来训练这 544 种语言和英语之间的跨语言单词嵌入。然后,这些嵌入方法可以从现有文档中提取出与目标短语相似的短语。
|
||||
|
||||
我与 SIL 国际公司的同事们合作完成了这项工作,他们收集了该短语的更多的人工翻译结果。这些人工翻译结果和我的一些机器翻译结果的组合可以在[这个民族语指南页面][3]上搜索到(机器生成的短语用一个小的机器人图标表示),更多的翻译将在生成/收集到的时候加入。
|
||||
|
||||
### 利用现有的语料库
|
||||
|
||||
SIL 国际公司已经完成了 2000 多种语言的语言工作,目前管理着 1600 多个语言项目。因此,当我解决这个特殊的问题时,我知道我们很可能已经多次将“请洗手”和/或类似的短语翻译成了数百种语言,而这一猜测得到了回报。我很快就从我们的档案库中收集到了超过 900 种语言的文件(主要是完成的贝壳书模板、教材和圣经)。这些文件中的每一份文件都有一个英文的对应语,其中必然包括“请洗手”和/或类似“请洗脸”这样的短语。此外,这些文件的质量都很高,并与当地语言社区合作进行了翻译和检查。
|
||||
SIL 国际公司已经完成了 2000 多种语言的语言工作,目前管理着 1600 多个语言项目。因此,当我解决这个特殊的问题时,我知道我们很可能已经多次将“请洗手”和/或类似的短语翻译成了数百种语言,而这一猜测得到了回报。我很快就从我们的档案库中收集到了超过 900 种语言的文档(主要是完成的贝壳书模板、教材和圣经)。这些文档中的每一份都有一个英文的对应版本,其中必然包括“请洗手”和/或类似“请洗脸”这样的短语。此外,这些文档的质量都很高,并与当地语言社区合作进行了翻译和检查。
|
||||
|
||||
这是相当多语言的数据集。然而,有两个问题需要克服。首先,这个数据包含了大多数语言的数千种样本,这与训练机器翻译模型所使用的数百万个样本形成了鲜明对比。其次,即使文档中包含目标语言中的“请洗手”这个短语,我们也不知道这个短语在周围文本中的确切位置。
|
||||
|
||||
我们当然可以利用[低资源语言的机器翻译][4]中的一些最新技巧,但要在每一对语言中快速调整翻译模型的自动化方法,还需要一些时间。此外,我们所针对的许多语言都没有现成的可以与之比较评估指标的基线,例如[BLEU 评分][5]。考虑到对冠状病毒大流行的迫切担忧,我们希望比这更快一点(尽管我们计划在将来再来解决这个问题)。
|
||||
我们当然可以利用[低资源语言的机器翻译][4]中的一些最新技巧,但是需要花费一些时间来调整自动化方法,以快速适应每种语言对中的翻译模型。此外,我们所针对的许多语言都没有现成的的基线,可以用来比较评估指标(例如 [BLEU 评分][5])。考虑到对冠状病毒大流行的迫切担忧,我们希望比这更快一点(尽管我们计划在将来再来解决这个问题)。
|
||||
|
||||
我选择通过在现有的文档中寻找短语本身或短语的组件(如“请洗”或“你的手”)来尝试构建“请洗手”这个短语。为了找到这些成分,我使用 Facebook Research 的 [多语言无监督和监督嵌入(MUSE)][6]对每个 {英语、目标语言} 对进行<ruby>跨语言<rt>cross-lingual</rt></ruby>嵌入训练。MUSE 以<ruby>单语言<rt>monolingual</rt></ruby>的单词嵌入作为输入(我使用 [fasttext][7] 来生成这些词),并使用对抗性方法学习从英语到目标嵌入空间的映射。这个过程的输出是<ruby>跨语言<rt>cross-lingual</rt></ruby>的单词嵌入。
|
||||
我选择通过在现有的文档中寻找短语本身或短语的组件(如“请洗”或“你的手”)来尝试构建“请洗手”这个短语。为了找到这些成分,我使用 Facebook Research 的[多语言无监督和受监督嵌入(MUSE)][6]对每个 {英语、目标语言} 对进行了<ruby>跨语言<rt>cross-lingual</rt></ruby>嵌入训练。MUSE 以<ruby>单语言<rt>monolingual</rt></ruby>的单词嵌入作为输入(我使用 [fasttext][7] 来生成这些词),并使用对抗性方法学习了从英语到目标嵌入空间的映射。这个过程的输出是<ruby>跨语言<rt>cross-lingual</rt></ruby>的单词嵌入。
|
||||
|
||||
![Using fasttext along with MUSE to perform cross-language embedding][8]
|
||||
|
||||
一旦产生了跨语言嵌入,我们就可以开始在目标语言文档中寻找短语成分。结果发现,整个文档中清楚地使用了“请洗脸”这个短语以及单独的“手”、“请洗”等词。对于每一种语言,我都通过 n-grams 搜索我预期该短语会出现的地方(根据其在英语平行语中的用法)。使用跨语言嵌入法对 n-grams 进行了矢量化,并使用各种距离指标与英语短语的矢量化版本进行了比较。在嵌入空间中,与英文短语“最接近”的 n-grams 被确定为目标语言匹配。
|
||||
一旦产生了跨语言嵌入,我们就可以开始在目标语言文档中寻找短语组件。结果发现,整个文档中清楚地使用了“请洗脸”这个短语以及单独的“手”、“请洗”等词。对于每一种语言,我都通过 n-gram 搜索我预期该短语会出现的地方(根据其在英语的对应版本中的用法)。使用跨语言嵌入法对 n-gram 进行了矢量化处理,并使用各种距离指标与英语短语的矢量化版本进行了比较。在嵌入空间中,与英文短语“最接近”的 n-gram 被确定为与目标语言匹配。
|
||||
|
||||
最后,将与英语对应的成分短语进行组合,生成目标语言中的“请洗手”短语。这种组合方式再次利用跨语言嵌入,确保组件短语的组合方式合适。例如,如果我们在目标语言中匹配“请洗脚”这个短语,就必须将“脚”对应的 n-gram 替换成“手”对应的 n-gram。下面是<ruby>伯利兹·克里奥尔<rt>Belize Kriol</rt></ruby>英语的一个例子:
|
||||
最后,将与英语对应的成分短语进行组合,生成目标语言中的“请洗手”短语。这种组合方式再次利用了跨语言嵌入,以确保以合适方式组合组件。例如,如果我们在目标语言中匹配“请洗脚”这个短语,就必须将“脚”对应的 n-gram 替换成“手”对应的 n-gram。下面是<ruby>伯利兹·克里奥尔<rt>Belize Kriol</rt></ruby>英语的一个例子:
|
||||
|
||||
![][9]
|
||||
|
||||
当然,在这个匹配过程中,有一些假设,这个过程完全有可能不能产生语法上正确的预测。例如,我假设在大多数语言中,“手”的单词和“脚”的单词都是一个字元长的(字元由空格和标点符号隔开)。当然,情况肯定不一定是这样。这可能会造成类似于“和洗的和手你”或类似的不好的词条。希望我们可以克服其中的一些局限性,并在未来扩展这个系统,但是,现在,我们选择用图形来强化这个想法。
|
||||
|
||||
我们将世界卫生组织的洗手说明改编成了一个 PNG 图片模板。然后,我们把我们翻译和生成的短语,用 Bash 和 Go 脚本的组合将其渲染到洗手图像中。这样,在文字和图像中都强调了正确洗手的理念(只是为了防止我们生成的翻译有问题)。
|
||||
当然,在这个匹配过程中,会做一些假设,这个过程完全有可能不能产生语法上正确的预测。例如,我假设在大多数语言中,“手”的单词和“脚”的单词都是一个<ruby>字元<rt>token</rt></ruby>长的(字元由空格和标点符号隔开)。当然并非总是如此。这可能会造成类似于“和洗和手你”或类似的瑕疵词条。希望我们可以克服其中的一些局限性,并在未来扩展这个系统,但是,现在,我们选择用图形来强化这个想法。
|
||||
|
||||
我们将世界卫生组织的洗手说明改编成了一个 PNG 图片模板。然后,我们把我们翻译和生成的短语,用 Bash 和 Go 脚本的组合将其渲染到洗手图像中。这样,在文字和图像中都强调了正确洗手的理念(以防万一我们生成的翻译很尴尬)。
|
||||
|
||||
![][10]
|
||||
|
||||
@ -91,11 +90,11 @@ SIL 国际公司已经完成了 2000 多种语言的语言工作,目前管理
|
||||
- 我们的系统:yaakuuvaitana nnikiiyauvaa fini
|
||||
- 谷歌翻译:不支持
|
||||
|
||||
构建的短语类似于参考翻译,或者似乎是“请洗手”的另一种说法。例如,在保加利亚语中,我预测为“умий ръцете”,而谷歌翻译预测为“Измий си ръцете”。然而,如果我用谷歌翻译回译我的预测,我还是会得到“请洗手”。有一些不确定的地方,我无法与参考译文(例如,所罗门群岛的 Pijin [pis])或人类注释的跨度进行比较,但我仍然可以验证“洗”(wasim)和“手”(han)分别用在其他必定是谈论洗或手的参考文件中。大约有 15% 的译文可以用这个方法验证,我希望在收集参考文献字典的过程中,能验证更多的译文。
|
||||
构造的短语类似于参考翻译,或者似乎是“请洗手”的另一种说法。例如,在保加利亚语中,我预测为“умий ръцете”,而谷歌翻译预测为“Измий си ръцете”。 然而,如果我用谷歌翻译回译我的预测,我还是会得到“请洗手”。有一些不确定的地方,我无法与参考译文(例如,所罗门群岛的 Pijin [pis])或人类注释的跨度进行比较,但我仍然可以验证“洗”(wasim)和“手”(han)分别用在其他必定是谈论洗或手的参考文件中。 大约有 15% 的译文可以用这个方法验证,我希望在收集参考文献字典的过程中能进行更多的验证。
|
||||
|
||||
请注意,我最多使用了每种语言中大约 7000 个句子来得到上述译文,即使是意大利语这样的高资源语言也是如此。我也没有依赖语言对之间的对齐句子。尽管在这种数据非常稀缺、无监督的情况下,但对于两个系统都支持的语言,我仍然能够获得类似于谷歌翻译的短语。这证明了这种“混合”方法(无监督的单词嵌入+基于规则的匹配)在将短语翻译成数据非常少的语言中的潜在用途。
|
||||
请注意,我最多使用了每种语言中大约 7000 个句子来得到上述译文,即使是意大利语这样的高资源语言也是如此。我也不依赖语言对之间的对齐句子。尽管存在这种数据非常稀缺、无监督的情况,但对于两个系统都支持的语言,我仍然能够获得类似于谷歌翻译的短语。这证明了这种“混合”方法(无监督的单词嵌入+基于规则的匹配)在将短语翻译成数据非常少的语言中的潜在用途。
|
||||
|
||||
注意:我绝对不是说这是解决冠状病毒和其他健康相关的信息传播问题的解决方案。这里仍有很多东西需要探索和正式评估,我们正在为此努力。在很多情况下,这种方法无法帮助构建数百种语言的重要信息资料。但是,我认为,我们都应该尝试着为当前危机的相关问题制定创造性的解决方案。也许这只是一个非常大的拼图中的一块。
|
||||
注意:我绝对不是说这是解决冠状病毒和其他健康相关的信息传播问题的解决方案。这里仍有很多东西需要探索和正式评估,我们正在为此努力。在很多情况下,这种方法无法帮助构建数百种语言的重要信息资料。但是,我认为,我们所有人都应该尝试着为当前危机的相关问题制定创造性的解决方案。也许这只是一个非常大的拼图中的一块。
|
||||
|
||||
你可以在[这个民族语言指南][3]上查看经过验证的译文加上人工翻译的完整列表。此外,我们即将以论文的形式对这一系统进行更深入的描述和分析。我们欢迎公众对翻译进行反馈,以帮助系统进行微调,最重要的是,确保将健康信息传递给世界各地的边缘化语言社区。
|
||||
|
||||
@ -116,7 +115,7 @@ via: https://opensource.com/article/20/4/ai-translation
|
||||
作者:[Daniel Whitenack][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,343 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Zioyi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (12 Linux Commands to Have Some Fun in the Terminal)
|
||||
[#]: via: (https://itsfoss.com/funny-linux-commands/)
|
||||
[#]: author: (Community https://itsfoss.com/author/itsfoss/)
|
||||
|
||||
12 Linux Commands to Have Some Fun in the Terminal
|
||||
======
|
||||
|
||||
_**So, you think Linux terminal is all work and no fun? These funny Linux commands will prove you wrong.**_
|
||||
|
||||
The Linux terminal is the place to get serious work done. We have plenty of useful [linux command tips and tricks][1] to help you with that.
|
||||
|
||||
But, did you know that you can have a lot of fun using the terminal? Well, if you did not, then you are not alone. Most Linux users see the terminal as an interface that is designed and built for system management and development tasks.
|
||||
|
||||
However, you will be surprised to know that there are tons of [terminal based games][2] and [ASCII games][3] that you can play in the terminal.
|
||||
|
||||
And, in this article, I’m going to explore some interesting, some funny and some ridiculous commands that you can type into the terminal on Linux and have fun!
|
||||
|
||||
### Have some fun in Linux terminal with these commands
|
||||
|
||||
![][4]
|
||||
|
||||
You’ll find a lot of these commands ridiculous or useless but some of them could actually be put to some good use.
|
||||
|
||||
I have added installation instructions for Ubuntu/Debian. If you are using Ubuntu-based distribution, please make sure to [enable universe repository][5] as most of these commands are not in the main repository.
|
||||
|
||||
If you are using Arch, Fedora, SUSE, Solus or any other non-Ubuntu distributions, please use your distribution’s package manager to install these funny Linux commands.
|
||||
|
||||
#### 1\. Run a train in the terminal
|
||||
|
||||
Let’s take a ride in the locomotive and begin our auspicious journey. And I mean it literally!
|
||||
|
||||
The sl command allows you to run a train in your terminal.
|
||||
|
||||
![][6]
|
||||
|
||||
Here’s how to install the command:
|
||||
|
||||
```
|
||||
sudo apt install sl
|
||||
```
|
||||
|
||||
Once done, you can simply type in the following in the terminal to get started:
|
||||
|
||||
```
|
||||
sl
|
||||
```
|
||||
|
||||
Impressive, isn’t it? But, hold on. We are not done yet! Apparently, you can fly your locomotive. Just add the option -F, Mr. Potter:
|
||||
|
||||
```
|
||||
sl -F
|
||||
```
|
||||
|
||||
****This should make the locomotive get wings to fly off from the terminal window!
|
||||
|
||||
#### 2\. Add the Matrix effect to your Linux terminal
|
||||
|
||||
Remember the iconic sci-fi movie [The Matrix][7]? The green text falling down on the terminal became an identity of Matrix.
|
||||
|
||||
You can have this Matrix digital rain on your Linux box as well! You just need to install **cmatrix** and type it in the terminal.
|
||||
|
||||
![][8]
|
||||
|
||||
Installing cmatrix on Debian/Ubuntu Linux:
|
||||
|
||||
```
|
||||
sudo apt install cmatrix
|
||||
```
|
||||
|
||||
Now, all you have to do is type the following to get the matrix screen on terminal:
|
||||
|
||||
```
|
||||
cmatrix
|
||||
```
|
||||
|
||||
Press Ctrl+C to stop it, Mr. Anderson.
|
||||
|
||||
**Recommended Read:**
|
||||
|
||||
![][9]
|
||||
|
||||
#### [Watch Star Wars In Linux Terminal via Telnet][10]
|
||||
|
||||
Watch Star Wars in ASCII art Linux terminal.
|
||||
|
||||
#### 3\. Let there be fire
|
||||
|
||||
Keep your fire extinguisher handy because now you are going to start a fire in your terminal!
|
||||
|
||||
![][11]
|
||||
|
||||
To get it installed, here’s what you have to type:
|
||||
|
||||
```
|
||||
sudo apt install libaa-bin
|
||||
```
|
||||
|
||||
Once done start a fire in your terminal by entering:
|
||||
|
||||
```
|
||||
aafire
|
||||
```
|
||||
|
||||
Press Ctrl+C to stop it.
|
||||
|
||||
#### 4\. Fortune ~~Cookie~~ Command
|
||||
|
||||
Want to know your fortune but there are no fortune cookies around you?
|
||||
|
||||
Not to worry, you just need to type “fortune” on your terminal and press enter. The terminal will display a random sentence just like you usually get in fortune cookies.
|
||||
|
||||
![][12]
|
||||
|
||||
Install it with:
|
||||
|
||||
```
|
||||
sudo apt install fortune
|
||||
```
|
||||
|
||||
Once done, simply type in the command below to know your fortune:
|
||||
|
||||
```
|
||||
fortune
|
||||
```
|
||||
|
||||
Now this is one of the commands here that you could actually use. You can use it as message of the day so that in a multi-user environment, all the users will see a random fortune cookie when they login.
|
||||
|
||||
You may also add it to your bashrc file so that it shows you a random message as soon as you log in to the terminal.
|
||||
|
||||
#### 5\. Pet lover? This is for you
|
||||
|
||||
Oneko is a little fun command that will change your regular cursor into a mouse and creates a curious little cat who will chase your cursor once you move it. It’s not limited to just the terminal. You can keep on working while the cat chases the cursor.
|
||||
|
||||
Now, that’s something fun to do specially if you have kids at home.
|
||||
|
||||
![][13]
|
||||
|
||||
Install Oneko with this command:
|
||||
|
||||
```
|
||||
sudo apt install oneko
|
||||
```
|
||||
|
||||
Run it with this command:
|
||||
|
||||
```
|
||||
oneko
|
||||
```
|
||||
|
||||
In case you want a dog instead of a cat, type:
|
||||
|
||||
```
|
||||
oneko -dog
|
||||
```
|
||||
|
||||
There are a few more types of cats available. You can get that information by using oneko –help. To stop it, use Ctrl+C.
|
||||
|
||||
#### 6\. Little brother is watching you
|
||||
|
||||
Xeyes is a tiny gui program that let the user draws a pair of ever watching eyes! It will follow your mouse cursor constantly. Run the command and see it yourself!
|
||||
|
||||
![][14]
|
||||
|
||||
You can install it using this command:
|
||||
|
||||
```
|
||||
sudo apt install xeyes
|
||||
```
|
||||
|
||||
And then use it with this:
|
||||
|
||||
```
|
||||
xeyes
|
||||
```
|
||||
|
||||
Press Ctrl+C to stop it.
|
||||
|
||||
#### Let the terminal speak for you
|
||||
|
||||
To try out this command, make sure you have turned on your speakers. [eSpeak][15] is a fun command that gives your terminal a voice. Yes, you heard that right.
|
||||
|
||||
Install the package first:
|
||||
|
||||
```
|
||||
sudo apt install espeak
|
||||
```
|
||||
|
||||
Next, you need to simply type in the command along with a text that you want to listen as audio:
|
||||
|
||||
```
|
||||
espeak "Type what your computer says"
|
||||
```
|
||||
|
||||
Whatever you place in the double quotes, your computer is obligated to say! It’s like [echo command in Linux][16]. But instead of printing, it speaks.
|
||||
|
||||
#### Toilet (but it has nothing to do with a washroom)
|
||||
|
||||
This sounds weird, yes. But, it’s just a command that transforms a text into large ASCII characters.
|
||||
|
||||
![][17]
|
||||
|
||||
Install toilet with this command:
|
||||
|
||||
```
|
||||
sudo apt install toilet
|
||||
```
|
||||
|
||||
Once done, you just need to type in:
|
||||
|
||||
```
|
||||
toilet sample text you want
|
||||
```
|
||||
|
||||
I don’t know why this little program is called toilet.
|
||||
|
||||
#### What does the ~~fox~~ cow say?
|
||||
|
||||
Cowsay is a command that displays a cow using ASCII characters in the terminal. And by using this command you can instruct the cow to say anything you want.
|
||||
|
||||
Not to be confused with any audio – it will just display a text (like you usually see in a comic book).
|
||||
|
||||
![Cowsay Cowthink][18]
|
||||
|
||||
Install ****cowsay:
|
||||
|
||||
```
|
||||
sudo apt install cowsay
|
||||
```
|
||||
|
||||
Once you have it installed, you just need to type in:
|
||||
|
||||
```
|
||||
cowsay "your text"
|
||||
```
|
||||
|
||||
Whatever you place in the double quotes, your cow is obligated to say! I have seen a few sysadmins using it to display the message of the day. Maybe you can do the same. You may even combine it with fortune command.
|
||||
|
||||
#### Banner Command
|
||||
|
||||
The banner command works just like the toilet command but it is limited to print only 10 characters at most.
|
||||
|
||||
![][19]
|
||||
|
||||
You can install banner command like this:
|
||||
|
||||
```
|
||||
sudo apt install sysvbanner
|
||||
```
|
||||
|
||||
Then use it in the following way:
|
||||
|
||||
```
|
||||
banner "Welcome"
|
||||
```
|
||||
|
||||
Replace content in the double quotes and you shall have your desired text displayed.
|
||||
|
||||
#### Yes command
|
||||
|
||||
![][20]
|
||||
|
||||
The “yes” command helps you to loop an automated response until you terminate the command. This command will print the exact same thing indefinitely. If you want to produce huge amounts of junk text fast, then this command will work like a charm.
|
||||
|
||||
You may also use it to provide a yes to a command (if it prompts for it). For example, the apt upgrade command asks for your confirmation, you can use it like this:
|
||||
|
||||
```
|
||||
yes | sudo apt upgrade
|
||||
```
|
||||
|
||||
You don’t need to install any package for it. Yes command is already available.
|
||||
|
||||
Terminate the yes command loop, simply press **CTRL + C**.
|
||||
|
||||
#### Get a new identity, well, sort of
|
||||
|
||||
Want to generate a random fake identity? I give you the command “rig”. Once you place this in the terminal, it will generate a fake identity.
|
||||
|
||||
![][21]
|
||||
|
||||
Install rig with this command:
|
||||
|
||||
```
|
||||
sudo apt install rig
|
||||
```
|
||||
|
||||
Then simply type this:
|
||||
|
||||
```
|
||||
rig
|
||||
```
|
||||
|
||||
It may be used in scripts or web-apps that displays random information but I haven’t done anything of that sort on my own.
|
||||
|
||||
**Wrapping Up**
|
||||
|
||||
I hope you liked this list of fun Linux commands. Which command do you like the most here? Do you know some other such amusing commands? Do share it with us in the comment section.
|
||||
|
||||
![][22]
|
||||
|
||||
### Srimanta Koley
|
||||
|
||||
A passionate writer, a distrohopper and an open source enthusiast, Srimanta is extremely fond of everything related to technology. He loves to read books and has an unhealthy addiction to the 90s!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/funny-linux-commands/
|
||||
|
||||
作者:[Community][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/itsfoss/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/linux-command-tricks/
|
||||
[2]: https://itsfoss.com/best-command-line-games-linux/
|
||||
[3]: https://itsfoss.com/best-ascii-games/
|
||||
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fun-linux-commands.png?ssl=1
|
||||
[5]: https://itsfoss.com/ubuntu-repositories/
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/sl-command.jpg?ssl=1
|
||||
[7]: https://en.wikipedia.org/wiki/The_Matrix
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/matrix-screen-command.png?ssl=1
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2015/12/Star-Wars-Linux-Terminal-2.png?fit=732%2C462&ssl=1
|
||||
[10]: https://itsfoss.com/star-wars-linux/
|
||||
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fire-command.png?ssl=1
|
||||
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fortune-command.jpg?ssl=1
|
||||
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/oneko-command.jpg?ssl=1
|
||||
[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/xeyes-command.jpg?ssl=1
|
||||
[15]: https://itsfoss.com/espeak-text-speech-linux/
|
||||
[16]: https://linuxhandbook.com/echo-command/
|
||||
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/toilet-command.jpg?ssl=1
|
||||
[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cowsay-cowthink.jpg?ssl=1
|
||||
[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/banner-command.jpg?ssl=1
|
||||
[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/yes-yourtext.jpg?ssl=1
|
||||
[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/rig-command.jpg?ssl=1
|
||||
[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/srimanta.jpg?ssl=1
|
@ -0,0 +1,116 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (A stress-free guide to keeping WordPress sites updated)
|
||||
[#]: via: (https://opensource.com/article/20/4/updating-wordpress)
|
||||
[#]: author: (Sara Kelly https://opensource.com/users/sarapk)
|
||||
|
||||
A stress-free guide to keeping WordPress sites updated
|
||||
======
|
||||
This practical guide to a necessary task will show you how to maximize
|
||||
site performance and avoid bugs and other issues with regular updates.
|
||||
![Working from home at a laptop][1]
|
||||
|
||||
We all know how important it is to keep WordPress sites updated. New updates provide the latest bug and security fixes against any nasties lurking on the web. But, more critically, an outdated site can also lead to poor performance, such as slow loading speed or an outdated look and feel.
|
||||
|
||||
Unfortunately, keeping your WordPress site up-to-date is not as easy as clicking a button. There are several components to consider, from theme to plugins to PHP. Even worse, updating too quickly can wreak another kind of havoc. Have you ever experienced the dreaded, "There has been a critical error on your website" warning after an innocent little update? I know I have, many times!
|
||||
|
||||
Here is a practical guide on what to look out for, as well as when and what to update, to ensure your WordPress site works well.
|
||||
|
||||
### Updating WordPress
|
||||
|
||||
Let's start with the basics. Check your WordPress version is up-to-date by visiting Dashboard > Updates.
|
||||
|
||||
![WordPress update screen][2]
|
||||
|
||||
### Choosing a WordPress theme
|
||||
|
||||
Before we deep dive into updating themes, I'd like to take a few steps back. Choose an up-to-date theme from the get-go and do your homework before installing it! There is nothing worse than pouring your heart and soul into customizing a new theme, only to discover it is buggy.
|
||||
|
||||
Questions to ask when choosing a theme include:
|
||||
|
||||
* When was it first created?
|
||||
* What is the current version available?
|
||||
* Does the theme provider still maintain an active demo site and helpdesk?
|
||||
* What do recent reviews say about the theme?
|
||||
|
||||
|
||||
|
||||
If the theme provider is no longer maintaining the theme, save yourself the trouble and move on. Also, don't assume that just because you paid for a theme, that is necessarily maintained. I recently fell into this trap when I purchased [Pinable][3]. I loved the Pinterest look and feel. However, soon after installation, I noticed the lack of customization within the theme settings, major compatibility issues arose with my plugins, and the customer service was nonexistent. I should have known better. The theme was created in 2013 and selling for a bargain.
|
||||
|
||||
If you already have a theme, then pay attention to how frequently updates become available. If there are never any updates, the theme provider may have closed up shop. It is only a matter of time before the impact of an outdated theme will cause problems.
|
||||
|
||||
A quick aside while we are on the topic—up-to-date themes also give access to the two new alignment options in the WordPress block editor, which enable wide-width and full-width images. These help your blog posts look more professional. While there are a number of [tutorials][4] on the web that show you how to manually update your functions, PHP file, and CSS to enable the new alignment blocks, the code does not always work on older themes (especially masonry themes).
|
||||
|
||||
![Wordpress theme][5]
|
||||
|
||||
### Updating themes
|
||||
|
||||
To check the current version of your theme, go to Appearance > Themes and click on the active theme to see the current version. If an upgrade is available, there will be an alert banner. Click on "update now" to initiate the update. You can also check for updates by going to Dashboard > Updates.
|
||||
|
||||
![Themify screenshot][6]
|
||||
|
||||
If you purchased a theme from a marketplace such as [Envato][7] or [Themify][8], check the theme documentation to learn what is required to initiate updates, as it will not show up automatically in the dashboard. In most cases, you will be required to download and install a specific plugin or manually upload new versions when they become available. In the latter case, you will need to delete or rename the old theme file via your cPanel before you can install the new one. A guide to installing themes via cPanel is available [here][9].
|
||||
|
||||
If you plan to customize your theme extensively and are worried about the impact of this when upgrading, consider creating a child theme first. A child theme lets you make changes without touching the original theme's code. You can then update your site without losing any customizations you've made. Read more about child themes [here][10].
|
||||
|
||||
As I said before, the source of most issues tends to be the theme. Learn what is required to keep your theme up to date, and do so regularly. If your theme provider is no longer creating updates, then find a new theme.
|
||||
|
||||
### Easy does it for plugins
|
||||
|
||||
If you manage multiple plugins, then you will be used to the frequent dashboard reminders to update! Before we get onto that, though, let's touch on some basics.
|
||||
|
||||
As a general rule, you don't want to have too many plugins. They slow down the speed of your site by creating more code that the browser has to load. Always delete any inactive plugins. I prefer to manage plugins on the Plugins tab. Here you can see all active and inactive plugins, the current version, and whether an update is available. To update the plugin, simply click "update."
|
||||
|
||||
![Plugin update page][11]
|
||||
|
||||
Nonetheless, I implore you to wait a week or two before installing new updates. Updating my plugins too quickly has caused me no end of grievances. To begin with, updates are prone to human error. Don't be the guinea pig that tests out the latest version. Sometimes, the newest version of a plugin is not compatible with an older version of WordPress or your theme. Check these are up-to-date first.
|
||||
|
||||
### Website down after updating plugins?
|
||||
|
||||
If your site has stopped working or performance has dropped noticeably after updating your plugins, then all is not lost. Forget about those newfangled plugins that promise to test speed and identify buggy plugins (the last thing you want is more plugins)! Disable all your plugins, then activate one at a time while you test the speed and performance of your site on a website such as [Pingdom][12]. This is a great exercise to perform periodically, even if your website has not crashed. Once you identify the plugin causing the problem, delete it.
|
||||
|
||||
In the event you cannot access WordPress because there is a critical error, then you will need to access your files via cPanel and delete all the plugin folders from there ([full instructions here][13]). Don't worry; doing this will not impact your website's content. You can then proceed to reinstall and activate the plugins one-by-one via WordPress.
|
||||
|
||||
Cache plugins tend to be the biggest culprit in my experience. Issues with cache plugins can be minimized by clearing the cache frequently. Do not install multiple cache plugins that perform the same function, as they will only serve to slow down your site. The only way to truly get around cache plugin issues is to either not use them, use a plugin recommended by your hosting provider, or become an expert on cache. [This blog][14] on common cache issues in WordPress is a good place to start.
|
||||
|
||||
### Back up before updating PHP
|
||||
|
||||
If you are concerned about your website speed and have spent enough time browsing Google for answers, then you likely have seen the advice, "You gotta update your PHP!" Please tread carefully with manual PHP updates, though! If you have a good hosting provider, you should never need to do this. Rather, select the option for automatic PHP version management with your host. Newer versions of PHP may not be stable or compatible with the version of WordPress you are running. Let your hosting provider be the one to determine when updates are ready.
|
||||
|
||||
However, if you are adamant that an old version of PHP is causing your website to be slow, take care to follow these steps before initiating an update. First, back up your site. Investing in a premium version of [Jetpack][15] is worth its weight in gold. Jetpack can perform real-time as well as daily backups, depending on your plan. Not to mention, their customer service and troubleshooting support are excellent. Secondly, inform your hosting provider that you plan to update the PHP and seek their advice first. If your host is unable to advise or wants to charge you for the privilege, you should probably think about changing hosts.
|
||||
|
||||
You can update PHP either via cPanel or via your hosting platform under Devs > PHP Manager. After that, you are on your own, as that is where my expertise on PHP ends.
|
||||
|
||||
If you have any other tips or pitfalls regarding updating WordPress, drop them in the comments box below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/updating-wordpress
|
||||
|
||||
作者:[Sara Kelly][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/sarapk
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/wfh_work_home_laptop_work.png?itok=VFwToeMy (Working from home at a laptop)
|
||||
[2]: https://opensource.com/sites/default/files/uploads/wp_update_1.png (Wordpress update screen)
|
||||
[3]: https://www.theme-junkie.com/themes/pinable/
|
||||
[4]: https://www.billerickson.net/full-and-wide-alignment-in-gutenberg/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/wp_theme_2.png (Wordpress theme)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/themify_3.png (Themify screenshot)
|
||||
[7]: https://elements.envato.com/
|
||||
[8]: https://themify.me/
|
||||
[9]: https://hostadvice.com/how-to/how-to-install-a-wordpress-theme-using-cpanel/
|
||||
[10]: https://developer.wordpress.org/themes/advanced-topics/child-themes/
|
||||
[11]: https://opensource.com/sites/default/files/uploads/plugins_4.png (Plugin update page)
|
||||
[12]: https://tools.pingdom.com/
|
||||
[13]: https://www.wpbeginner.com/plugins/how-to-deactivate-all-plugins-when-not-able-to-access-wp-admin/
|
||||
[14]: https://mhthemes.com/support/knb/solving-common-cache-issues-on-wordpress-websites/
|
||||
[15]: https://jetpack.com/upgrade/backup/?utm_source=google&utm_campaign=google_jetpack_search_brand_desktop_sg_en&utm_medium=paid_search&utm_term=%2Bwordpress%20%2Bjetpack%20%2Bbackup&creative=379260213317&campaignid=2061290863&utm_content=77066462603&matchtype=b&device=c&network=g&gclid=Cj0KCQjwu6fzBRC6ARIsAJUwa2RuPx5Dzr72eBEtZegsf11MmOBgLiwLX2HcEUXVaULIgv1MdZqGmeAaArmFEALw_wcB&gclsrc=aw.ds
|
@ -7,155 +7,136 @@
|
||||
[#]: via: (https://opensource.com/article/20/2/git-great-teeming-workspaces)
|
||||
[#]: author: (Daniel Gryniewicz https://opensource.com/users/dang)
|
||||
|
||||
Manage complex Git workspaces with Great Teeming Workspaces
|
||||
使用 Great Teeming Workspaces 管理复杂的 Git 工作空间
|
||||
======
|
||||
GTWS is a set of scripts that make it easy to have development
|
||||
environments for different projects and different versions of a project.
|
||||
GTWS 是一系列脚本,这些脚本能让我们在开发环境中管理一个有不同项目和不同版本的工程时变得更简单。
|
||||
![Coding on a computer][1]
|
||||
|
||||
Great Teeming Workspaces ([GTWS][2]) is a complex workspace management package for Git that makes it easy to have development environments for different projects and different versions of a project.
|
||||
[GTWS][2] 是一个 Git 的复杂工作空间管理工具包,可以让我们在开发环境中管理一个有不同项目和不同版本的工程时变得更简单。
|
||||
|
||||
Somewhat like Python [venv][3], but for languages other than Python, GTWS handles workspaces for multiple versions of multiple projects. You can create, update, enter, and leave workspaces easily, and each project or version combination has (at most) one local origin that syncs to and from the upstream—all other workspaces update from the local origin.
|
||||
|
||||
### Layout
|
||||
有点像 Python 的 [venv][3],但不是为 Python 语言准备的。GTWS 用来处理多项目的多个版本的工作空间。你可以很容易地创建、更新、进入和离开工作空间,每个项目或版本的组合(最多)有一个本地的 origin,用来与 upstream 同步 — 其余的所有工作空间都从本地的 origin 更新。
|
||||
|
||||
### 部署
|
||||
|
||||
```
|
||||
${GTWS_ORIGIN}/<project>/<repo>[/<version>]
|
||||
${GTWS_BASE_SRCDIR}/<project>/<version>/<workspacename>/{<repo>[,<repo>...]}
|
||||
```
|
||||
|
||||
Each level in the source tree (plus the homedir for globals) can contain a **.gtwsrc** file that maintains settings and Bash code relevant to that level. Each more specific level overrides the higher levels.
|
||||
源目录的每一级(包括全局的 home 目录)可以包含一个 **.gtwsrc** 文件,这个文件中维护与当前级相关的设置和 bash 代码。每一级的配置会覆盖上一级。
|
||||
|
||||
### Setup
|
||||
|
||||
Check out GTWS with:
|
||||
### 安装
|
||||
|
||||
用下面的命令检出 GTWS:
|
||||
|
||||
```
|
||||
`git clone https://github.com/dang/gtws.git`
|
||||
```
|
||||
|
||||
Set up your **${HOME}/.gtwsrc**. It should include **GTWS_ORIGIN** and optionally **GTWS_SETPROMPT**.
|
||||
|
||||
Add the repo directory to your path:
|
||||
配置你的 **${HOME}/.gtwsrc**。它应该包含 **GTWS_ORIGIN**,也可以再包含 **GTWS_SETPROMPT**。
|
||||
|
||||
把仓库目录加到环境变量中:
|
||||
|
||||
```
|
||||
`export PATH="${PATH}:/path/to/gtws`
|
||||
```
|
||||
|
||||
### Configuration
|
||||
### 配置
|
||||
|
||||
Configuration is via cascading **.gtwsrc** files. It walks the real path down from the root, and each **.gtwsrc** file it finds is sourced in turn. More specific files override less specific files.
|
||||
通过级联 **.gtwsrc** 文件来进行配置。它从根目录向下遍历,会执行在每级目录中找到的 **.gtwsrc** 文件。下级目录的文件会覆盖上一级。
|
||||
|
||||
Set the following in your top-level **~/.gtws/.gtwsrc**:
|
||||
在你最上层的文件 **~/.gtws/.gtwsrc** 中进行如下设置:
|
||||
|
||||
* **GTWS_BASE_SRCDIR:** This is the base of all the projects' source trees. It defaults to **$HOME/src**.
|
||||
* **GTWS_ORIGIN:** This sets the location of the origin Git trees. It defaults to **$HOME/origin**.
|
||||
* **GTWS_SETPROMPT:** This is optional. If it's set, the shell prompt will have the workspace name in it.
|
||||
* **GTWS_DEFAULT_PROJECT:** This is the project used when no project is given or known. If it is not given, projects must be specified on the command line.
|
||||
* **GTWS_DEFAULT_PROJECT_VERSION:** This is the default version to check out. It defaults to **master**.
|
||||
* **GTWS_BASE_SRCDIR:** 所有项目源文件目录树的 base。默认为 **$HOME/src**。
|
||||
* **GTWS_ORIGIN:** 指定 origin git 目录树的路径。默认为 **$HOME/origin**。
|
||||
* **GTWS_SETPROMPT:** 可选配置。如果配置了这个参数,shell 提示符会有工作空间的名字。
|
||||
* **GTWS_DEFAULT_PROJECT:** 不指定项目或项目未知时默认的项目名。如果不指定,使用命令行时必须指明项目。
|
||||
* **GTWS_DEFAULT_PROJECT_VERSION:** 检出的默认版本。默认为 **master**。
|
||||
|
||||
在每个项目的根目录进行以下设置:
|
||||
|
||||
* **GTWS_PROJECT:** 项目的名字(和 base 目录)。
|
||||
* **gtws_project_clone:** 这个函数用于克隆一个项目的指定版本。如果未定义,它会假定项目的 origin 对每一个版本都有一个单独的目录,这样会导致克隆一堆 Git 仓库。
|
||||
* **gtws_project_setup:** 在克隆完所有的仓库后,可以选择是否调用这个函数,调用后可以对项目进行必要的配置,如在 IDE 中配置工作空间。
|
||||
|
||||
Set the following at the project level of each project:
|
||||
在项目版本级进行以下设置:
|
||||
|
||||
* **GTWS_PROJECT:** The name (and base directory) of the project.
|
||||
* **gtws_project_clone:** This function is used to clone a specific version of a project. If it is not defined, then it is assumed that the origin for the project contains a single directory per version, and that contains a set of Git repos to clone.
|
||||
* **gtws_project_setup:** This optional function is called after all cloning is done and allows any additional setup necessary for the project, such as setting up workspaces in an IDE.
|
||||
* **GTWS_PROJECT_VERSION:** 项目的版本。用于正确地从 origin 拉取代码。类似 Git 中的分支名字。
|
||||
|
||||
下面这些参数可以在目录树的任意地方进行配置,如果能生效,它们可以被重写多次:
|
||||
|
||||
* **GTWS_PATH_EXTRA:** 这些是工作空间中加到路径后的额外的路径元素。
|
||||
* **GTWS_FILES_EXTRA:** 这些是不在版本控制内,但应该在工作空间中被检出的额外的文件。这些文件包括 **.git/info/exclude**,每个文件都与仓库的 base 相关联。
|
||||
|
||||
Set this at the project version level:
|
||||
### origin 目录
|
||||
|
||||
* **GTWS_PROJECT_VERSION:** This is the version of the project. It's used to pull from the origin correctly. In Git, this is likely the branch name.
|
||||
**GTWS_ORIGIN** (大部分脚本中)指向拉取和推送的原始 Git 检出目录。
|
||||
|
||||
|
||||
|
||||
These things can go anywhere in the tree and can be overridden multiple times, if it makes sense:
|
||||
|
||||
* **GTWS_PATH_EXTRA:** These are extra path elements to be added to the path inside the workspace.
|
||||
* **GTWS_FILES_EXTRA:** These are extra files not under version control that should be copied into each checkout in the workspace. This includes things like **.git/info/exclude**, and each file is relative to the base of its repo.
|
||||
|
||||
|
||||
|
||||
### Origin directories
|
||||
|
||||
**GTWS_ORIGIN** (in most scripts) points to the pristine Git checkouts to pull from and push to.
|
||||
|
||||
Layout of **${GTWS_ORIGIN}**:
|
||||
**${GTWS_ORIGIN}** 部署:
|
||||
|
||||
* **/<project>**
|
||||
* This is the base for repos for a project.
|
||||
* If **gtws_project_clone** is given, this can have any layout you desire.
|
||||
* If **gtws_project_clone** is not given, this must contain a single subdirectory named **git** that contains a set of bare Git repos to clone.
|
||||
* 这是一个项目的仓库 base。
|
||||
* 如果指定了 **gtws_project_clone**,你可以配置任意的部署路径。
|
||||
* 如果没有指定 **gtws_project_clone**,这个路径下必须有个名为 **git** 的子目录,且 **git** 目录下有一系列用来克隆的裸 Git 仓库。
|
||||
|
||||
### 工作流示例
|
||||
|
||||
假设你有一个项目名为 **Foo**,它的 upstream 为 **github.com/foo/foo.git**。这个仓库有个名为 **bar** 的子模块,它的 upstream 是 **github.com/bar/bar.git**。Foo 项目在 master 分支开发,使用稳定版本的分支。
|
||||
|
||||
### Workflow example
|
||||
为了能在 Foo 中使用 GTWS,你首先要配置目录结构。本例中假设你使用默认的目录结构。
|
||||
|
||||
Suppose you have a project named **Foo** that has an upstream repository at **github.com/foo/foo.git**. This repo has a submodule named **bar** with an upstream at **github.com/bar/bar.git**. The Foo project does development in the master branch and uses stable version branches.
|
||||
|
||||
Before you can use GTWS with Foo, first you must set up the directory structure. These examples assume you are using the default directory structure.
|
||||
|
||||
* Set up your top level **.gtwsrc**:
|
||||
* 配置你最上层的 **.gtwsrc**:
|
||||
* **cp ${GTWS_LOC}/examples/gtwsrc.top ~/.gtwsrc**
|
||||
* Edit **~/.gtwsrc** and change as necessary.
|
||||
* Create top-level directories:
|
||||
* 根据需要修改 **~/.gtwsrc**。
|
||||
* 创建顶级目录:
|
||||
* **mkdir -p ~/origin ~/src**
|
||||
* Create and set up the project directory:
|
||||
* 创建并配置项目目录:
|
||||
* **mkdir -p ~/src/foo**
|
||||
**cp ${GTWS_LOC}/examples/gtwsrc.project ~/src/foo/.gtwsrc**
|
||||
* Edit **~/src/foo/.gtwsrc** and change as necessary.
|
||||
* Create and set up the master version directory:
|
||||
* 根据需要修改 **~/src/foo/.gtwsrc**。
|
||||
* 创建并配置 master 版本目录:
|
||||
* **mkdir -p ~/src/foo/master**
|
||||
**cp ${GTWS_LOC}/examples/gtwsrc.version ~/src/foo/master/.gtwsrc**
|
||||
* Edit **~/src/foo/master/.gtwsrc** and change as necessary.
|
||||
* Go to the version directory and create a temporary workspace to set up the mirrors:
|
||||
* 根据需要修改 **~/src/foo/master/.gtwsrc**。
|
||||
* 进入版本目录并创建一个临时工作空间来配置镜像:
|
||||
* **mkdir -p ~/src/foo/master/tmp**
|
||||
**cd ~/src/foo/master/tmp
|
||||
git clone --recurse-submodules git://github.com/foo/foo.git
|
||||
cd foo
|
||||
gtws-mirror -o ~/origin -p foo**
|
||||
* This will create **~/origin/foo/git/foo.git** and **~/origin/foo/submodule/bar.git**.
|
||||
* Future clones will clone from these origins rather than from upstream.
|
||||
* This workspace can be deleted now.
|
||||
gtws-mirror -o ~/origin -p foo**(译注:这个地方原文有误,不加 `-s` 参数会报错)
|
||||
* 上面命令会创建 **~/origin/foo/git/foo.git** 和 **~/origin/foo/submodule/bar.git**。
|
||||
* 以后的克隆操作会从这些 origin 而不是 upstream 克隆。
|
||||
* 现在可以删除工作空间了。
|
||||
|
||||
到现在为止,Foo 的 master 分支的工作可以结束了。假设你现在想修复一个 bug,名为 **bug1234**。你可以脱离你当前的工作空间为修复这个 bug 单独创建一个工作空间,之后在新创建的工作空间中开发。
|
||||
|
||||
|
||||
At this point, work can be done on the master branch of Foo. Suppose you want to fix a bug named **bug1234**. You can create a workspace for this work to keep it isolated from anything else you're working on, and then work within this workspace.
|
||||
|
||||
* Go to the version directory, and create a new workspace:
|
||||
* 进入版本目录,创建一个新的工作空间:
|
||||
* **cd ~/src/foo/master
|
||||
mkws bug1234**
|
||||
* This creates **bug1234/**, and inside it checks out Foo (and its submodule **bar**) and makes **build/foo** for building it.
|
||||
* Enter the workspace. There are two ways to do this:
|
||||
* 上面的命令创建了 **bug1234/**,在这个目录下检出了 Foo(和它的子模块 **bar**),并创建了 **build/foo** 来构建它。
|
||||
* 有两种方式进入工作空间:
|
||||
* **cd ~/src/foo/master/bug1234
|
||||
startws**
|
||||
or
|
||||
或者
|
||||
**cd ~/src/foo/master/**
|
||||
**startws bug1234**
|
||||
* This starts a subshell within the bug1234 workspace. This shell has the GTWS environment plus any environment you set up in your stacked **.gtwsrc** files. It also adds the base of the workspace to your CD path, so you can **cd** into relative paths from that base.
|
||||
* At this point, you can do work on bug1234, build it, test it, and commit your changes. When you're ready to push to upstream, do this:
|
||||
* 上面的命令在 bug1234 工作空间中开启了一个子 shell。这个 shell 有 GTWS 的环境和你在各级 **.gtwsrc** 文件中设置的环境。它也把你工作空间的 base 路径加入到了 CD,因此你可以从 base 路径 **cd** 到相关的目录中。
|
||||
* 现在你可以修复 bug1234了,构建、测试、提交你的修改。当你可以把代码推送到 upstream 时,执行下面的命令:
|
||||
**cd foo
|
||||
wspush**
|
||||
* **wspush** will push the branch associated with your workspace—first to your local origin and then to the upstream.
|
||||
* If upstream changes. you can sync your local checkout using:
|
||||
* **wspush** 会把代码推送到与你工作空间相关的分支 — 先推送到本地的 origin,再推送到 upstream。
|
||||
* 当 upstream 有修改时,你可以用下面的命令同步到本地:
|
||||
**git sync**
|
||||
* This envokes the **git-sync** script in GTWS, which will update your checkout from the local origin. To update the local origin, use:
|
||||
* 上面的命令调用了 GTWS 的 **git-sync** 脚本,会从本地 origin 更新代码。使用下面的命令来更新本地的 origin:
|
||||
**git sync -o**
|
||||
* This will update your local origin and submodules' mirrors, then use those to update your checkout. **git-sync** has other nice features.
|
||||
* When you're done using the workspace, just exit the shell:
|
||||
* 上面的命令会更新你本地的 origin 和子模块的镜像,然后用那些命令来更新你的检出仓库的代码。**git-sync** 也有一些其他的很好的工鞥。
|
||||
* 当要结束工作空间中的工作时,直接退出 shell:
|
||||
**exit**
|
||||
* You can re-enter the workspace at any time and have multiple shells in the same workspace at the same time.
|
||||
* When you're done with a workspace, you can remove it using the **rmws** command or just remove its directory tree.
|
||||
* There is a script named **tmws** that enters a workspace within tmux, creating a set of windows/panes that are fairly specific to my workflow. Feel free to modify it to suit your needs.
|
||||
|
||||
|
||||
|
||||
### The script
|
||||
* 你可以在任何时间重复进入工作空间,也可以在同一时间在相同的工作空间中开多个 shell。
|
||||
* 当你不需要某个工作空间时,你可以使用 **rmws** 来删除它,或者直接删除它的目录树。
|
||||
* 还有一个脚本 **tmws** 使用 tmux 进入工作空间,能创建一系列的窗口/窗格,这完美契合我的工作流。你可以根据你自己的需求来修改它。
|
||||
|
||||
### 脚本内容
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
@ -1157,7 +1138,7 @@ via: https://opensource.com/article/20/2/git-great-teeming-workspaces
|
||||
|
||||
作者:[Daniel Gryniewicz][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[lxbwolf](https://github.com/lxbwolf)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -1,127 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lxbwolf)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Getting started with Linux firewalls)
|
||||
[#]: via: (https://opensource.com/article/20/2/firewall-cheat-sheet)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Linux 防火墙入门教程
|
||||
======
|
||||
防火墙是你的计算机防止网络入侵的第一道屏障。为确保你的安全,请下载我们的备忘单。
|
||||
![Cheat Sheet cover image][1]
|
||||
|
||||
合理的防火墙是你的计算机防止网络入侵的第一道屏障。你在家里上网,通常互联网服务提供会在路由中搭建一层防火墙。如果不在家里上网,那么你计算机上的那层防火墙就是仅有的一层,因为配置和控制好你 Linux 电脑上的防火墙很重要。如果你维护一台 Linux 服务器,知道怎么去管理你的防火墙同样重要,只要掌握了这些知识你才能保护你的服务器免于本地或远程非法流量的入侵。
|
||||
|
||||
### 安装防火墙
|
||||
|
||||
很多 Linux 发行版本已经自带了防火墙,通常是 `iptables`。它很强大并可以自定义,但配置起来有点复杂。幸运的是,有开发者写出了一些前端界面来帮助用户不需要写冗长的 iptables 规则就可以控制防火墙。
|
||||
|
||||
在 Fedora,CentOS,Red Hat 和一些类似的发行版本上,默认安装的防火墙软件是 `firewalld`,是用 **firewall-cmd** 命令来配置和控制的。在 Debian 和大部分其他发行版上,可以从你的软件仓库安装 firewalld。Ubuntu 自带的是 Uncomplicated Firewall(ufw),所以你必须打开 **universe** 库才能使用 firewalld:
|
||||
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository universe
|
||||
$ sudo apt install firewalld
|
||||
```
|
||||
|
||||
你还需要停用 ufw:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo systemctl disable ufw`
|
||||
```
|
||||
|
||||
没有理由*不*用 ufw。它是一个强大的防火墙前端。然而,本文重点讲 firewalld,因为大部分发行版都支持它而且它集成到了 systemd,systemd 是几乎所有发行版都自带的。
|
||||
|
||||
不管你的发行版是哪个,都要先激活防火墙才能让它生效,激活需要在启动时加载:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo systemctl enable --now firewalld`
|
||||
```
|
||||
|
||||
### 理解防火墙的 zone
|
||||
|
||||
Firewalld 旨在让防火墙的配置工作尽可能简单。它通过建立 *zone* 来实现这个目标。一个 zone 是一类型的合理、通用的规则,这些规则适配大部分用户的日常需求。
|
||||
|
||||
* **trusted:** 接受所有的连接。这是最低级别的防火墙设置,只能在一个完全信任的环境中,如测试实验室或网络中相互都认识的家庭网络中。
|
||||
* **home, work, internal: **在这三个 zone 中,接受大部分来的连接。它们每个都会拒绝不活跃的端口进来的流量。这三个都适合用于家庭环境中,因为在家庭环境中不会出现端口模糊的网络流量,在家庭网络中你可以基本信任其他的用户。
|
||||
* **public:** 用于公共区域内。这是个极端的设置,当你不信任网络中的其他计算机时使用。只能接收经过选择的和基本安全的连接。
|
||||
* **dmz:** DMZ 表示隔离区。这个 zone 多用于可公开访问的计算机,属于某个组织的外部网络不能完全访问内网的计算机。对于个人计算机,它没什么用,但是对某类服务器来说它是个很重要的选项。
|
||||
* **external:** 用于外部网络,会开启伪装(你私人网络的地址被映射到一个外网 IP 地址,并隐藏起来)。跟 DMZ 类似,仅接受经过选择的连接,包括 SSH。
|
||||
* **block:** 仅接收在本系统中初始化的网络连接。接收到的任何网络连接都会被 **icmp-host-prohibited** 信息拒绝。这个一个极度偏激的设置,对于某类服务器或处于不信任或不安全的环境中的个人计算机来说很重要。
|
||||
* **drop:** 接收的所有网络包都被丢弃,没有任何回复。仅能有发送出去的网络连接。比这个设置更极端的办法,只有关闭 WiFi 和拔掉网线。
|
||||
|
||||
|
||||
|
||||
你可以查看你发行版本的所有 zone,或通过配置文件 **/usr/lib/firewalld/zones** 来查看管理员设置。举个例子:下面是 Fefora 31 自带的 FedoraWorkstation zone:
|
||||
|
||||
|
||||
```
|
||||
$ cat /usr/lib/firewalld/zones/FedoraWorkstation.xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<zone>
|
||||
<short>Fedora Workstation</short>
|
||||
<description>Unsolicited incoming network packets are rejected from port 1 to 1024, except for select network services. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
|
||||
<service name="dhcpv6-client"/>
|
||||
<service name="ssh"/>
|
||||
<service name="samba-client"/>
|
||||
<port protocol="udp" port="1025-65535"/>
|
||||
<port protocol="tcp" port="1025-65535"/>
|
||||
</zone>
|
||||
```
|
||||
|
||||
### 获取当前的 zone
|
||||
|
||||
任何时候你都可以通过 **\--get-active-zones** 选项来查看你是在哪个 zone
|
||||
|
||||
|
||||
```
|
||||
`$ sudo firewall-cmd --get-active-zones`
|
||||
```
|
||||
|
||||
输出结果中,会有当前活跃的 zone 名字和分配给它的网络接口。笔记本电脑上,在默认 zone 中通常意味着你有个 WiFi 卡:
|
||||
|
||||
|
||||
```
|
||||
FedoraWorkstation
|
||||
interfaces: wlp61s0
|
||||
```
|
||||
|
||||
### 修改你当前的 zone
|
||||
|
||||
把你的网络接口分配给另一个 zone,就可以改变 zone。例如,把例子中的 **wlp61s0** 卡修改为 public zone:
|
||||
|
||||
|
||||
```
|
||||
$ sudo firewall-cmd --change-interface=wlp61s0 \
|
||||
\--zone=public
|
||||
```
|
||||
|
||||
你可以为一个接口修改活跃的 zone,不管出于什么理由 — 无论你是要出去喝杯咖啡还是感觉有必要增强笔记本电脑的安全策略,无论是你要去工作需要开启某些端口才能进入内联网,还是任何其他的理由。在你凭记忆学会 **firewall-cmd** 命令之前,你只要记住了关键词 ”change“ 和 ”zone“,就可以慢慢掌握,因为按下 **Tab** 时,它的选项会自动补全。
|
||||
|
||||
### 更多信息
|
||||
|
||||
你可以用你的防火墙干更多的事,比如自定义已存在的 zone,设置默认的 zone,等等。你对防火墙越了解,你在网上的活动就越安全,所以我们创建了一个[备忘单][2]便于速查和参考。
|
||||
|
||||
### 下载你的 [防火墙备忘单][2]
|
||||
|
||||
David Both分享了他是怎样用树莓派 2 替换他的专用网络防火墙电脑的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/2/firewall-cheat-sheet
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[lxbwolf](https://github.com/lxbwolf)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_cheat_sheet.png?itok=lYkNKieP (Cheat Sheet cover image)
|
||||
[2]: https://opensource.com/downloads/firewall-cmd-cheat-sheet
|
@ -0,0 +1,343 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Zioyi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (12 Linux Commands to Have Some Fun in the Terminal)
|
||||
[#]: via: (https://itsfoss.com/funny-linux-commands/)
|
||||
[#]: author: (Community https://itsfoss.com/author/itsfoss/)
|
||||
|
||||
12个有趣的Linux终端命令
|
||||
======
|
||||
|
||||
_**你觉得Linux终端里只有无趣的工作吗?那你一定不知道下面这些有趣的Linux命令吧。**_
|
||||
|
||||
Linux终端是用来完成复杂的工作的,我们有很多有用的[linux命令奇技淫巧][1]来帮助你。
|
||||
|
||||
但是,你知道你还可以用终端来做很多有趣的是吗?如果你不知道,没关系,大多数Linux用户也都只把终端视为一个用来管理系统和执行任务的交互接口。
|
||||
|
||||
然而,如果你知道这里有些你可以在终端玩的[基于终端的游戏][2]和[ASCII码游戏][3],你一定会大吃一惊。
|
||||
|
||||
在这篇文章中,我将会探索一些有趣的、可笑的、荒谬的命令来让你可以在终端中找点乐子!
|
||||
|
||||
### 用这些命令在Linux终端中找点乐子
|
||||
|
||||
![][4]
|
||||
|
||||
你可能会觉得这些命令荒谬或没用,但是有一些还是可以被好好利用的。
|
||||
|
||||
我已经添加了Ubuntu/Debian的安装组件,如果你使用基于Ubuntu的发行版,请确保[启用通用仓库][5]因为大多数命令不在主仓库中。
|
||||
|
||||
如果你使用Arch、Fedora、SUSE、Solus或者其他非Ubuntu的发行版,请使用你的发行版包管理工具去安装这些有趣的Linux命令。
|
||||
|
||||
#### 1\. 在终端开一辆火车
|
||||
|
||||
让我们坐上火车,来一场说走就走的旅行的,没错,就是字面意思!
|
||||
|
||||
sl命令可以让你在终端运行一辆火车。
|
||||
|
||||
![][6]
|
||||
|
||||
安装方法:
|
||||
|
||||
```
|
||||
sudo apt install sl
|
||||
```
|
||||
|
||||
完成后,你只要在终端输入下面的命令就可以开始
|
||||
|
||||
```
|
||||
sl
|
||||
```
|
||||
|
||||
很精彩,对吧?但等等,我们还没结束!你还可以让你的火车飞起来,只要加上参数-F,Magic:
|
||||
|
||||
```
|
||||
sl -F
|
||||
```
|
||||
|
||||
**这样会让火车长出翅膀飞出终端窗口!**
|
||||
|
||||
#### 2\. 给你的Linux终端加上矩阵效果
|
||||
|
||||
还记得科幻电影[黑客帝国][7]吗?掉落在终端的绿字变成一个矩阵符号。
|
||||
|
||||
你也可以在你的Linux电脑里有这样的矩阵数字雨!你只需要安装**cmatric**然后在终端输入它就行。
|
||||
|
||||
![][8]
|
||||
|
||||
在Debian/Ubuntu Linux上安装cmatrix:
|
||||
|
||||
```
|
||||
sudo apt install cmatrix
|
||||
```
|
||||
|
||||
现在,你要做的就是输入下面的命令,在终端就会有矩阵屏幕了:
|
||||
|
||||
```
|
||||
cmatrix
|
||||
```
|
||||
|
||||
按住Ctrl+C来停止它,黑客先生。
|
||||
|
||||
**推荐阅读:**
|
||||
|
||||
![][9]
|
||||
|
||||
#### [通过Telnet在Linux终端看星际大战][10]
|
||||
|
||||
在Linux终端看星际大战。
|
||||
|
||||
#### 3\. 让这里着火
|
||||
|
||||
拿好灭火器因为接下来你要在你的终端里点火了!
|
||||
|
||||
![][11]
|
||||
|
||||
想安装它,你要输入:
|
||||
|
||||
```
|
||||
sudo apt install libaa-bin
|
||||
```
|
||||
|
||||
完成后,你输入下面的命令,你的终端就会燃起一团火焰:
|
||||
|
||||
```
|
||||
aafire
|
||||
```
|
||||
|
||||
按住Ctril+C来停止它。
|
||||
|
||||
#### 4\. 幸运饼干命令
|
||||
|
||||
想知道你的运气怎样但身边没有幸运饼干?
|
||||
|
||||
别担心,你只需在终端打出“fortune”然后按下回车。终端将会显示出一个你的幸运语就像你从幸运饼干里得到的一样。
|
||||
|
||||
![][12]
|
||||
|
||||
安装它:
|
||||
|
||||
```
|
||||
sudo apt install fortune
|
||||
```
|
||||
|
||||
完成后,只要在命令行打出下面的内容,你就会知道你的运气怎样:
|
||||
|
||||
```
|
||||
fortune
|
||||
```
|
||||
|
||||
这是一个你可以实际去使用的命令。你可以用它作为每日消息,这样在多用户环境下,每个用户登录后都会得到一个“幸运饼干”。
|
||||
|
||||
你也可以把它添加到bashrc文件,这样当你登进终端你就会看到了。
|
||||
|
||||
#### 5\. 宠物爱好者?这是给你准备的
|
||||
|
||||
Oneko是一个有趣的命令,可以把你的光标变成一只老鼠,然后创造一只猫,一旦你移动光标,就会来追你。这不仅局限于终端。当猫追逐光标时,你可以继续工作。
|
||||
|
||||
如果你家里有孩子这一定很有趣。
|
||||
|
||||
![][13]
|
||||
|
||||
用下面的命令安装Oneko
|
||||
|
||||
```
|
||||
sudo apt install oneko
|
||||
```
|
||||
|
||||
用下面的命令运行它:
|
||||
|
||||
```
|
||||
oneko
|
||||
```
|
||||
|
||||
如果你不喜欢猫,喜欢狗,输入:
|
||||
|
||||
```
|
||||
oneko -dog
|
||||
```
|
||||
|
||||
这里有很多种小宠物,你可以用oneko -help获取信息。用Ctrl+C终止它。
|
||||
|
||||
#### 6\. 有个小兄弟在看着你
|
||||
|
||||
Xeyes是一个很小的GUI程序,它可以绘制出一双眼睛一直盯着你!它会不断跟随您的鼠标光标,运行命令自己看看!
|
||||
|
||||
![][14]
|
||||
|
||||
你可以用下面命令安装:
|
||||
|
||||
```
|
||||
sudo apt install xeyes
|
||||
```
|
||||
|
||||
然后这样用它:
|
||||
|
||||
```
|
||||
xeyes
|
||||
```
|
||||
|
||||
按住Ctrl+C终止它。
|
||||
|
||||
#### 7\. Let the terminal speak for you
|
||||
#### 7\. 让终端帮你讲话
|
||||
|
||||
打开你的扬声器,你来试试这个命令,[eSpeak][15]是一个有趣的命令,它可以让你的终端说话。是的,你没听错。
|
||||
|
||||
先安装这个包:
|
||||
|
||||
```
|
||||
sudo apt install espeak
|
||||
```
|
||||
|
||||
接下来,你只需要输入在命令行中输入你想听到的话:
|
||||
|
||||
```
|
||||
espeak "Type what your computer says"
|
||||
```
|
||||
|
||||
无论你在双引号里面填什么,你的电脑都会复述出来!它就像[在Linux中的echo命令][16],但不是打印出来,而是说出来。
|
||||
|
||||
#### 8\. 卫生间(但它不能洗衣服)
|
||||
|
||||
这听起来有点奇怪,是的。但是,这只是一个命令,用来将文本转换成大的ASCII字符。
|
||||
|
||||
![][17]
|
||||
|
||||
用这个命令安装toilet:
|
||||
|
||||
```
|
||||
sudo apt install toilet
|
||||
```
|
||||
|
||||
完成后,你只需输入:
|
||||
|
||||
```
|
||||
toilet sample text you want
|
||||
```
|
||||
|
||||
我也不知道为啥这个小程序叫卫生间。
|
||||
|
||||
#### 9\. 那个牛说什么?
|
||||
|
||||
Cowsay是一个在终端中用ASCII字符展示出一头牛的命令。通过这个命令,你可以控制牛说出你想说的话。
|
||||
|
||||
别纠结声音,它只展示文本(就是你看漫画书一样)。
|
||||
|
||||
![Cowsay Cowthink][18]
|
||||
|
||||
安装**cowsay**:
|
||||
|
||||
```
|
||||
sudo apt install cowsay
|
||||
```
|
||||
|
||||
安装完成后,你只要输入:
|
||||
|
||||
```
|
||||
cowsay "your text"
|
||||
```
|
||||
|
||||
无论你在双引号里填什么,你的牛都会说!我看到一些系统管理员用它来展示每天的消息。你也可以这样,你甚至可以把它和fortune命令结合。
|
||||
|
||||
#### 10\. Banner命令
|
||||
|
||||
banner命令与toilet命令相似,但它限制最多只能打印10个字符。
|
||||
|
||||
![][19]
|
||||
|
||||
你可以这样安装banner命令:
|
||||
|
||||
```
|
||||
sudo apt install sysvbanner
|
||||
```
|
||||
|
||||
然后这样运行:
|
||||
|
||||
```
|
||||
banner "Welcome"
|
||||
```
|
||||
|
||||
替换双引号里的内容,你将会得到你想要的展示内容。
|
||||
|
||||
#### 11\. Yes命令
|
||||
|
||||
![][20]
|
||||
|
||||
yes命令帮助你在循环中自动响应直到终止命令。这个命令将会一直打印相同的内容。如果你想快速生成大量垃圾文本,那么此命令将像超级按钮一样工作。
|
||||
|
||||
你也可以使用它为命令提供“yes”(如果提示)。例如,apt upgrade命令会要求你确认,你可以像这样使用它:
|
||||
|
||||
```
|
||||
yes | sudo apt upgrade
|
||||
```
|
||||
|
||||
你不需要安装任何包,Yes命令已经存在了。
|
||||
|
||||
想要终止yes命令循环,只需按住**CTRL+C**。
|
||||
|
||||
#### 12\. 得到一个新的身份
|
||||
|
||||
要生成一个随机的假身份吗?我推荐你用rig命令。你在终端运行它,就会生成一个假的身份。
|
||||
|
||||
![][21]
|
||||
|
||||
用这个命令安装rig:
|
||||
|
||||
```
|
||||
sudo apt install rig
|
||||
```
|
||||
|
||||
只需像这样输入:
|
||||
|
||||
```
|
||||
rig
|
||||
```
|
||||
|
||||
它可能被用在脚本或者web应用中展示随机信息,但我自己还没做过什么。
|
||||
|
||||
**结尾**
|
||||
|
||||
我希望你会喜欢这个有趣的Linux命令列表。你最喜欢哪个命令呢?你还知道其他有趣的命令吗?请在评论部分与我们分享。
|
||||
|
||||
![][22]
|
||||
|
||||
### Srimanta Koley
|
||||
|
||||
Srimanta是一位热情的作家、发行者、开源爱好者,非常喜欢与技术相关的所有内容。他喜欢读书,特别是90年的书!
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/funny-linux-commands/
|
||||
|
||||
作者:[Community][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Zioyi](https://github.com/Zioyi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/itsfoss/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/linux-command-tricks/
|
||||
[2]: https://itsfoss.com/best-command-line-games-linux/
|
||||
[3]: https://itsfoss.com/best-ascii-games/
|
||||
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fun-linux-commands.png?ssl=1
|
||||
[5]: https://itsfoss.com/ubuntu-repositories/
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/sl-command.jpg?ssl=1
|
||||
[7]: https://en.wikipedia.org/wiki/The_Matrix
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/matrix-screen-command.png?ssl=1
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2015/12/Star-Wars-Linux-Terminal-2.png?fit=732%2C462&ssl=1
|
||||
[10]: https://itsfoss.com/star-wars-linux/
|
||||
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fire-command.png?ssl=1
|
||||
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fortune-command.jpg?ssl=1
|
||||
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/oneko-command.jpg?ssl=1
|
||||
[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/xeyes-command.jpg?ssl=1
|
||||
[15]: https://itsfoss.com/espeak-text-speech-linux/
|
||||
[16]: https://linuxhandbook.com/echo-command/
|
||||
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/toilet-command.jpg?ssl=1
|
||||
[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cowsay-cowthink.jpg?ssl=1
|
||||
[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/banner-command.jpg?ssl=1
|
||||
[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/yes-yourtext.jpg?ssl=1
|
||||
[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/rig-command.jpg?ssl=1
|
||||
[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/srimanta.jpg?ssl=1
|
Loading…
Reference in New Issue
Block a user