mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
commit
34016915e1
@ -1,11 +1,11 @@
|
||||
我是被 root@notty 黑了吗?
|
||||
我是被 “root@notty” 黑了吗?
|
||||
======
|
||||
|
||||
当你在 `ps aux` 的输出中看到 `sshd:root@notty` 时会觉得很奇怪吧,`notty` 算是哪门子的主机,是不是黑客计算机的名字啊。不过不用担心; `notty` 仅仅是表示 `no tty` 而已。
|
||||
当你在 `ps aux` 的输出中看到 `sshd:root@notty` 时会觉得很奇怪吧,`notty` 算是哪门子的主机,是不是黑客计算机的名字啊。不过不用担心;`notty` 仅仅是表示 没有 tty 而已。
|
||||
|
||||
当你在本地登陆 linux 机器时,登陆终端会在进程列表中显示为 `tty`( 比如。tty7)。若你通过 ssh 登陆一台远程服务器,则会看到类似 `root@pts/0` 这样的东西。
|
||||
当你在本地登录 Linux 机器时,登录终端会在进程列表中显示为 `tty`( 比如,tty7)。若你通过 ssh 登录一台远程服务器,则会看到类似 `root@pts/0` 这样的东西。
|
||||
|
||||
而若某个连接是由 sftp 或者是由 scp 拷贝文件而创建的,则该连接会会显示成 no tty (notty)。
|
||||
而若某个连接是由 sftp 或者是由 scp 拷贝文件而创建的,则该连接会会显示成没有 tty (notty)。
|
||||
|
||||
如果你仍然想知道服务器上发生了什么事情,可以检查 `ps auxf` 的输出来查看进程树,或者运行 `netstat -vatn` 来检查所有的 TCP 连接。
|
||||
|
||||
@ -15,7 +15,7 @@ via: http://www.sysadminworld.com/2011/ps-aux-shows-sshd-rootnotty/
|
||||
|
||||
作者:[sysadminworld][a]
|
||||
译者:[lujun9972](https://github.com/lujun9972)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
294
published/20170216 25 Free Books To Learn Linux For Free.md
Normal file
294
published/20170216 25 Free Books To Learn Linux For Free.md
Normal file
@ -0,0 +1,294 @@
|
||||
25 个学习 Linux 的免费资源
|
||||
======
|
||||
|
||||
> 在这篇文章中,我将与你分享免费学习 Linux 的最佳资源。这个集合包括了网站、在线视频课程和免费电子书。
|
||||
|
||||
**如何学习 Linux ?**
|
||||
|
||||
这可能是 Facebook Linux 用户组中最常见的问题。
|
||||
|
||||
“如何学习 Linux”这个看起来简单的问题的答案并不简单。
|
||||
|
||||
问题在于不同的人对于学习 Linux 有不同的意义。
|
||||
|
||||
* 比如有人从来没有使用过 Linux,无论是命令行还是桌面版本,那个人可能只是想知道更多关于它的信息。
|
||||
* 比如有人使用 Windows 作为桌面,但必须在工作中使用 Linux 命令行,那个人可能对学习 Linux 命令感兴趣。
|
||||
* 比如有人已经使用过一段时间的 Linux,而且懂得一些基础,但他/她可能想要更上一层楼。
|
||||
* 比如有人只是对 Linux 特定的发行版本感兴趣。
|
||||
* 比如有人想要提升或学习几乎与 Linux 命令行差不多的 Bash 脚本。
|
||||
* 比如有人想要从事一个 Linux 系统管理员的职业,或者想提高他/她的系统管理技能。
|
||||
|
||||
你看,“我如何学习 Linux”的答案取决于你追求什么样的 Linux 知识。为此,我收集了大量能用来学习 Linux 的资源。
|
||||
|
||||
这些免费的资源包括电子书、视频课程、网站等。这些资源分成几个子类别,以便当你试图学习 Linux 时可以很容易地找到你想要的东西。
|
||||
|
||||
再者,这里没有学习 Linux 的最好方式。这完全取决于你如何去学习 Linux,通过在线门户网站、下载电子书、视频课程或者其他。
|
||||
|
||||
让我们看看你能如何学习 Linux。
|
||||
|
||||
**免责声明** : 这里列举的所有书都可以合法的下载。 据我所知,这里提到的资源都是官方的资源。但是,如果你发现它不是,请让我知道以便我可以采取适当的措施。
|
||||
|
||||
![Best Free eBooks to learn Linux for Free][1]
|
||||
|
||||
### 1. 对于完全新手学习 Linux 的免费资料
|
||||
|
||||
也许你刚刚从朋友那里或者从网上的讨论中听到了 Linux。关于 Linux 的炒作让你对 Linux 很感兴趣,你被互联网上的大量信息所淹没,不知道在哪里寻找更多的关于 Linux 的知识。
|
||||
|
||||
不用担心,我们中的大多数,即使不是全部,都经过过这个阶段。
|
||||
|
||||
#### Linux 基金会关于 Linux 的介绍 [视频课程]
|
||||
|
||||
如果你对于什么是 Linux 和如何开始学习 Linux 完全没有概念的话,我建议你从学习 [Linux 基金会][2]在 [edX][3] 上提供的免费的视频课程开始。它可以看做“维护” Linux 的组织的一个官方课程——是的,这个组织是由 Linux 之父 [Linus Torvalds][4] 所背书的。
|
||||
|
||||
- [Introduction To Linux][5]
|
||||
|
||||
#### Linux 旅程 [网站]
|
||||
|
||||
不是官方的,也许不是很受欢迎。但是这个小网站对于初学者来说是一个 Linux 学习的完美场所。
|
||||
|
||||
该网站设计精美,并根据主题组织得很好。它给你提供了能够在阅读完一个片段或章节后的进行的互动式测验。我的建议是收藏这个网站:
|
||||
|
||||
- [Linux Journey][6]
|
||||
|
||||
#### 《5 天学习 Linux》 [电子书]
|
||||
|
||||
这本出色的书针对 FOSS 读者来说完全的免费,这完全得感谢 [Linux Training Academy][7]。
|
||||
|
||||
为完全的新手而写,这本免费的 Linux 电子书给了你一个关于 Linux 的概述、常用的 Linux 指令和你开始学习 Linux 所需要的其他东西。
|
||||
|
||||
你能够从下面的网页下载该书:
|
||||
|
||||
- [Learn Linux In 5 Days][8]
|
||||
|
||||
#### 《Linux 新手终极指南》 [电子书]
|
||||
|
||||
这是一本面向 Linux 初学者的免费下载的电子书。该电子书从解释什么是 Linux 开始,并提供了将 Linux 作为桌面的更多实际使用经验。
|
||||
|
||||
您可以从下面的链接下载最新版本的电子书:
|
||||
|
||||
- [The Ultimate Linux Newbie Guide][9]
|
||||
|
||||
### 2. 初学者进阶的免费书籍
|
||||
|
||||
本节列出了那些已经“完成”的 Linux 电子书。
|
||||
|
||||
我的意思是,这些之中的大部分就像是专注于 Linux 的每个方面的学术教科书。你可以作为一个绝对的新手阅读这些书,或者你也可以作为一个中级的 Linux 用户来深入学习。即使你已经是专家级,你也可以把它们作为参考。
|
||||
|
||||
#### 《Linux 介绍》 [电子书]
|
||||
|
||||
《Linux 介绍》是 [Linux 文档计划][10]的免费电子书,而且它是最热门的 Linux 免费电子书之一。即使我认为其中的部分段落需要更新,它仍然是一本非常好的电子书,可以教你 Linux、Linux 的文件系统、命令行、网络和其他相关的东西。
|
||||
|
||||
- [Introduction To Linux][11]
|
||||
|
||||
#### 《Linux 基础》 [电子书]
|
||||
|
||||
这本由 Paul Cobbaut 编写的免费的电子书可以教你关于 Linux 的历史、安装和你需要知道的基本的 Linux 命令。你能够从下列链接上得到这本书:
|
||||
|
||||
- [Linux Fundamentals][12]
|
||||
|
||||
#### 《Linux 高级编程》 [电子书]
|
||||
|
||||
顾名思义,这是一本面向想要或者正在开发 Linux 软件的高级用户的书。它阐释了那些复杂的功能,比如多进程、多线程、进程间通信以及和硬件设备的交互。
|
||||
|
||||
跟着这本书学习会帮你开发一个更快速、更可靠、更安全的使用 GNU/Linux 系统全部功能的项目。
|
||||
|
||||
- [Advanced Linux Programming][13]
|
||||
|
||||
#### 《LFS》 [电子书]
|
||||
|
||||
如果你认为自己对 Linux 有足够的了解,并且你是一个专业人士,那么为什么不创建自己的 Linux 版本呢? Linux From Scratch(LFS)是一个完全基于源代码,为你构建你自定义的 Linux 系统提供手把手的指导。
|
||||
|
||||
可以把它叫做 DIY Linux ,它是一个把你的 Linux 专业知识提高到新的高度的方法。
|
||||
|
||||
这里有许多的关于这个项目的子项目,你能够在这个网站上查看和下载。
|
||||
|
||||
- [Linux From Scratch][14]
|
||||
|
||||
### 3. 学习 Linux 命令和 Shell 脚本的免费电子书
|
||||
|
||||
Linux 的真正强大在于命令行,如果你想要征服 Linux,你必须学习命令行和shell。
|
||||
|
||||
事实上,如果你必须在你的工作中使用 Linux 终端,那么熟悉 Linux 命令行实际上会帮助你完成任务,也有可能帮助你提高你的职业生涯(因为你会更有效率)。
|
||||
|
||||
在本节中,我们将看到各种 Linux 命令方面的免费电子书。
|
||||
|
||||
#### 《GNU/Linux 命令行工具总览》 [电子书]
|
||||
|
||||
这本 Linux 文档项目中的电子书是接触 Linux 命令行并开始熟悉 Shell 脚本的好地方。
|
||||
|
||||
- [GNU/Linux Command−Line Tools Summary][15]
|
||||
|
||||
#### 《GNU Bash 参考手册》 [电子书]
|
||||
|
||||
这是一本可以从 [GNU][16] 网站下载的免费电子书。 就像名字暗示的那样, 它涉及 Bash Shell (如果我能这么叫的话)。这本书超过了 175 页,而且它包括了许多在 Bash 里和 Linux 有关的主题。
|
||||
|
||||
你能够从下面的链接中获取:
|
||||
|
||||
- [Bash Reference Manual][17]
|
||||
|
||||
#### 《Linux 命令行》 [电子书]
|
||||
|
||||
这本 500 多页的由 William Shotts 编写的免费电子书,对于那些认真学习 Linux 命令行的人来说,是一本必须拥有的书。
|
||||
|
||||
即使你认为你已经了解了 Linux,你还是会惊讶于这本书能教你很多东西。
|
||||
|
||||
它涵盖了从初学者到高级的东西。我敢打赌读完这本书之后你会成为一个更好的 Linux 用户。请下载这本书并且随时携带它。
|
||||
|
||||
- [The Linux Command Line][18]
|
||||
|
||||
#### 《Bash 入门指南》 [电子书]
|
||||
|
||||
如果你想从 Bash 脚本开始,这可能对于你来说是一个很好的助手。 这本电子书也是基于 Linux 文档项目的,它是编写 《Linux 介绍》的电子书的作者(本文前面讨论过)。
|
||||
|
||||
- [Bash Guide for Beginners][19]
|
||||
|
||||
#### 《Bash 脚本高级指南》 [电子书]
|
||||
|
||||
如果你认为你已经了解了基本的 Bash 脚本知识,并且你想把你的技能提高到一个新的水平,这本书就是你所需要的。这本书有超过 900 页的各种高级命令和举例。
|
||||
|
||||
- [Advanced Bash-Scripting Guide][20]
|
||||
|
||||
#### 《AWK 编程语言》 [电子书]
|
||||
|
||||
这不是一本很美观的书,但是如果你真的想要深入学习脚本,这本虽旧但是依然很棒的书会很有帮助。
|
||||
|
||||
- [The AWK Programming Language][21]
|
||||
|
||||
#### 《Linux 101 技巧》 [电子书]
|
||||
|
||||
这本 270 多页的书来自“The Geek Stuff”,通过易于跟踪学习的例子教给你 Linux 命令行基础。你能够从下列的链接获取:
|
||||
|
||||
- [Linux 101 Hacks][22]
|
||||
|
||||
### 4. 特定发行版的免费学习资料
|
||||
|
||||
这个章节专注于特定 Linux 发行版的材料。到目前为止,我们看到的都是以常规的方式学习 Linux,更多的关注于文件系统、命令和其他的核心内容。
|
||||
|
||||
这些书,在另一方面,可以被认为是用户手册或者开始学习各种各样的 Linux 发行版的指南。所以如果你正在使用或准备使用一个特定的 Linux 发行版,你可以参考这些资源。是的,这些书更加关注 Linux 桌面。
|
||||
|
||||
我还想补充的是,大部分的 Linux 发行版有它们自己的大量的 wiki 或者文档。你能够从网上随时找到它们。
|
||||
|
||||
#### 《Ubuntu 用户指南》 [电子书]
|
||||
|
||||
不用说,这本书是针对 Ubuntu 用户的。这是一个独立的项目,以免费电子书的形式提供 Ubuntu 的用户指南。它对于每个版本的 Ubuntu 都有更新。
|
||||
|
||||
这本书被叫做用户指南因为它是由一步步的指导组成的,而且受众目标是对于 Ubuntu 完全新手的。所以,你会了解到 Unity 桌面,以及怎样逐渐使用它而且查找应用等等。
|
||||
|
||||
如果你从来没有使用过 Ubuntu Unity ,那么这是一本你必须拥有的书,因为它帮助你理解怎样在日常中使用 Ubuntu。
|
||||
|
||||
- [Ubuntu Manual][23]
|
||||
|
||||
#### 《面向 Linux Mint:直接告诉我就行!》 [电子书]
|
||||
|
||||
一本非常基本的关于 Linux Mint 的电子书。它告诉你怎么样在虚拟机中安装 Linux Mint,怎么样去查找软件,安装更新和自定义 Linux Mint 桌面。
|
||||
|
||||
你能够在下面的链接下载电子书:
|
||||
|
||||
- [Just Tell Me Damnit!][24]
|
||||
|
||||
#### 《Solus Linux 用户指南》 [电子书]
|
||||
|
||||
注意!这本书过去是 Solus Linux 的官方用户指南,但是我找不到 Solux 项目的网站上在哪里有提到它。我不知道它是不是已经过时了。尽管如此,反正不要钱,多少学习一点 Solus Linux。
|
||||
|
||||
- [Solus Linux User Guide][25]
|
||||
|
||||
### 5. 面向系统管理员的免费电子书
|
||||
|
||||
这个章节主要关注于系统管理员——开发者的超级英雄。我已经列了一部分会真正帮助那些已经是系统管理者或者想要成为系统管理者的免费的电子书。我还得说,你必须要关注基本的 Linux 命令行,因为它会使你的工作更加简单。
|
||||
|
||||
#### 《The Debian 管理手册》 [电子书]
|
||||
|
||||
如果你使用 Debian Linux 作为你的服务器,这本书就是你的圣经。这本书从 Debian 的历史、安装、包管理等等开始,接着覆盖一些主题,比如说 [LAMP][26]、虚拟机、存储管理和其他核心系统管理。
|
||||
|
||||
- [The Debian Administration's Handbook][27]
|
||||
|
||||
#### 《高级 Linux 系统管理》 [电子书]
|
||||
|
||||
如果在准备 [LPI 认证][28],那么这本书是一本理想的书。这本书的涉及系统管理员必要的主题,所以了解 Linux 命令行是前置条件。
|
||||
|
||||
- [Advanced Linux System Administration][29]
|
||||
|
||||
#### 《Linux 系统管理》 [电子书]
|
||||
|
||||
Paul Cobbaut 编写的另一本免费的电子书。370 页长的的书包括了网络、磁盘管理、用户管理、内核管理、库管理等等。
|
||||
|
||||
- [Linux System Administration][30]
|
||||
|
||||
#### 《Linux 服务器》 [电子书]
|
||||
|
||||
又一本来自 [linux-training.be][31] 的 Paul Cobbaut 编写的电子书。这本书包括了 Web 服务器、MySQL、DHCP、DNS、Samba 和其他文件服务器。
|
||||
|
||||
- [Linux Servers][32]
|
||||
|
||||
#### 《Linux 网络》 [电子书]
|
||||
|
||||
网络是系统管理者的面包和黄油,这本也是由 Paul Cobbaut 编写的书是一本好的参考资料。
|
||||
|
||||
- [Linux Networking][33]
|
||||
|
||||
#### 《Linux 存储》 [电子书]
|
||||
|
||||
这本由 Paul Cobbaut(对,还是他)编写的书详细解释了 Linux 的磁盘管理,而且介绍了许多其他的和存储相关的技术。
|
||||
|
||||
- [Linux Storage][34]
|
||||
|
||||
#### 《Linux 安全》 [电子书]
|
||||
|
||||
这是这个书单里最后一本由 Paul Cobbaut 编写的书。安全是系统管理员最重要的工作之一。这本书关注文件权限、ACL、SELinux、用户和密码等等。
|
||||
|
||||
- [Linux Security][35]
|
||||
|
||||
### 你有什么最喜爱的 Linux 资料吗?
|
||||
|
||||
我知道这是一个不错的免费 Linux 电子书集合,但是它可以做的更好。
|
||||
|
||||
如果你有学习 Linux 方面有更大帮助的其它资料,请务必和我们共享。请注意只共享合法的下载资料,以便我可以根据你的建议更新这篇文章而不会有任何问题。
|
||||
|
||||
我希望你觉得这篇文章在学习 Linux 时有帮助,欢迎你的反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/learn-linux-for-free/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
译者:[yyyfor](https://github.com/yyyfor)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://itsfoss.com/author/abhishek/
|
||||
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/02/free-ebooks-linux-800x450.png
|
||||
[2]:https://www.linuxfoundation.org/
|
||||
[3]:https://www.edx.org
|
||||
[4]:https://www.youtube.com/watch?v=eE-ovSOQK0Y
|
||||
[5]:https://www.edx.org/course/introduction-linux-linuxfoundationx-lfs101x-0
|
||||
[6]:https://linuxjourney.com/
|
||||
[7]:https://www.linuxtrainingacademy.com/
|
||||
[8]:https://courses.linuxtrainingacademy.com/itsfoss-ll5d/
|
||||
[9]:https://linuxnewbieguide.org/ulngebook/
|
||||
[10]:http://www.tldp.org/index.html
|
||||
[11]:http://tldp.org/LDP/intro-linux/intro-linux.pdf
|
||||
[12]:http://linux-training.be/linuxfun.pdf
|
||||
[13]:http://advancedlinuxprogramming.com/alp-folder/advanced-linux-programming.pdf
|
||||
[14]:http://www.linuxfromscratch.org/
|
||||
[15]:http://tldp.org/LDP/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.pdf
|
||||
[16]:https://www.gnu.org/home.en.html
|
||||
[17]:https://www.gnu.org/software/bash/manual/bash.pdf
|
||||
[18]:http://linuxcommand.org/tlcl.php
|
||||
[19]:http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf
|
||||
[20]:http://www.tldp.org/LDP/abs/abs-guide.pdf
|
||||
[21]:https://ia802309.us.archive.org/25/items/pdfy-MgN0H1joIoDVoIC7/The_AWK_Programming_Language.pdf
|
||||
[22]:http://www.thegeekstuff.com/linux-101-hacks-ebook/
|
||||
[23]:https://ubuntu-manual.org/
|
||||
[24]:http://downtoearthlinux.com/resources/just-tell-me-damnit/
|
||||
[25]:https://drive.google.com/file/d/0B5Ymf8oYXx-PWTVJR0pmM3daZUE/view
|
||||
[26]:https://en.wikipedia.org/wiki/LAMP_(software_bundle)
|
||||
[27]:https://debian-handbook.info/about-the-book/
|
||||
[28]:https://www.lpi.org/our-certifications/getting-started
|
||||
[29]:http://www.nongnu.org/lpi-manuals/manual/pdf/GNU-FDL-OO-LPI-201-0.1.pdf
|
||||
[30]:http://linux-training.be/linuxsys.pdf
|
||||
[31]:http://linux-training.be/
|
||||
[32]:http://linux-training.be/linuxsrv.pdf
|
||||
[33]:http://linux-training.be/linuxnet.pdf
|
||||
[34]:http://linux-training.be/linuxsto.pdf
|
||||
[35]:http://linux-training.be/linuxsec.pdf
|
@ -1,12 +1,17 @@
|
||||
检查 linux 上网络连接的更多方法
|
||||
在 Linux 上检查网络连接的更多方法
|
||||
======
|
||||
ifconfig 和 netstat 命令当然非常有用,但还有很多其他命令能帮你查看 linux 系统上的网络状况。本文探索了一些检查网络连接的非常简便的命令。
|
||||
> 有几个命令可以帮助你在 Linux 系统上看到网络状况,这些包括 ip、ethtool、traceroute、tcptraceroute 和 tcpdump。
|
||||
|
||||
![](https://images.techhive.com/images/article/2016/11/ethernet_cables-100694419-large.jpg)
|
||||
|
||||
`ifconfig` 和 `netstat` 命令当然非常有用,但还有很多其它命令能帮你查看 Linux 系统上的网络状况。本文探索了一些检查网络连接的非常简便的命令。
|
||||
|
||||
### ip 命令
|
||||
|
||||
**ip** 命令显示了许多与你使用 **ifconfig** 命令时的一样信息。其中一些信息以不同的格式呈现,比如使用“192.168.0.6/24”,而不是“inet addr:192.168.0.6 Bcast:192.168.0.255”,尽管 ifconfig 更适合数据包计数,但 ip 命令有许多有用的选项。
|
||||
`ip` 命令显示了许多与你使用 `ifconfig` 命令时的一样信息。其中一些信息以不同的格式呈现,比如显示 `192.168.0.6/24`,而不是 `inet addr:192.168.0.6 Bcast:192.168.0.255`,尽管 `ifconfig` 更适合数据包计数,但 `ip` 命令有许多有用的选项。
|
||||
|
||||
首先,`ip a` 命令可以列出所有网络接口的信息。
|
||||
|
||||
首先,这里是 **ip a** 命令列出的所有网络接口的信息。
|
||||
```
|
||||
$ ip a
|
||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
|
||||
@ -21,39 +26,39 @@ $ ip a
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 fe80::21e:4fff:fec8:43fc/64 scope link
|
||||
valid_lft forever preferred_lft forever
|
||||
|
||||
```
|
||||
|
||||
如果你只想看到简单的网络接口列表,你可以用 **grep** 限制它的输出。
|
||||
如果你只想看到简单的网络接口列表,你可以用 `grep` 限制它的输出。
|
||||
|
||||
```
|
||||
$ ip a | grep inet
|
||||
inet 127.0.0.1/8 scope host lo
|
||||
inet6 ::1/128 scope host
|
||||
inet 192.168.0.6/24 brd 192.168.0.255 scope global eth0
|
||||
inet6 fe80::21e:4fff:fec8:43fc/64 scope link
|
||||
|
||||
```
|
||||
|
||||
使用如下面的命令,你可以看到你的默认路由:
|
||||
|
||||
```
|
||||
$ ip route show
|
||||
default via 192.168.0.1 dev eth0
|
||||
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.6
|
||||
|
||||
```
|
||||
|
||||
在这个输出中,你可以看到通过 eth0 的默认网关是 192.168.0.1,并且本地网络是相当标准的 192.168.0.0/24。
|
||||
在这个输出中,你可以看到通过 `eth0` 的默认网关是 `192.168.0.1`,并且本地网络是相当标准的 `192.168.0.0/24`。
|
||||
|
||||
你也可以使用 `ip` 命令来启用和禁用网络接口。
|
||||
|
||||
你也可以使用 **ip** 命令来启用和禁用网络接口。
|
||||
```
|
||||
$ sudo ip link set eth1 up
|
||||
$ sudo ip link set eth1 down
|
||||
|
||||
```
|
||||
|
||||
### ethtool 命令
|
||||
|
||||
另一个检查网络非常有用的工具是 **ethtool**。这个命令提供了网络接口上的许多描述性的数据。
|
||||
另一个检查网络非常有用的工具是 `ethtool`。这个命令提供了网络接口上的许多描述性的数据。
|
||||
|
||||
```
|
||||
$ ethtool eth0
|
||||
Settings for eth0:
|
||||
@ -79,10 +84,10 @@ Cannot get wake-on-lan settings: Operation not permitted
|
||||
Current message level: 0x00000007 (7)
|
||||
drv probe link
|
||||
Link detected: yes
|
||||
|
||||
```
|
||||
|
||||
你也可以使用 **ethtool** 命令来检查以太网驱动设置。
|
||||
你也可以使用 `ethtool` 命令来检查以太网驱动程序的设置。
|
||||
|
||||
```
|
||||
$ ethtool -i eth0
|
||||
driver: e1000e
|
||||
@ -95,23 +100,22 @@ supports-test: yes
|
||||
supports-eeprom-access: yes
|
||||
supports-register-dump: yes
|
||||
supports-priv-flags: no
|
||||
|
||||
```
|
||||
|
||||
自动协商的详细信息可以用这样的命令来显示:
|
||||
|
||||
```
|
||||
$ ethtool -a eth0
|
||||
Pause parameters for eth0:
|
||||
Autonegotiate: on
|
||||
RX: on
|
||||
TX: on
|
||||
|
||||
```
|
||||
|
||||
### traceroute 命令
|
||||
|
||||
`traceroute` 命令用于显示路由路径。它通过在一系列数据包中设置数据包头的 TTL(生存时间)字段来捕获数据包所经过的路径,以及数据包从一跳到下一跳需要的时间。`traceroute` 的输出有助于评估网络连接的健康状况,因为某些路由可能需要花费更长的时间才能到达最终的目的地。
|
||||
|
||||
**traceroute** 命令显示路由路径。它通过在一系列数据包中设置数据包头的TTL(生存时间)字段来捕获数据包所经过的路径,以及数据包从一跳到下一跳需要的时间。Traceroute 的输出有助于评估网络连接的健康状况,因为某些路由可能需要花费更长的时间才能到达最终的目的地。
|
||||
```
|
||||
$ sudo traceroute world.std.com
|
||||
traceroute to world.std.com (192.74.137.5), 30 hops max, 60 byte packets
|
||||
@ -130,16 +134,16 @@ traceroute to world.std.com (192.74.137.5), 30 hops max, 60 byte packets
|
||||
13 69.38.149.18 (69.38.149.18) 44.955 ms 46.210 ms 55.673 ms
|
||||
14 64.119.137.154 (64.119.137.154) 56.076 ms 56.064 ms 56.052 ms
|
||||
15 world.std.com (192.74.137.5) 63.440 ms 63.886 ms 63.870 ms
|
||||
|
||||
```
|
||||
|
||||
### tcptraceroute 命令
|
||||
|
||||
**tcptraceroute** 命令与 traceroute 基本上是一样的,只是它能够绕过最常见的防火墙的过滤。正如该命令的手册页所述,tcptraceroute 发送 TCP SYN 数据包而不是 UDP 或 ICMP ECHO 数据包,所以其不易被阻塞。
|
||||
`tcptraceroute` 命令与 `traceroute` 基本上是一样的,只是它能够绕过最常见的防火墙的过滤。正如该命令的手册页所述,`tcptraceroute` 发送 TCP SYN 数据包而不是 UDP 或 ICMP ECHO 数据包,所以其不易被阻塞。
|
||||
|
||||
### tcpdump 命令
|
||||
|
||||
**tcpdump** 命令允许你捕获网络数据包来进一步分析。使用 -D 选项列出可用的网络接口。
|
||||
`tcpdump` 命令允许你捕获网络数据包来进一步分析。使用 `-D` 选项列出可用的网络接口。
|
||||
|
||||
```
|
||||
$ tcpdump -D
|
||||
1.eth0 [Up, Running]
|
||||
@ -154,10 +158,10 @@ $ tcpdump -D
|
||||
10.usbmon5 (USB bus number 5)
|
||||
11.usbmon6 (USB bus number 6)
|
||||
12.usbmon7 (USB bus number 7)
|
||||
|
||||
```
|
||||
|
||||
-v(verbose)选项控制你看到的细节程度--越多的 v,越详细,但超过 3 个 v 不会有更多意义。
|
||||
`-v` 选项控制你看到的细节程度——越多的 `v`,越详细,但超过 3 个 `v` 不会有更多意义。
|
||||
|
||||
```
|
||||
$ sudo tcpdump -vv host 192.168.0.32
|
||||
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
|
||||
@ -169,12 +173,11 @@ tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 byt
|
||||
192.168.0.32.57294 > 192.168.0.6.ssh: Flags [.], cksum 0x643d (correct), seq 1, ack 304, win 385, length 0
|
||||
20:26:31.383954 IP (tos 0x10, ttl 64, id 22413, offset 0, flags [DF], proto TCP (6), length 248)
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
当你运行像这样的命令时,会看到非常多的输出。
|
||||
当你运行像这样的命令时,会看到**非常多**的输出。
|
||||
|
||||
这个命令捕获来自特定主机和 eth0 上的 11 个数据包。-w 选项标识保存捕获包的文件。在这个示例命令中,我们只要求捕获 11 个数据包。
|
||||
这个命令捕获来自特定主机和 `eth0` 上的 `11` 个数据包。`-w` 选项标识保存捕获包的文件。在这个示例命令中,我们只要求捕获 `11` 个数据包。
|
||||
|
||||
```
|
||||
$ sudo tcpdump -c 11 -i eth0 src 192.168.0.32 -w packets.pcap
|
||||
@ -182,21 +185,19 @@ tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 byt
|
||||
11 packets captured
|
||||
11 packets received by filter
|
||||
0 packets dropped by kernel
|
||||
|
||||
```
|
||||
|
||||
### arp 命令
|
||||
|
||||
arp 命令将 IPv4 地址映射到硬件地址。它所提供的信息也可以在一定程度上用于识别系统,因为网络适配器可以告诉你使用它们的系统的一些信息。下面的第二个MAC 地址,从 f8:8e:85 开始,很容易被识别为 Comtrend 路由器。
|
||||
`arp` 命令将 IPv4 地址映射到硬件地址。它所提供的信息也可以在一定程度上用于识别系统,因为网络适配器可以告诉你使用它们的系统的一些信息。下面的第二个 MAC 地址,以 `f8:8e:85` 开头,很容易被识别出是 Comtrend 路由器。
|
||||
|
||||
```
|
||||
$ arp -a
|
||||
? (192.168.0.12) at b0:c0:90:3f:10:15 [ether] on eth0
|
||||
? (192.168.0.1) at f8:8e:85:35:7f:b9 [ether] on eth0
|
||||
|
||||
```
|
||||
|
||||
上面的第一行显示了系统本身的网络适配器的 MAC 地址。该网络适配器似乎已由台湾 Chicony 电子公司制造。你可以很容易地在网上查找 MAC 地址关联,例如来自 Wireshark 的这个工具 -- https://www.wireshark.org/tools/oui-lookup.html
|
||||
上面的第一行显示了系统本身的网络适配器的 MAC 地址。该网络适配器似乎已由台湾 Chicony 电子公司制造。你可以很容易地在网上查找 MAC 地址关联,例如来自 Wireshark 的这个工具 —— https://www.wireshark.org/tools/oui-lookup.html 。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -204,7 +205,7 @@ via: https://www.networkworld.com/article/3233306/linux/more-ways-to-examine-net
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
译者:[kimii](https://github.com/kimii)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,135 @@
|
||||
如何在 Linux/Unix 之上绑定 ntpd 到特定的 IP 地址
|
||||
======
|
||||
|
||||
默认的情况下,我们的 ntpd/NTP 服务器会监听所有的端口或者 IP 地址,也就是:`0.0.0.0:123`。 怎么才可以在一个 Linux 或是 FreeBSD Unix 服务器上,确保只监听特定的 IP 地址,比如 `localhost` 或者是 `192.168.1.1:123` ?
|
||||
|
||||
NTP 是<ruby>网络时间协议<rt>Network Time Protocol</rt></ruby>的首字母简写,这是一个用来同步两台电脑之间时间的协议。ntpd 是一个操作系统守护进程,可以设置并且保证系统的时间与互联网标准时间服务器同步。
|
||||
|
||||
[![如何在 Linux 和 Unix 服务器,防止 NTPD 监听 0.0.0.0:123 并将其绑定到特定的 IP 地址][1]][1]
|
||||
|
||||
NTP 使用 `/etc/directory` 之下的 `ntp.conf` 作为配置文件。
|
||||
|
||||
### /etc/ntp.conf 之中的端口指令
|
||||
|
||||
你可以通过设置端口命令来防止 ntpd 监听 `0.0.0.0:123`,语法如下:
|
||||
|
||||
```
|
||||
interface listen IPv4|IPv6|all
|
||||
interface ignore IPv4|IPv6|all
|
||||
interface drop IPv4|IPv6|all
|
||||
```
|
||||
|
||||
上面的配置可以使 `ntpd` 监听那个地址或者不出来任何请求而直接丢弃。`ignore` 会防止打开匹配的地址,`drop` 会导致 ntpd 打开该地址并丢弃所有接收到的包,而不做任何检查。举个例子,如果要忽略所有端口之上的监听,加入下面的语句到 `/etc/ntp.conf`:
|
||||
|
||||
```
|
||||
interface ignore wildcard
|
||||
```
|
||||
|
||||
如果只监听 127.0.0.1 和 192.168.1.1 则是这样:
|
||||
|
||||
```
|
||||
interface listen 127.0.0.1
|
||||
interface listen 192.168.1.1
|
||||
```
|
||||
|
||||
这是我 FreeBSD 云服务器上的样例 `/etc/ntp.conf` 文件:
|
||||
|
||||
```
|
||||
$ egrep -v '^#|$^' /etc/ntp.conf
|
||||
```
|
||||
|
||||
样例输出为:
|
||||
|
||||
```
|
||||
tos minclock 3 maxclock 6
|
||||
pool 0.freebsd.pool.ntp.org iburst
|
||||
restrict default limited kod nomodify notrap noquery nopeer
|
||||
restrict -6 default limited kod nomodify notrap noquery nopeer
|
||||
restrict source limited kod nomodify notrap noquery
|
||||
restrict 127.0.0.1
|
||||
restrict -6 ::1
|
||||
leapfile "/var/db/ntpd.leap-seconds.list"
|
||||
interface ignore wildcard
|
||||
interface listen 172.16.3.1
|
||||
interface listen 10.105.28.1
|
||||
```
|
||||
|
||||
### 重启 ntpd
|
||||
|
||||
在 FreeBSD Unix 之上重新加载/重启 ntpd:
|
||||
|
||||
```
|
||||
$ sudo /etc/rc.d/ntpd restart
|
||||
```
|
||||
|
||||
或者 [在 Debian 和 Ubuntu Linux 之上使用下面的命令][2]:
|
||||
|
||||
```
|
||||
$ sudo systemctl restart ntp
|
||||
```
|
||||
|
||||
或者 [在 CentOS/RHEL 7/Fedora Linux 之上使用下面的命令][2]:
|
||||
|
||||
```
|
||||
$ sudo systemctl restart ntpd
|
||||
```
|
||||
|
||||
### 校验
|
||||
|
||||
使用 `netstat` 和 `ss` 命令来检查 ntpd 只绑定到了特定的 IP 地址:
|
||||
|
||||
```
|
||||
$ netstat -tulpn | grep :123
|
||||
```
|
||||
|
||||
或是:
|
||||
|
||||
```
|
||||
$ ss -tulpn | grep :123
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
udp 0 0 10.105.28.1:123 0.0.0.0:* -
|
||||
udp 0 0 172.16.3.1:123 0.0.0.0:* -
|
||||
```
|
||||
|
||||
[在 FreeBSD Unix 服务器上使用 sockstat 命令][3]:
|
||||
|
||||
```
|
||||
$ sudo sockstat
|
||||
$ sudo sockstat -4
|
||||
$ sudo sockstat -4 | grep :123
|
||||
```
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
root ntpd 59914 22 udp4 127.0.0.1:123 *:*
|
||||
root ntpd 59914 24 udp4 127.0.1.1:123 *:*
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
作者是 nixCraft 的创始人并且是一位经验丰富的系统管理员、DevOps 工程师,也是一名 Linux 操作系统和 Unix shell 脚本的训练师。他为全球不同行业,包括 IT、教育业、安全防护、空间研究和非营利性组织的客户工作。关注他的 [Twitter][4], [Facebook][5], [Google+][6]。
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.cyberciti.biz/faq/how-to-bind-ntpd-to-specific-ip-addresses-on-linuxunix/
|
||||
|
||||
作者:[Vivek Gite][a]
|
||||
译者:[Drshu](https://github.com/Drshu)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.cyberciti.biz
|
||||
[1]:https://www.cyberciti.biz/media/new/faq/2017/10/how-to-prevent-ntpd-to-listen-on-all-interfaces-on-linux-unix-box.jpg
|
||||
[2]:https://www.cyberciti.biz/faq/restarting-ntp-service-on-linux/
|
||||
[3]:https://www.cyberciti.biz/faq/freebsd-unix-find-the-process-pid-listening-on-a-certain-port-commands/
|
||||
[4]:https://twitter.com/nixcraft
|
||||
[5]:https://facebook.com/nixcraft
|
||||
[6]:https://plus.google.com/+CybercitiBiz
|
165
published/20171117 How to Install and Use Docker on Linux.md
Normal file
165
published/20171117 How to Install and Use Docker on Linux.md
Normal file
@ -0,0 +1,165 @@
|
||||
在 Linux 上安装和使用 Docker
|
||||
======
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/use-containers.jpg?itok=s3YLmYHs)
|
||||
|
||||
容器现在风靡于 IT 界 —— 这很好理解。容器是轻量级的,包含应用运行所需所有东西(代码、库、运行时环境、系统设置,以及依赖关系)的独立的包。每个容器都部署于它自己的 CPU、内存、块 I/O,以及网络资源上,所有这些都不依赖于某个内核和操作系统。这也是容器与虚拟机之间最大的不同;相比之下,虚拟机是一个运行于宿主机操作系统上的完整的操作系统平台,而容器不是。
|
||||
|
||||
容器允许你以一种前所未有的方式扩展交付能力(不管内部还是外部的)。例如,你可以快速部署多个 NGINX 实例(甚至可以应用于多个不同的阶段 —— 比如开发和生产阶段)。跟虚拟机不同,容器不会消耗太多系统资源。
|
||||
|
||||
[Docker][1] 使得创建、部署,和管理容器变得特别简单。更好的是,安装和使用 Docker 在 Linux 平台上特别的方便。
|
||||
|
||||
我将会向你演示在 Linux 上安装 Docker 是多么方便,同时带你入门 Docker。我的演示平台是 [Ubuntu 16.04 Server][2],但流程在大多数其它 Linux 平台都差不多。
|
||||
|
||||
我这里假设你已经启动了 Ubuntu Server 16.04。
|
||||
|
||||
### 安装
|
||||
|
||||
由于 Ubuntu Server 16.04 缺少图形界面,我会完全通过命令行来安装和使用 Docker。在你安装前,你需要更新 `apt` 然后进行必要的升级。一定要注意,若系统内核升级了,你会需要重启系统。因此最好挑个服务器能重启的时间进行。
|
||||
|
||||
运行下面命令更新 `apt`:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
完成后,使用命令升级系统:
|
||||
|
||||
```
|
||||
sudo apt upgrade
|
||||
```
|
||||
|
||||
若内核升级了,你需要用下面命令重启服务器:
|
||||
|
||||
```
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
若内核没有升级,你就可以安装 Docker 了(无需重启)。安装 Docker 的命令为:
|
||||
|
||||
```
|
||||
sudo apt install docker.io
|
||||
```
|
||||
|
||||
若你使用的是其它 Linux 发行版,当尝试用相应的包管理器来安装时却发现没有 `docker.io` 包,则你应该安装 `docker` 包。例如,在 [Fedora][3] 上安装应该用命令:
|
||||
|
||||
```
|
||||
sudo dnf install docker
|
||||
```
|
||||
|
||||
若你使用的是 CentOS 7,那么最好使用安装脚本来安装 docker。首先使用命令 `sudo yum check-update` 更新系统。升级完后,输入下面命令来下载并运行所需的脚本:
|
||||
|
||||
```
|
||||
curl -fsSL https://get.docker.com/ | sh
|
||||
```
|
||||
|
||||
默认情况下,只有管理员权限能够运行 docker 命令。考虑到安全问题,你不会想用 root 用户或使用 `sudo` 来运行 Docker 的。要解决这个问题,你需要将自己的用户加入到 docker 组中。命令如下:
|
||||
|
||||
```
|
||||
sudo usermod -a -G docker $USER
|
||||
```
|
||||
|
||||
完成操作后,登出系统然后再重新登录,应该就搞定了。不过若你的平台是 Fedora,则添加用户到 docker 组时会发现这个组是不存在的。那该怎么办呢?你需要首先创建这个组。命令如下:
|
||||
|
||||
```
|
||||
sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
登出后再登录。就可以开始用 Docker 了。
|
||||
|
||||
### 启动,暂停以及启用 Docker
|
||||
|
||||
安装好 Docker 后,你可以让系统在启动时自动启动 Docker 守护进程。使用下面两个命令来实现这一点:
|
||||
|
||||
```
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
```
|
||||
|
||||
若需要暂停或重启 Docker 守护进程,则命令为:
|
||||
|
||||
```
|
||||
sudo systemctl stop docker
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
现在可以用 Docker 来部署容器了。
|
||||
|
||||
### 拉取镜像
|
||||
|
||||
对 Docker 来说,镜像是构建容器的基石。你可以拉下一个镜像(比如 [NGINX][4])然后根据这个镜像部署任意多个容器出来。使用镜像前,你首先需要把镜像拉取到系统中。镜像从注册仓库中拉取,默认情况下安装好的 Docker 包含了一个默认的注册仓库 [Docker Hub][5] —— 这个注册仓库包含了大量别人所贡献的镜像(既包括官方的镜像,也包括用户自己贡献的镜像)。
|
||||
|
||||
假设你想要拉取一个 Nginx Web 服务器相关的镜像。在开始拉取前,先检查一下系统中已经有了哪些镜像。输入 `docker images` 命令你会发现现在还没有镜像存在(图 1)。
|
||||
|
||||
![Docker][7]
|
||||
|
||||
*图 1:还没有镜像。*
|
||||
|
||||
让我们来拉取一个镜像。使用下面命令可以从 Docker Hub 中下载 Nginx 镜像:
|
||||
|
||||
```
|
||||
docker pull nginx
|
||||
```
|
||||
|
||||
上面命令会从 Docker Hub 下载最新的(官方的) Nginx 镜像。现在再运行 `docker images` 命令就能看到有列出镜像了(图 2)。
|
||||
|
||||
![Docker][10]
|
||||
|
||||
*图 2:NGINX 镜像已经被拉取下来了。*
|
||||
|
||||
注意到我这里说的是“官方” Nginx 镜像了吗?在 Docker Hub 上有很多的非官方 Nginx 镜像。这些非官方镜像都是基于各种不同的目的而创建出来的。你可以使用下面过命令来搜索 Docker Hub 中的所有 Nginx 镜像:
|
||||
|
||||
```
|
||||
docker search nginx
|
||||
```
|
||||
|
||||
你会发现(图 3 中),有很多基于不同目的所创建的 Nginx 镜像(反向代理、PHP-FPM(LCTT 译注:<ruby>FastCGI 进程管理器<rt>FastCGI Process Manager</rt></ruby>是一个 PHPFastCGI 管理器,旨在将 FastCGI 进程管理整合进 PHP 包中)功能、LetsEncrypt(LCTT 译注:由 ISRG 提供的免费 SSL 项目),Bitnami,在树莓派上使用的 Nginx 和 Drupal,等等很多很多)。
|
||||
|
||||
![Docker hub][12]
|
||||
|
||||
*图 3:Docker Hub 上找到的各种 NGINX 镜像。*
|
||||
|
||||
假设,你想要下载内建有反向代理功能的 Nginx 镜像,有个非官方的镜像 jwilder/nginx-proxy。因此输入下面命令来拉取这个镜像:
|
||||
|
||||
```
|
||||
docker pull jwilder/nginx-proxy
|
||||
```
|
||||
|
||||
再输入 `docker images` 命令来查看新拉下来的这个镜像(图 4)。
|
||||
|
||||
![Nginx][14]
|
||||
|
||||
*图 4:已经有了两种不同的 NGINX 镜像了。*
|
||||
|
||||
处于谨慎考虑,我建议只使用官方镜像,毕竟你无法确定非官方镜像是否包含了恶意代码。
|
||||
|
||||
有了镜像后就可以用它来部署容器了。下次我们再聊聊如何通过这些 Nginx 镜像来发布容器。
|
||||
|
||||
Docker 是一个超级强力的系统可以让你的工作更简单,让你的公司更具有伸缩性,也更灵活。想知道 Docker 还能做什么,运行 `man docker` 然后阅读它的帮助文档吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux
|
||||
|
||||
作者:[Jack Wallen][a]
|
||||
译者:[lujun9972](https://github.com/lujun9972)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linux.com/users/jlwallen
|
||||
[1]:https://www.docker.com/
|
||||
[2]:http://releases.ubuntu.com/16.04/
|
||||
[3]:https://getfedora.org/
|
||||
[4]:https://www.nginx.com/
|
||||
[5]:https://hub.docker.com/
|
||||
[6]:/files/images/docker1jpg
|
||||
[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_1.jpg?itok=CxSyyXyF (Docker)
|
||||
[8]:/licenses/category/used-permission
|
||||
[9]:/files/images/docker2jpg
|
||||
[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_2.jpg?itok=TESa7bYr (Docker)
|
||||
[11]:/files/images/docker3jpg
|
||||
[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_3.jpg?itok=_7F4QWqx (Docker hub)
|
||||
[13]:/files/images/docker4jpg
|
||||
[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_4.jpg?itok=f13E1L0Q (Nginx)
|
@ -7,7 +7,7 @@
|
||||
|
||||
### 要求
|
||||
|
||||
* 了解标准的 Unix / Linux 权限系统
|
||||
* 了解标准的 Unix / Linux 权限系统
|
||||
|
||||
### 难度
|
||||
|
||||
@ -15,55 +15,49 @@
|
||||
|
||||
### 约定
|
||||
|
||||
* **#** \- 要求直接以 root 用户或使用 `sudo` 命令执行指定的命令
|
||||
* **$** \- 用普通的非特权用户来执行指定的命令
|
||||
* `#` - 要求直接以 root 用户或使用 `sudo` 命令执行指定的命令
|
||||
* `$` - 用普通的非特权用户来执行指定的命令
|
||||
|
||||
### 介绍
|
||||
|
||||
通常,在类 Unix 操作系统上,文件和目录的所有权是基于文件创建者的默认 `uid`(user-id)和 `gid`(group-id)的。启动一个进程时也是同样的情况:它以启动它的用户的 uid 和 gid 运行,并具有相应的权限。这种行为可以通过使用特殊的权限进行改变。
|
||||
通常,在类 Unix 操作系统上,文件和目录的所有权是基于文件创建者的默认 `uid`(user-id)和 `gid`(group-id)的。启动一个进程时也是同样的情况:它以启动它的用户的 `uid` 和 `gid` 运行,并具有相应的权限。这种行为可以通过使用特殊的权限进行改变。
|
||||
|
||||
### setuid 位
|
||||
|
||||
当使用 setuid 位时,之前描述的行为会有所变化,所以当一个可执行文件启动时,它不会以启动它的用户的权限运行,而是以该文件所有者的权限运行。所以,如果在一个可执行文件上设置了 setuid 位,并且该文件由 root 拥有,当一个普通用户启动它时,它将以 root 权限运行。显然,如果 setuid 位使用不当的话,会带来潜在的安全风险。
|
||||
当使用 setuid (设置用户 ID)位时,之前描述的行为会有所变化,所以当一个可执行文件启动时,它不会以启动它的用户的权限运行,而是**以该文件所有者的权限运行**。所以,如果在一个可执行文件上设置了 setuid 位,并且该文件由 root 拥有,当一个普通用户启动它时,它将以 root 权限运行。显然,如果 setuid 位使用不当的话,会带来潜在的安全风险。
|
||||
|
||||
使用 setuid 权限的可执行文件的例子是 `passwd`,我们可以使用该程序更改登录密码。我们可以通过使用 `ls` 命令来验证:
|
||||
|
||||
```
|
||||
|
||||
ls -l /bin/passwd
|
||||
-rwsr-xr-x. 1 root root 27768 Feb 11 2017 /bin/passwd
|
||||
|
||||
```
|
||||
|
||||
如何识别 `setuid` 位呢?相信您在上面命令的输出已经注意到,`setuid` 位是用 `s` 来表示的,代替了可执行位的 `x`。小写的 `s` 意味着可执行位已经被设置,否则你会看到一个大写的 `S`。大写的 `S` 发生于当设置了 `setuid` 或 `setgid` 位、但没有设置可执行位 `x` 时。它用于提醒用户这个矛盾的设置:如果可执行位未设置,则 `setuid` 和 `setgid` 位均不起作用。setuid 位对目录没有影响。
|
||||
|
||||
### setgid 位
|
||||
|
||||
与 `setuid` 位不同,`setgid` 位对文件和目录都有影响。在第一个例子中,具有 `setgid` 位设置的文件在执行时,不是以启动它的用户所属组的权限运行,而是以拥有该文件的组运行。换句话说,进程的 gid 与文件的 gid 相同。
|
||||
与 `setuid` 位不同,`setgid` (设置组 ID)位对文件和目录都有影响。在第一个例子中,具有 `setgid` 位设置的文件在执行时,不是以启动它的用户所属组的权限运行,而是**以拥有该文件的组运行**。换句话说,进程的 `gid` 与文件的 `gid` 相同。
|
||||
|
||||
当在一个目录上使用时,`setgid` 位与一般的行为不同,它使得在所述目录内创建的文件,不属于创建者所属的组,而是属于父目录所属的组。这个功能通常用于文件共享(目录所属组中的所有用户都可以修改文件)。就像 setuid 一样,setgid 位很容易识别(我们用 test 目录举例):
|
||||
|
||||
```
|
||||
|
||||
ls -ld test
|
||||
drwxrwsr-x. 2 egdoc egdoc 4096 Nov 1 17:25 test
|
||||
|
||||
```
|
||||
|
||||
这次 `s` 出现在组权限的可执行位上。
|
||||
|
||||
### sticky 位
|
||||
|
||||
Sticky 位的工作方式有所不同:它对文件没有影响,但当它在目录上使用时,所述目录中的所有文件只能由其所有者删除或移动。一个典型的例子是 `/tmp` 目录,通常系统中的所有用户都对这个目录有写权限。所以,设置 sticky 位使用户不能删除其他用户的文件:
|
||||
sticky (粘连)位的工作方式有所不同:它对文件没有影响,但当它在目录上使用时,所述目录中的所有文件只能由其所有者删除或移动。一个典型的例子是 `/tmp` 目录,通常系统中的所有用户都对这个目录有写权限。所以,设置 sticky 位使用户不能删除其他用户的文件:
|
||||
|
||||
```
|
||||
|
||||
$ ls -ld /tmp
|
||||
drwxrwxrwt. 14 root root 300 Nov 1 16:48 /tmp
|
||||
|
||||
```
|
||||
|
||||
在上面的例子中,目录所有者、组和其他用户对该目录具有完全的权限(读、写和执行)。Sticky 位在可执行位上用 `t` 来标识。同样,小写的 `t` 表示可执行权限 `x`也被设置了,否则你会看到一个大写字母 `T`。
|
||||
在上面的例子中,目录所有者、组和其他用户对该目录具有完全的权限(读、写和执行)。sticky 位在可执行位上用 `t` 来标识。同样,小写的 `t` 表示可执行权限 `x`也被设置了,否则你会看到一个大写字母 `T`。
|
||||
|
||||
### 如何设置特殊权限位
|
||||
|
||||
@ -87,7 +81,7 @@ $ chmod g+s test
|
||||
$ chmod u+s file
|
||||
```
|
||||
|
||||
要设置 Sticky 位,可运行:
|
||||
要设置 sticky 位,可运行:
|
||||
|
||||
```
|
||||
$ chmod o+t test
|
||||
@ -101,7 +95,7 @@ via: https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-an
|
||||
|
||||
作者:[Egidio Docile][a]
|
||||
译者:[jessie-pang](https://github.com/jessie-pang)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,11 +1,11 @@
|
||||
Linux mkdir 命令的初学者教程
|
||||
======
|
||||
|
||||
当你使用命令行的时候,无论什么时候,你都位于一个目录中,它告诉了命令行当前所位于的完整目录。在 Linux 中,你可以使用 `rm` 命令删除目录,但是首先,你需要使用 `mkdir` 命令来创建目录。在这篇教程中,我将使用一些易于理解的例子来讲解这个工具的基本用法。
|
||||
当你使用命令行的时候,无论什么时候,你都位于一个目录中,它告诉了命令行当前所位于的完整目录。在 Linux 中,你可以使用 [rm][10] 命令删除目录,但是首先,你需要使用 `mkdir` 命令来创建目录。在这篇教程中,我将使用一些易于理解的例子来讲解这个工具的基本用法。
|
||||
|
||||
在开始之前,值得一提的是,这篇教程中的所有例子都已经在 Ubuntu 16.04 LTS 中测试过。
|
||||
|
||||
### Linux `mkdir` 命令
|
||||
### Linux mkdir 命令
|
||||
|
||||
正如上面所提到的,用户可以使用 `mkdir` 命令来创建目录。它的语法如下:
|
||||
|
||||
@ -14,11 +14,10 @@ mkdir [OPTION]... DIRECTORY...
|
||||
```
|
||||
|
||||
下面的内容是 man 手册对这个工具的描述:
|
||||
```
|
||||
Create the DIRECTORY(ies), if they do not already exist.
|
||||
```
|
||||
|
||||
下面这些问答式的例子将能够帮助你更好的理解 `mkdir` 这个命令是如何工作的。
|
||||
> 如果目录还不存在,则创建之。
|
||||
|
||||
下面这些 Q&A 式的例子将能够帮助你更好的理解 `mkdir` 这个命令是如何工作的。
|
||||
|
||||
### Q1. 如何使用 `mkdir` 命令创建目录?
|
||||
|
||||
@ -44,7 +43,7 @@ mkdir test-dir
|
||||
mkdir -p dir1/dir2/dir3
|
||||
```
|
||||
|
||||
[![How to make sure parent directories \(if non-existent\) are created][1]][2]
|
||||
[![How to make sure parent directories (if non-existent) are created][1]][2]
|
||||
|
||||
### Q3. 如何在创建目录时自定义权限?
|
||||
|
||||
@ -79,7 +78,7 @@ via: https://www.howtoforge.com/linux-mkdir-command/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[ucasFL](https://github.com/ucasFL)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@ -93,3 +92,4 @@ via: https://www.howtoforge.com/linux-mkdir-command/
|
||||
[7]:https://www.howtoforge.com/images/command-tutorial/mkdir-verbose.png
|
||||
[8]:https://www.howtoforge.com/images/command-tutorial/big/mkdir-verbose.png
|
||||
[9]:https://linux.die.net/man/1/mkdir
|
||||
[10]:https://linux.cn/article-9321-1.html
|
@ -0,0 +1,79 @@
|
||||
为初学者准备的 Linux rmdir 命令案例教程
|
||||
======
|
||||
|
||||
在 Linux 命令行上删除文件和目录,我们已经讨论过 [rm 命令][1] 的使用。然而,这里有另一个相关的命令行工具,专门针对目录的删除。这是所指的工具就是 `rmdir`,本教程中,我们将根据一些简单的实例来讨论它。
|
||||
|
||||
### Linux rmdir 命令
|
||||
|
||||
见名知意,`rmdir`(remove directory) 命令专门针对删除目录,不过通常目录内空空如也。如下是它的语法:
|
||||
|
||||
```
|
||||
rmdir [OPTION]... DIRECTORY...
|
||||
```
|
||||
|
||||
下面是 man 文档的说明:
|
||||
|
||||
> 如目录为空,则删除之。
|
||||
|
||||
在理解此程序如何工作,下面的 Q&A 风格的案例可能会给您带来更好的灵感。
|
||||
|
||||
### Q1. rmdir 命令如何工作?
|
||||
|
||||
这非常直接,只需将目录名作为输入参数传递给它。
|
||||
|
||||
比如:
|
||||
|
||||
```
|
||||
rmdir test-dir
|
||||
```
|
||||
|
||||
[![rmdir 命令如何工作][2]][3]
|
||||
|
||||
### Q2. 如何让 rmdir 忽略非空目录?
|
||||
|
||||
通常情况下,`rmdir` 命令会在您删除非空目录时抛出一个错误。然而,如果需要的话,您可以使用 `--ignore-fail-on-non-empty` 选项,忽略它。
|
||||
|
||||
比如说:
|
||||
|
||||
[![如何让 rmdir 忽视非空目录][4]][5]
|
||||
|
||||
### Q3. 如何让 rmdir 命令移除父目录?
|
||||
|
||||
和 [mkdir][6] 一样,您可以通过要求 `rmdir` 命令在其父目录执行操作。这意味着,您可以一次性删除目录和目录的上级目录。这个功能可以通过 `-p` 命令选项实现。
|
||||
|
||||
比如,下面的命令将会删除 “test” 和 “test-dir” 目录。
|
||||
|
||||
```
|
||||
rmdir -p test/test-dir/
|
||||
```
|
||||
|
||||
注意: 欲此操作生效,所有被删除的父目录都不应该包含要被删除的空目录之外的任何目录。
|
||||
|
||||
### Q4. rmdir 和 rm -r 有何区别?
|
||||
|
||||
如果还有印象,您还可以通过提供 `-r` 选项的 `rm` 命令删除目录。那 `rmdir` 和 `rm -r` 区别何在?`rmdir` 仅对空目录生效 —— 您没有办法使用 rmdir 删除非空目录。
|
||||
|
||||
因此,`rmdir` 在删除需要检测目录是否为空的情况下,是一个有效的工具。
|
||||
|
||||
### 总结
|
||||
|
||||
相信您会认同,`rmdir` 并不是一个难以理解和使用的复杂命令。除此之外,它仅提供少量命令行选项。在此,我们几乎讨论了所有的选项,如果您想掌握的更好,练习在本教程提到的案例即可。关于 `rmdir`,[这里另有 man 文档][7],备您不时之需。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/linux-rmdir-command/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[CYLeft](https://github.com/CYLeft)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com
|
||||
[1]:https://linux.cn/article-9321-1.html
|
||||
[2]:https://www.howtoforge.com/images/command-tutorial/rm-basic-usage1.png
|
||||
[3]:https://www.howtoforge.com/images/command-tutorial/big/rm-basic-usage1.png
|
||||
[4]:https://www.howtoforge.com/images/command-tutorial/rmdir-ignore-nonempty.png
|
||||
[5]:https://www.howtoforge.com/images/command-tutorial/big/rmdir-ignore-nonempty.png
|
||||
[6]:https://linux.cn/article-9356-1.html
|
||||
[7]:https://linux.die.net/man/1/rmdir
|
@ -1,112 +0,0 @@
|
||||
6 Best Open Source Alternatives to Microsoft Office for Linux
|
||||
======
|
||||
**Brief: Looking for Microsoft Office in Linux? Here are the best free and open source alternatives to Microsoft Office for Linux.**
|
||||
|
||||
Office Suites are a mandatory part of any operating system. It is difficult to imagine using a desktop OS without office software. While Windows has MS Office Suite and Mac OS X has its own iWork apart from lots of other Office Suites especially meant for these OS, Linux too has some arrows in its quiver.
|
||||
|
||||
In this article, I list the best Microsoft Office alternatives for Linux.
|
||||
|
||||
## Best open source alternatives to Microsoft Office for Linux
|
||||
|
||||
![Best Microsoft office alternatives for Linux][1]
|
||||
|
||||
Before we see the MS Office alternatives, let's first see what you look for in a decent office suite:
|
||||
|
||||
* Word processor
|
||||
* Spreadsheet
|
||||
* Presentation
|
||||
|
||||
|
||||
|
||||
I know that Microsoft Office offers a lot more than these three tools but in reality, you would be using these three tools most of the time. It's not that open source office suites are restricted to have only these three products. Some of them offer additional tools as well but our focus would be on the above-mentioned tools.
|
||||
|
||||
Let's see what office suits for Linux have we got here:
|
||||
|
||||
### 6. Apache OpenOffice
|
||||
|
||||
![OpenOffice Logo][2]
|
||||
|
||||
[Apache OpenOffice][3] or simply OpenOffice has a history of name/owner change. It was born as Star Office in 1999 by Sun Microsystems which later renamed it as OpenOffice to pit it against MS Office as a free and open source alternative. When Oracle bought Sun in 2010, it discontinued the development of OpenOffice after a year. And finally it was Apache who supported it and it is now known as Apache OpenOffice.
|
||||
|
||||
Apache OpenOffice is available for a number of platforms that includes Linux, Windows, Mac OS X, Unix, BSD. It also includes support for MS Office files apart from its own OpenDocument format. The office suite contains the following applications: Writer, Calc, Impress, Base, Draw, Math.
|
||||
|
||||
[Installing OpenOffice][4] is a pain as it doesn't provide a decent installer. Also, there are rumors that [OpenOffice development might have been stalled][5]. These two are the main reasons why I wouldn't recommend it. I listed it here more for historical purposes.
|
||||
|
||||
### 5. Feng Office
|
||||
|
||||
![Feng Office logo][6]
|
||||
|
||||
[Feng Office][7] was previously known as OpenGoo. It is not your regular office suite. It is entirely focused on being an online office suite like Google Docs. In other words, it's an open source [collaboration platform][8].
|
||||
|
||||
There is no desktop version available so if you are looking to using it on a single Linux desktop, you are out of luck here. On the other hand, if you have a small business, an institution or some other organization, you may try to deploy it on the local server.
|
||||
|
||||
### 4. Siag Office
|
||||
|
||||
![SIAG Office logo][9]
|
||||
|
||||
[Siag][10] is an extremely lightweight office suite for Unix-Like systems that can be run on a 16 MB system. Since it is very light-weight, it lacks many of the features that are found in a standard office suite. But small is beautiful, ain't it? It has all the necessary function of an office suite that could "just work" on [lightweight Linux distributions][11]. It comes by default in [Damn Small Linux][12].
|
||||
|
||||
### 3. Calligra Suite
|
||||
|
||||
![Calligra free and Open Source office logo][13]
|
||||
|
||||
[Calligra][14], previously known as KOffice, is the default Office suite in KDE. It is available for Linux and FreeBSD system with support for Mac OS X and Windows. It was also [launched for Android][15]. but unfortunately, it's not available for Android anymore. It has all the application needed for an office suite along with some extra applications such as Flow for flow charts and Plane for project management.
|
||||
|
||||
Calligra has generated quite a noise after their recent developments and it may be seen as an [alternative to LibreOffice][16].
|
||||
|
||||
### 2. ONLYOFFICE
|
||||
|
||||
![ONLYOFFICE is Linux alternative to Microsoft Office][17]
|
||||
|
||||
Relatively a new player in the market, [ONLYOFFICE][18] is an office suite more focused on the [collaborative][8] part. Enterprises (and even individuals) can deploy it on their own server to have a Google Docs like collaborative office suite.
|
||||
|
||||
Don't worry. You don't have to bother about installing it on a server. There is a free and [open source desktop version of ONLYOFFICE][19]. You can even get .deb and .rpm binaries to easily install it on your desktop Linux system.
|
||||
|
||||
### 1. LibreOffice
|
||||
|
||||
![LibreOffice logo][20]
|
||||
|
||||
When Oracle decided to discontinue the development of OpenOffice, it was [The Document Foundation][21] who forked it and gave us what is known as [Libre-Office][22]. Since then a number of Linux distributions have replaced OpenOffice for LibreOffice as their default office application.
|
||||
|
||||
It is available for Linux, Windows and Mac OS X which makes it easy to use in a cross-platform environment. Same as Apache OpenOffice, this too includes support for MS Office files apart from its own OpenDocument format. It also contains the same applications as Apache OpenOffice.
|
||||
|
||||
You can also use LibreOffice as a collaborative platform using [Collabora Online][23]. Basically, LibreOffice is a complete package and undoubtedly the best **Microsoft Office alternative for Linux** , Windows and macOS.
|
||||
|
||||
## What do you think?
|
||||
|
||||
I hope these Open Source alternatives to Microsoft Office saves your money. Which open source productivity suite do you use?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/
|
||||
|
||||
作者:[Abhishek Prakash][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/abhishek/
|
||||
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/best-open-source-alternatives-ms-office-800x450.jpg
|
||||
[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/open-office-logo-wide.jpg
|
||||
[3]:http://www.openoffice.org/
|
||||
[4]:https://itsfoss.com/install-openoffice-ubuntu-linux/
|
||||
[5]:https://itsfoss.com/openoffice-shutdown/
|
||||
[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/feng-office-logo-wide-800x240.jpg
|
||||
[7]:http://www.fengoffice.com/web/index.php?lang=en
|
||||
[8]:https://en.wikipedia.org/wiki/Collaborative_software
|
||||
[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/siag-office-logo-wide-800x240.jpg
|
||||
[10]:http://siag.nu/
|
||||
[11]:https://itsfoss.com/lightweight-linux-beginners/
|
||||
[12]:http://www.damnsmalllinux.org/
|
||||
[13]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/calligra-office-logo-wide-800x240.jpg
|
||||
[14]:http://www.calligra.org/
|
||||
[15]:https://itsfoss.com/calligra-android-app-coffice/
|
||||
[16]:http://maketecheasier.com/is-calligra-a-great-alternative-to-libreoffice/2012/06/18
|
||||
[17]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/only-office-logo-wide-800x240.png
|
||||
[18]:https://www.onlyoffice.com/
|
||||
[19]:https://itsfoss.com/review-onlyoffice-desktop-editors-linux/
|
||||
[20]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/LibreOffice-logo-wide-800x240.jpg
|
||||
[21]:http://www.documentfoundation.org/
|
||||
[22]:http://www.libreoffice.org/
|
||||
[23]:https://www.collaboraoffice.com/collabora-online/
|
@ -1,99 +0,0 @@
|
||||
Translating by qhwdw
|
||||
Torrents - Everything You Need to Know
|
||||
======
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrenting-how-torrent-works_orig.jpg)
|
||||
|
||||
**Torrents** - Every time we hear this word, the only thing that comes to our minds is free movies, games and cracked software. But little do we know about how they work, the various concepts involved in torrenting etc. So here in this article let’s have a look at **torrenting** from a technical perspective.
|
||||
|
||||
### What are Torrents?
|
||||
|
||||
Torrents are links to a file’s location on the internet. They are not the files, they are just Dynamic pointers to the original file that you download.
|
||||
|
||||
For example: if you click on
|
||||
|
||||
[Google Chrome][1]
|
||||
|
||||
you can download the Google Chrome browser from Google's servers.
|
||||
|
||||
|
||||
|
||||
If you click on that link tomorrow, or next week or next month, the file will still be downloaded from Google’s server.
|
||||
|
||||
But when we download torrents, there is no fixed server. Files are downloaded from other people’s computers who had previously downloaded that torrent.
|
||||
|
||||
### How Does this work?
|
||||
|
||||
[![Peer to peer network](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent_orig.png)][2]
|
||||
|
||||
Let’s say ‘A’ has some video that he wants to create a torrent of. So he creates a torrent and sends that link to ‘B’, this link contains information about where exactly is that video on the internet from its IP address. So when ‘B’ starts downloading that file, ‘B’ connects to ‘A’s’ computer. Now after ‘B’ has completed downloading it, ‘B’ will start seeding it i.e ‘B’ will allow another ‘C’ or ‘D’ to download it from ‘B’s’ computer.
|
||||
|
||||
So everyone first downloads the file and then uploads, the more uploaders the more, downloading speed you get. And if in any case, someone wishes to stop uploading he can do so. This won’t be a problem unless there are too many downloaders and few uploaders.
|
||||
|
||||
### Seeders and Leechers
|
||||
|
||||
[![kickass torrents website](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/seeders_orig.png)][3]
|
||||
|
||||
A user who has fully downloaded that particular file and is now uploading it so that new users can download is a seeder.
|
||||
|
||||
And someone who hasn’t completed downloading that file and is still downloading it is a leecher.
|
||||
|
||||
### Pieces
|
||||
|
||||
[![qbittorrent software for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/peers_orig.png)][4]
|
||||
|
||||
All torrent files are separated into packets of fixed size so that they can be downloaded non-linearly and randomly. Each piece can uniquely be identified so that once all pieces are downloaded they can be put together to form the original file.
|
||||
|
||||
This is done so that if you are downloading a file from someone and if he stops uploading due to some reasons, you can continue your download from another seeder without having to re-download the file.
|
||||
|
||||
### Peers
|
||||
|
||||
Peers are basically leechers that are currently connected to you. A leecher who is uploading however many pieces that he has downloaded is a peer.
|
||||
|
||||
**For example:
|
||||
**
|
||||
|
||||
A user who has downloaded the first 50 pieces of a file is a leecher, but he is uploading those files simultaneously and you are a person who has only 10 first pieces, so you can download up to 50 pieces from him. Here he would be your peer.
|
||||
|
||||
### Best Practises
|
||||
|
||||
Whenever you are downloading a torrent, always try to choose the one that has maximum seeders. Consider this a rule of thumb.
|
||||
|
||||
|
||||
|
||||
There are no exact minimum criteria but just make sure you choose the one with the maximum seeders.
|
||||
|
||||
### Torrent Laws
|
||||
|
||||
[![piracy is illegal](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent-laws_orig.png)][5]
|
||||
|
||||
Torrent laws are no different from other laws and torrenting of copyrighted material is a punishable offense. Most governments have blocked torrent sites and protocols but torrenting is not bad.
|
||||
|
||||
Torrents are extremely useful in quickly sharing a file and they are used to share most of the Open Source Community’s software as they can save a lot of server resources. However, many people use them for piracy.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Torrenting is a great technology ideal to reduce the load on the servers.
|
||||
|
||||
Torrenting
|
||||
|
||||
can give us speed up to our network adapter’s limit, which is great. However, due to decentralized servers, Piracy is inevitable. It can only be our moral responsibility to restrict what we share and never download the pirated content.
|
||||
|
||||
Do share your thoughts about using torrents in the comments section below and share with us your favorite torrent websites to download legal material.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxandubuntu.com/home/torrents-everything-you-need-to-know
|
||||
|
||||
作者:[LINUXANDUBUNTU][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxandubuntu.com
|
||||
[1]:https://www.google.com/chrome/
|
||||
[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent_orig.png
|
||||
[3]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/seeders_orig.png
|
||||
[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/peers_orig.png
|
||||
[5]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent-laws_orig.png
|
@ -1,154 +0,0 @@
|
||||
Translating by qhwdw
|
||||
Building a Linux-based HPC system on the Raspberry Pi with Ansible
|
||||
============================================================
|
||||
|
||||
### Create a high-performance computing cluster with low-cost hardware and open source software.
|
||||
|
||||
![Building a Linux-based HPC system on the Raspberry Pi with Ansible](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 "Building a Linux-based HPC system on the Raspberry Pi with Ansible")
|
||||
Image by : opensource.com
|
||||
|
||||
In my [previous article for Opensource.com][14], I introduced the [OpenHPC][15] project, which aims to accelerate innovation in high-performance computing (HPC). This article goes a step further by using OpenHPC's capabilities to build a small HPC system. To call it an _HPC system_ might sound bigger than it is, so maybe it is better to say this is a system based on the [Cluster Building Recipes][16] published by the OpenHPC project.
|
||||
|
||||
The resulting cluster consists of two Raspberry Pi 3 systems acting as compute nodes and one virtual machine acting as the master node:
|
||||
|
||||
|
||||
![Map of HPC cluster](https://opensource.com/sites/default/files/u128651/hpc_with_pi-1.png "Map of HPC cluster")
|
||||
|
||||
My master node is running CentOS on x86_64 and my compute nodes are running a slightly modified CentOS on aarch64.
|
||||
|
||||
This is what the setup looks in real life:
|
||||
|
||||
|
||||
![HPC hardware setup](https://opensource.com/sites/default/files/u128651/hpc_with_pi-2.jpg "HPC hardware setup")
|
||||
|
||||
To set up my system like an HPC system, I followed some of the steps from OpenHPC's Cluster Building Recipes [install guide for CentOS 7.4/aarch64 + Warewulf + Slurm][17] (PDF). This recipe includes provisioning instructions using [Warewulf][18]; because I manually installed my three systems, I skipped the Warewulf parts and created an [Ansible playbook][19] for the steps I took.
|
||||
|
||||
|
||||
Once my cluster was set up by the [Ansible][26] playbooks, I could start to submit jobs to my resource manager. The resource manager, [Slurm][27] in my case, is the instance in the cluster that decides where and when my jobs are executed. One possibility to start a simple job on the cluster is:
|
||||
```
|
||||
[ohpc@centos01 ~]$ srun hostname
|
||||
calvin
|
||||
```
|
||||
|
||||
If I need more resources, I can tell Slurm that I want to run my command on eight CPUs:
|
||||
|
||||
```
|
||||
[ohpc@centos01 ~]$ srun -n 8 hostname
|
||||
hobbes
|
||||
hobbes
|
||||
hobbes
|
||||
hobbes
|
||||
calvin
|
||||
calvin
|
||||
calvin
|
||||
calvin
|
||||
```
|
||||
|
||||
In the first example, Slurm ran the specified command (`hostname`) on a single CPU, and in the second example Slurm ran the command on eight CPUs. One of my compute nodes is named `calvin` and the other is named `hobbes`; that can be seen in the output of the above commands. Each of the compute nodes is a Raspberry Pi 3 with four CPU cores.
|
||||
|
||||
Another way to submit jobs to my cluster is the command `sbatch`, which can be used to execute scripts with the output written to a file instead of my terminal.
|
||||
|
||||
```
|
||||
[ohpc@centos01 ~]$ cat script1.sh
|
||||
#!/bin/sh
|
||||
date
|
||||
hostname
|
||||
sleep 10
|
||||
date
|
||||
[ohpc@centos01 ~]$ sbatch script1.sh
|
||||
Submitted batch job 101
|
||||
```
|
||||
|
||||
This will create an output file called `slurm-101.out` with the following content:
|
||||
|
||||
```
|
||||
Mon 11 Dec 16:42:31 UTC 2017
|
||||
calvin
|
||||
Mon 11 Dec 16:42:41 UTC 2017
|
||||
```
|
||||
|
||||
To demonstrate the basic functionality of the resource manager, simple and serial command line tools are suitable—but a bit boring after doing all the work to set up an HPC-like system.
|
||||
|
||||
A more interesting application is running an [Open MPI][20] parallelized job on all available CPUs on the cluster. I'm using an application based on [Game of Life][21], which was used in a [video][22] called "Running Game of Life across multiple architectures with Red Hat Enterprise Linux." In addition to the previously used MPI-based Game of Life implementation, the version now running on my cluster colors the cells for each involved host differently. The following script starts the application interactively with a graphical output:
|
||||
|
||||
```
|
||||
$ cat life.mpi
|
||||
#!/bin/bash
|
||||
|
||||
module load gnu6 openmpi3
|
||||
|
||||
if [[ "$SLURM_PROCID" != "0" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
mpirun ./mpi_life -a -p -b
|
||||
```
|
||||
|
||||
I start the job with the following command, which tells Slurm to allocate eight CPUs for the job:
|
||||
|
||||
```
|
||||
$ srun -n 8 --x11 life.mpi
|
||||
```
|
||||
|
||||
For demonstration purposes, the job has a graphical interface that shows the current result of the calculation:
|
||||
|
||||
|
||||
![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-3.png)
|
||||
|
||||
The position of the red cells is calculated on one of the compute nodes, and the green cells are calculated on the other compute node. I can also tell the Game of Life program to color the cell for each used CPU (there are four per compute node) differently, which leads to the following output:
|
||||
|
||||
|
||||
![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-4.png)
|
||||
|
||||
Thanks to the installation recipes and the software packages provided by OpenHPC, I was able to set up two compute nodes and a master node in an HPC-type configuration. I can submit jobs to my resource manager, and I can use the software provided by OpenHPC to start MPI applications utilizing all my Raspberry Pis' CPUs.
|
||||
|
||||
* * *
|
||||
|
||||
_To learn more about using OpenHPC to build a Raspberry Pi cluster, please attend Adrian Reber's talks at [DevConf.cz 2018][10], January 26-28, in Brno, Czech Republic, and at the [CentOS Dojo 2018][11], on February 2, in Brussels._
|
||||
|
||||
### About the author
|
||||
|
||||
[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/gotchi-square.png?itok=PJKu7LHn)][23] Adrian Reber - Adrian is a Senior Software Engineer at Red Hat and is migrating processes at least since 2010\. He started to migrate processes in a high performance computing environment and at some point he migrated so many processes that he got a PhD for that and since he joined Red Hat he started to migrate containers. Occasionally he still migrates single processes and is still interested in high performance computing topics.[More about me][12]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/how-build-hpc-system-raspberry-pi-and-openhpc
|
||||
|
||||
作者:[Adrian Reber ][a]
|
||||
译者:[译者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/adrianreber
|
||||
[1]:https://opensource.com/resources/what-are-linux-containers?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[2]:https://opensource.com/resources/what-docker?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[3]:https://opensource.com/resources/what-is-kubernetes?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[4]:https://developers.redhat.com/blog/2016/01/13/a-practical-introduction-to-docker-container-terminology/?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[5]:https://opensource.com/file/384031
|
||||
[6]:https://opensource.com/file/384016
|
||||
[7]:https://opensource.com/file/384021
|
||||
[8]:https://opensource.com/file/384026
|
||||
[9]:https://opensource.com/article/18/1/how-build-hpc-system-raspberry-pi-and-openhpc?rate=l9n6B6qRcR20LJyXEoUoWEZ4mb2nDc9sFZ1YSPc60vE
|
||||
[10]:https://devconfcz2018.sched.com/event/DJYi/openhpc-introduction
|
||||
[11]:https://wiki.centos.org/Events/Dojo/Brussels2018
|
||||
[12]:https://opensource.com/users/adrianreber
|
||||
[13]:https://opensource.com/user/188446/feed
|
||||
[14]:https://opensource.com/article/17/11/openhpc
|
||||
[15]:https://openhpc.community/
|
||||
[16]:https://openhpc.community/downloads/
|
||||
[17]:https://github.com/openhpc/ohpc/releases/download/v1.3.3.GA/Install_guide-CentOS7-Warewulf-SLURM-1.3.3-aarch64.pdf
|
||||
[18]:https://en.wikipedia.org/wiki/Warewulf
|
||||
[19]:http://people.redhat.com/areber/openhpc/ansible/
|
||||
[20]:https://www.open-mpi.org/
|
||||
[21]:https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
|
||||
[22]:https://www.youtube.com/watch?v=n8DvxMcOMXk
|
||||
[23]:https://opensource.com/users/adrianreber
|
||||
[24]:https://opensource.com/users/adrianreber
|
||||
[25]:https://opensource.com/users/adrianreber
|
||||
[26]:https://www.ansible.com/
|
||||
[27]:https://slurm.schedmd.com/
|
||||
[28]:https://opensource.com/tags/raspberry-pi
|
||||
[29]:https://opensource.com/tags/programming
|
||||
[30]:https://opensource.com/tags/linux
|
||||
[31]:https://opensource.com/tags/ansible
|
@ -1,3 +1,4 @@
|
||||
leemeans translating
|
||||
Creating an Adventure Game in the Terminal with ncurses
|
||||
======
|
||||
How to use curses functions to read the keyboard and manipulate the screen.
|
||||
|
@ -1,122 +0,0 @@
|
||||
How to print filename with awk on Linux / Unix
|
||||
======
|
||||
|
||||
I would like to print filename with awk on Linux / Unix-like system. How do I print filename in BEGIN section of awk? Can I print the name of the current input file using gawk/awk?
|
||||
|
||||
The name of the current input file set in FILENAME variable. You can use FILENAME to display or print current input file name If no files are specified on the command line, the value of FILENAME is “-” (stdin). However, FILENAME is undefined inside the BEGIN rule unless set by getline.
|
||||
|
||||
### How to print filename with awk
|
||||
|
||||
The syntax is:
|
||||
```
|
||||
awk '{ print FILENAME }' fileNameHere
|
||||
awk '{ print FILENAME }' /etc/hosts
|
||||
```
|
||||
You might see file name multiple times as awk read file line-by-line. To avoid this problem update your awk/gawk syntax as follows:
|
||||
```
|
||||
awk 'FNR == 1{ print FILENAME } ' /etc/passwd
|
||||
awk 'FNR == 1{ print FILENAME } ' /etc/hosts
|
||||
```
|
||||
![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-print-filename-using-awk-on-Linux-or-Unix.jpg)
|
||||
|
||||
### How to print filename in BEGIN section of awk
|
||||
|
||||
Use the following syntax:
|
||||
```
|
||||
awk 'BEGIN{print ARGV[1]}' fileNameHere
|
||||
awk 'BEGIN{print ARGV[1]}{ print "someting or do something on data" }END{}' fileNameHere
|
||||
awk 'BEGIN{print ARGV[1]}' /etc/hosts
|
||||
```
|
||||
Sample outputs:
|
||||
```
|
||||
/etc/hosts
|
||||
|
||||
```
|
||||
|
||||
However, ARGV[1] might not always work. For example:
|
||||
`ls -l /etc/hosts | awk 'BEGIN{print ARGV[1]} { print }'`
|
||||
So you need to modify it as follows (assuming that ls -l only produced a single line of output):
|
||||
`ls -l /etc/hosts | awk '{ print "File: " $9 ", Owner:" $3 ", Group: " $4 }'`
|
||||
Sample outputs:
|
||||
```
|
||||
File: /etc/hosts, Owner:root, Group: roo
|
||||
|
||||
```
|
||||
|
||||
### How to deal with multiple filenames specified by a wild card
|
||||
|
||||
Use the following simple syntax:
|
||||
```
|
||||
awk '{ print FILENAME; nextfile } ' *.c
|
||||
awk 'BEGIN{ print "Starting..."} { print FILENAME; nextfile }END{ print "....DONE"} ' *.conf
|
||||
```
|
||||
Sample outputs:
|
||||
```
|
||||
Starting...
|
||||
blkid.conf
|
||||
cryptconfig.conf
|
||||
dhclient6.conf
|
||||
dhclient.conf
|
||||
dracut.conf
|
||||
gai.conf
|
||||
gnome_defaults.conf
|
||||
host.conf
|
||||
idmapd.conf
|
||||
idnalias.conf
|
||||
idn.conf
|
||||
insserv.conf
|
||||
iscsid.conf
|
||||
krb5.conf
|
||||
ld.so.conf
|
||||
logrotate.conf
|
||||
mke2fs.conf
|
||||
mtools.conf
|
||||
netscsid.conf
|
||||
nfsmount.conf
|
||||
nscd.conf
|
||||
nsswitch.conf
|
||||
openct.conf
|
||||
opensc.conf
|
||||
request-key.conf
|
||||
resolv.conf
|
||||
rsyncd.conf
|
||||
sensors3.conf
|
||||
slp.conf
|
||||
smartd.conf
|
||||
sysctl.conf
|
||||
vconsole.conf
|
||||
warnquota.conf
|
||||
wodim.conf
|
||||
xattr.conf
|
||||
xinetd.conf
|
||||
yp.conf
|
||||
....DONE
|
||||
|
||||
```
|
||||
|
||||
nextfile tells awk to stop processing the current input file. The next input record read comes from the next input file. For more information see awk/[gawk][1] command man page:
|
||||
```
|
||||
man awk
|
||||
man gawk
|
||||
```
|
||||
|
||||
### about the author
|
||||
|
||||
The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][2], [Facebook][3], [Google+][4]. Get the **latest tutorials on SysAdmin, Linux/Unix and open source topics via[my RSS/XML feed][5]**.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.cyberciti.biz/faq/how-to-print-filename-with-awk-on-linux-unix/
|
||||
|
||||
作者:Vivek GIte[][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.cyberciti.biz/
|
||||
[1]:https://www.gnu.org/software/gawk/manual/
|
||||
[2]:https://twitter.com/nixcraft
|
||||
[3]:https://facebook.com/nixcraft
|
||||
[4]:https://plus.google.com/+CybercitiBiz
|
||||
[5]:https://www.cyberciti.biz/atom/atom.xml
|
@ -1,3 +1,4 @@
|
||||
@qianghaohao 翻译中
|
||||
How to create AWS ec2 key using Ansible
|
||||
======
|
||||
|
||||
|
@ -0,0 +1,111 @@
|
||||
# Liunx 平台 6 个最好的替代 Microsoft Office 的开源办公软件
|
||||
|
||||
**概要:还在 Linux 中寻找 Microsoft Office ? 这里有一些最好的在 Linux 平台替代 Microsoft Office 的开源软件。**
|
||||
|
||||
办公套件是任何操作系统的必备品。很难想象没有Office 软件的桌面操作系统。虽然 Windows 有 MS Office 套件,Mac OS X 也有它自己的 iWork,但其他很多办公套件都是专门针对这些操作系统的,Linux 也有自己的办公套件。
|
||||
|
||||
在本文中,我会列举一些在 Linux 平台替代 Microsoft Office 的办公软件。
|
||||
|
||||
## Linux 最好的 MS Office 开源替代软件
|
||||
|
||||
![Best Microsoft office alternatives for Linux][1]
|
||||
|
||||
在我们看 MS Office 的替代软件之前,我们先来看看在一个像样的办公套件中有一些什么:
|
||||
|
||||
* 文字处理器
|
||||
* 电子表格
|
||||
* 演示功能
|
||||
|
||||
|
||||
我知道 Microsoft Office 提供了比上述三种工具更多的工具,但事实上, 您主要使用这三个工具。 开源办公套件并不限于只有这三种产品。 其中有一些套件提供了一些额外的工具,但我们的重点将放在上述工具上。
|
||||
|
||||
让我们看看在 Linux 上有什么办公套件:
|
||||
|
||||
### 6. Apache OpenOffice
|
||||
|
||||
![OpenOffice Logo][2]
|
||||
|
||||
[Apache OpenOffice][3] 或简单的称为 OpenOffice 有一段名称/所有者变更的历史。 它于1999年由 Sun Microsystems 公司开发,后来改名为 OpenOffice ,将它作为一个与 MS Office 对抗的免费的开源替代软件。 当Oracle 在 2010 年收购 Sun 公司后,一年之后便停止开发 OpenOffice。 最后是 Apache 支持它,现在被称为Apache OpenOffice。
|
||||
|
||||
Apache OpenOffice 可用于多种平台,包括 Linux,Windows,Mac OS X,Unix,BSD。 除了 OpenDocument 格式外,它还支持 MS Office 文件。 办公套件包含以下应用程序:Writer,Calc,Impress,Base,Draw,Math。
|
||||
|
||||
安装 OpenOffice 是一件痛苦的事,因为它没有提供一个友好的安装程序。 另外,有传言说 OpenOffice 开发可能已经停滞。 这两个是我不推荐的主要原因。 为了历史目的,我在这里列出它。
|
||||
|
||||
### 5. Feng Office
|
||||
|
||||
![Feng Office logo][6]
|
||||
|
||||
[Feng Office][7] 以前被称为 OpenGoo。 这不是一个常规的办公套件。 它完全专注于在线办公,如 Google 文档。 换句话说,这是一个开源[协作平台][8]。
|
||||
|
||||
Feng Office 不支持桌面使用,因此如果您想在单个Linux 桌面上使用它,这个可能无法实现。 另一方面,如果你有一个小企业,一个机构或其他组织,你可以尝试将其部署在本地服务器上。
|
||||
|
||||
### 4. Siag Office
|
||||
|
||||
![SIAG Office logo][9]
|
||||
|
||||
[Siag][10] 是一个非常轻量级的办公套件,适用于类 Unix 系统,可以在 16 MB 系统上运行。 由于它非常轻便,因此缺少标准办公套件中的许多功能。 但小即是美丽的,不是吗? 它具有办公套件的所有必要功能,可以在[轻量级 Linux 发行版][11]上“正常工作”。它是 [Damn Small Linux][12] 默认安装软件。(译者注: 根据官网,现已不是默认安装软件)
|
||||
|
||||
### 3. Calligra Suite
|
||||
|
||||
![Calligra free and Open Source office logo][13]
|
||||
|
||||
[Calligra][14],以前被称为 KOffice,是 KDE 中默认的 Office 套件。 它支持 Mac OS X,Windows,Linux,FreeBSD系统。 它也曾经推出 Android 版本。 但不幸的是,后续没有继续支持 Android。 它拥有办公套件所需的必要应用程序以及一些额外的应用程序,如用于绘制流程图的 Flow 和用于项目管理的 Plane。
|
||||
|
||||
Calligra 最近的发展产生了相当大的影响,很有可能成为 [LibreOffice 的替代品][16]。
|
||||
|
||||
### 2. ONLYOFFICE
|
||||
|
||||
![ONLYOFFICE is Linux alternative to Microsoft Office][17]
|
||||
|
||||
[ONLYOFFICE][18] 是办公套件市场上的新玩家,它更专注于协作部分。 企业(甚至个人)可以将其部署到自己的服务器上,以获得类似 Google Docs 之类的协作办公套件。
|
||||
|
||||
别担心。 您不必必须将其安装在服务器上。 有一个免费的开源[桌面版本][19] ONLYOFFICE。 您甚至可以获取 .deb 和 .rpm 二进制文件,以便将其安装在 Linux 桌面系统上。
|
||||
|
||||
### 1. LibreOffice
|
||||
|
||||
![LibreOffice logo][20]
|
||||
|
||||
当 Oracle 决定停止 OpenOffice 的开发时,是[文档基金会][21]将其复制分发,这就是我们所熟知的 [Libre-Office][22] 。从那时起,许多 Linux 发行版都将 OpenOffice 替换为 LibreOffice 作为它们的默认办公应用程序。
|
||||
|
||||
它适用于 Linux,Windows 和 Mac OS X,这使得在跨平台环境中易于使用。 和 Apache OpenOffice 一样,这也包括了除了 OpenDocument 格式以外的对 MS Office 文件的支持。 它还包含与 Apache OpenOffice 相同的应用程序。
|
||||
|
||||
您还可以使用 LibreOffice 作为 [Collabora Online][23] 的协作平台。 基本上,LibreOffice 是一个完整的软件包,无疑是 Linux,Windows 和 MacOS 的**最佳 Microsoft Office 替代品**。
|
||||
|
||||
## 你认为呢?
|
||||
|
||||
我希望 Microsoft Office 的这些开源替代软件可以节省您的资金。 您会使用哪种开源生产力办公套件?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
译者:[amwps290](https://github.com/amwps290)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://itsfoss.com/author/abhishek/
|
||||
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/best-open-source-alternatives-ms-office-800x450.jpg
|
||||
[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/open-office-logo-wide.jpg
|
||||
[3]:http://www.openoffice.org/
|
||||
[4]:https://itsfoss.com/install-openoffice-ubuntu-linux/
|
||||
[5]:https://itsfoss.com/openoffice-shutdown/
|
||||
[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/feng-office-logo-wide-800x240.jpg
|
||||
[7]:http://www.fengoffice.com/web/index.php?lang=en
|
||||
[8]:https://en.wikipedia.org/wiki/Collaborative_software
|
||||
[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/siag-office-logo-wide-800x240.jpg
|
||||
[10]:http://siag.nu/
|
||||
[11]:https://itsfoss.com/lightweight-linux-beginners/
|
||||
[12]:http://www.damnsmalllinux.org/
|
||||
[13]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/calligra-office-logo-wide-800x240.jpg
|
||||
[14]:http://www.calligra.org/
|
||||
[15]:https://itsfoss.com/calligra-android-app-coffice/
|
||||
[16]:http://maketecheasier.com/is-calligra-a-great-alternative-to-libreoffice/2012/06/18
|
||||
[17]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/only-office-logo-wide-800x240.png
|
||||
[18]:https://www.onlyoffice.com/
|
||||
[19]:https://itsfoss.com/review-onlyoffice-desktop-editors-linux/
|
||||
[20]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2012/06/LibreOffice-logo-wide-800x240.jpg
|
||||
[21]:http://www.documentfoundation.org/
|
||||
[22]:http://www.libreoffice.org/
|
||||
[23]:https://www.collaboraoffice.com/collabora-online/
|
@ -1,292 +0,0 @@
|
||||
25本免费学习linux的书
|
||||
======
|
||||
简介: 在这篇文章中,我将与你分享**免费学习Linux**的最佳资源。这是一个网站,在线视频课程和免费电子书的集合。
|
||||
|
||||
**如何学习linux?**
|
||||
|
||||
这可能是 Facebook Linux 用户群组中最常见的问题。
|
||||
|
||||
'如何学习linux'这个看起来简单的问题的答案并不简单。
|
||||
|
||||
问题在于不同的人对于学习 linux 有不同的意义。
|
||||
* 比如有人从来没有使用过 Linux,无论是命令行还是桌面版本,那个人可能只是想知道更多关于它的信息。
|
||||
* 比如有人使用 Windows 作为桌面,但必须在工作中使用 Linux 命令行,那个人可能对学习 Linux 命令感兴趣。
|
||||
* 比如有人已经使用过一段时间的 Linux,而且懂得一些基础,但他/她可能想要更上一层楼。
|
||||
* 比如有人只是对 Linux 特定的发行版本感兴趣。
|
||||
* 比如有人想要改进或学习几乎与 Linux 命令行差不多的Bash脚本。
|
||||
* 比如有人想要从事一个 Linux 系统管理员的职业,或者想提高他/她的系统管理技能。
|
||||
|
||||
你看,'我如何学习Linux'的答案取决于你追求什么样的 linux 知识。为此,我收集了大量能用来学习Linux的资源
|
||||
|
||||
这些免费的资源包括电子书,视频课程,网站等。这些资源分成几个子类别,以便当你试图学习 Linux 时可以很容易地找到你想要的东西。
|
||||
|
||||
再者,这里没有**最好的方式来学习Linux**。这完全取决于你如何去学习 Linux,通过在线门户网站,下载电子书,视频课程或者其他。
|
||||
|
||||
让我们看看你能如何学习 Linux。
|
||||
|
||||
**免责声明** : 这里列举的所有书都可以合法的下载。 据我所知,这里提到的资源都是官方的资源。但是,如果你发现它不是,请让我知道以便我可以采取适当的措施。
|
||||
|
||||
![Best Free eBooks to learn Linux for Free][1]
|
||||
|
||||
## 1. 对于完全新手的免费资料
|
||||
|
||||
也许你刚刚从朋友那里或者从网上的讨论中听到了 Linux。关于 Linux 的炒作让你对Linux很感兴趣,你被互联网上的大量信息所淹没,不知道在哪里寻找更多的关于Linux的知识。
|
||||
|
||||
不用担心, 我们中的大多数, 即使不是全部, 已经来到你的身边
|
||||
|
||||
### Linux基金会关于Linux的介绍 [Video Course]
|
||||
|
||||
如果你对于什么是Linux和如何开始学习Linux完全没有概念的话,我建议你从学习Linux基金会[Linux Foundation][2]在[edX][3]提供的免费的视频课程开始。
|
||||
把它当做一个'维护'Linux组织的官方的课程。是的,它是由Linux之父[Linus Torvalds][4]赞同的
|
||||
|
||||
[Introduction To Linux][5]
|
||||
|
||||
### Linux 旅程 [Online Portal]
|
||||
|
||||
不是官方的,也许不是很受欢迎。但是这个小网站对于初学者来说是一个Linux学习的完美场所。
|
||||
|
||||
该网站设计精美,并根据主题组织得很好。它给你提供了能够在阅读完一个片段或章节后的进行的互动式测验。我的建议,收藏这个网站:
|
||||
[Linux Journey][6]
|
||||
|
||||
### 5天学习Linux [eBook]
|
||||
|
||||
这本出色的书对于它专门的 FOSS 读者 来说完全的免费,这完全得感谢[Linux Training Academy][7]。
|
||||
|
||||
为了完全的新手而写,这本免费的 Linux 电子书给你一个关于 Linux的概述,常用的 Linux指令和你开始学习 Linux 所需要的其他东西
|
||||
|
||||
你能够从下面的网页下载书:
|
||||
|
||||
[Learn Linux In 5 Days][8]
|
||||
|
||||
### 终极的Linux新手指南 [eBook]
|
||||
|
||||
这是一本Linux初学者可以免费下载的电子书。电子书从解释什么是 Linux 开始,然后继续提供了更多Linux作为桌面的实际的使用。
|
||||
|
||||
您可以从下面的链接下载最新版本的电子书:
|
||||
|
||||
[The Ultimate Linux Newbie Guide][9]
|
||||
|
||||
## 2. 初学者进阶的免费书籍
|
||||
|
||||
本节列出了那些已经"完成"的 Linux 电子书。
|
||||
|
||||
我的意思是,这些之中的大部分就像是专注于 Linux 的每个方面的学术教科书。你可以作为一个绝对的新手阅读这些书或者你可以作为一个中级的 Linux 用户来深入学习。即使你已经是专家级,你也可以把它们作为参考
|
||||
|
||||
### Introduction to Linux [eBook]
|
||||
|
||||
Linux 简介是[The Linux Documentation Project][10]的免费电子书,而且它是最热门的 Linux 免费电子书之一。即使我认为其中的部分段落需要更新,它仍然是一本非常好的电子书来教你 Linux,Linux 的文件系统,命令行,网络和其他相关的东西。
|
||||
|
||||
[Introduction To Linux][11]
|
||||
|
||||
### Linux 基础 [eBook]
|
||||
|
||||
这本由 Paul Cobbaut 编写的免费的电子书教你关于 Linux 的历史,安装和你需要知道的基本的 Linux 命令。你能够从下列链接上得到这本书:
|
||||
|
||||
[Linux Fundamentals][12]
|
||||
|
||||
### 高级的 Linux 编程[eBook]
|
||||
|
||||
顾名思义,这是一本对于想要或者正在开发 Linux 软件的高级用户的书。它解决了负责的功能比如多进程,多线程,进程间通信以及和硬件设备的交互。
|
||||
|
||||
跟着这本书学习会帮你开发一个更快速,更可靠,更安全的使用 GNU/Linux 系统全部功能的项目
|
||||
|
||||
[Advanced Linux Programming][13]
|
||||
|
||||
### Linux From Scratch(就是一种从网上直接下载源码,从头编译LINUX的安装方式) [eBook]
|
||||
|
||||
如果你认为自己对Linux有足够的了解,并且你是一个专业人士,那么为什么不创建自己的Linux版本呢? Linux From Scratch(LFS)是一个完全基于源代码,为你构建你自定义的 Linux 系统提供手把手的指导。
|
||||
|
||||
把它叫做 DIY Linux 但是它是一个把你的 Linux 专业知识提高到新的高度的方法。
|
||||
|
||||
这里有许多的关于这个项目的子项目,你能够在这个网站上查看和下载。
|
||||
|
||||
[Linux From Scratch][14]
|
||||
|
||||
## 3.免费的电子书来学习 Linux 命令和 Shell脚本
|
||||
|
||||
Linux 的真正强大在于命令行,如果你想要征服 Linux,你必须学习命令行和shell
|
||||
|
||||
事实上,如果你必须在你的工作中使用Linux终端,那么熟悉Linux命令行实际上会帮助你完成任务,也有可能帮助你提高你的职业生涯(因为你会更有效率)。
|
||||
|
||||
在本节中,我们将看到各种Linux命令的免费电子书。
|
||||
|
||||
### GNU/Linux Command−Line Tools Summary [eBook]
|
||||
|
||||
这本Linux文档项目中的电子书是接触Linux命令行并开始熟悉Shell脚本的好地方
|
||||
|
||||
[GNU/Linux Command−Line Tools Summary][15]
|
||||
|
||||
### 来自 GNU 的 Bash 参考指南[eBook]
|
||||
|
||||
这是一本从[GNU][16]下载的免费电子书。 就像名字暗示的那样, 它涉及 Bash Shell (如果我能这么叫的话). 这本书有超过175页而且它包括了许多在 Bash里和 Linux有关的主题。
|
||||
|
||||
你能够从下面的链接中获取:
|
||||
|
||||
[Bash Reference Manual][17]
|
||||
|
||||
### Linux 命令行 [eBook]
|
||||
|
||||
这本500多页的由William Shotts编写的免费电子书,对于那些认真学习Linux命令行的人来说,是一本必须拥有的书。
|
||||
|
||||
即使你认为你知道关于Linux的东西,你还是会惊讶于这本书能教你很多东西。
|
||||
|
||||
它涵盖了从初学者到高级的东西。我敢打赌读完这本书之后你会成为一个更好的Linux用户。请下载这本书并且随时携带它。
|
||||
|
||||
[The Linux Command Line][18]
|
||||
|
||||
### Bash 入门指南 [eBook]
|
||||
|
||||
如果你是想从 Bash 脚本开始,这可能对于你来说是一个很好的助手。 Linux 文档项目又是这本电子书的基础,它是编写 Linux 介绍的电子书的作者(本文前面讨论过)。
|
||||
|
||||
[Bash Guide for Beginners][19]
|
||||
|
||||
### 高级的 Bash 脚本指南[eBook]
|
||||
|
||||
如果你认为你已经知道了基本的Bash脚本的知识,并且你想把你的技能提高到一个新的水平,这本书就是你所需要的。这本书有超过900页的各种高级命令和举例。
|
||||
|
||||
[Advanced Bash-Scripting Guide][20]
|
||||
|
||||
### AWK 编程语言 [eBook]
|
||||
|
||||
这不是最漂亮的书,但是如果你真的想要通过脚本研究的更深,这本旧的但是依然发光的书会很有帮助。
|
||||
|
||||
[The AWK Programming Language][21]
|
||||
|
||||
### Linux 101 黑客 [eBook]
|
||||
|
||||
这本来自 "The Geek Stuf" 的书通过易于跟踪学习的例子教你基本的 Linux 命令行。你能够从下列的链接获取:
|
||||
|
||||
[Linux 101 Hacks][22]
|
||||
|
||||
## 4. 特定版本的免费学习资料
|
||||
|
||||
这个章节专注于特定 Linux 版本的材料。到目前为止,我们看到的都是常规的 Linux,更多的关注文件系统,命令和其他的核心内容。
|
||||
|
||||
这些书,在另一方面,可以被认为是用户手册或者开始学习各种各样的 Linux 版本的指南。所以如果你正在使用一个特定的 Linux 版本或者你准备使用它,你可以参考这些资源。是的,这些书更加关注 Linux 桌面。
|
||||
|
||||
我还想补充的是大部分的 Linux 版本有它们自己的大量的 wiki 或者文档。你能够从网上随时找到它们。
|
||||
|
||||
### Ubuntu 用户指南
|
||||
|
||||
不用说这本书是针对 Ubuntu 用户的。这是一个独立的项目在免费的电子书中提供 Ubuntun 的用户指南。它对于每个版本的 Ubuntu 都有更新。
|
||||
|
||||
这本书被叫做用户指南因为它是由一步步的指导组成而且受众目标是对于 Ubuntu 绝对的新手。所以,你会去了解 Unity 桌面,怎样慢慢走近而且查找应用等等。
|
||||
|
||||
如果你从来没有使用过 Ubuntu Unity 那么这是一本你必须拥有的书因为它帮助你理解怎样在日常中使用 Ubuntu。
|
||||
|
||||
[Ubuntu Manual][23]
|
||||
|
||||
### 对于 Linux Mint: 只要告诉我 Damnit! [eBook]
|
||||
|
||||
一本非常基本的关于 Linux Mint 的电子书。它告诉你怎么样在虚拟机中安装 Linux Mint,怎么样去查找软件,安装更新和自定义 Linux Mint 桌面。
|
||||
|
||||
你能够在下面的链接下载电子书:
|
||||
|
||||
[Just Tell Me Damnit!][24]
|
||||
|
||||
### Solus Linux 用户指南 [eBook]
|
||||
|
||||
注意!这本书过去是 Solus Linux 的官方用户指南但是我找不到 Solux 项目的网站上在哪里有提到它。我不知道它是不是已经过时了。尽管如此,学习一点Solu Linux 并不是受到伤害,不是吗?
|
||||
|
||||
[Solus Linux User Guide][25]
|
||||
|
||||
## 5. 对于系统管理者的免费电子书
|
||||
|
||||
这个章节主要关注与系统管理者,开发者的超级英雄。我已经列了一部分会真正帮助那些已经是系统管理者或者想要成为系统管理者的免费的电子书。我必须补充你必须要关注基本的 Linux 命令行因为它会使你的工作更加简单
|
||||
|
||||
### The Debian 管理者的手册 [eBook]
|
||||
|
||||
如果你使用 Debian Linux 作为你的服务器,这本书就是你的圣经。这本书从 Debian 的历史,安装,包管理等等开始,接着覆盖一些主题,比如说[LAMP][26],虚拟机,存储管理和其他核心系统管理。
|
||||
|
||||
[The Debian Administration's Handbook][27]
|
||||
|
||||
### 高级的 Linux 系统管理者[eBook]
|
||||
|
||||
如果在准备[LPI certification][28],那么这本书是一本理想的书。这本书的涉及系统管理员必要的主题。所以了解 Linux 命令行在这个条件下是一个前置条件。
|
||||
|
||||
[Advanced Linux System Administration][29]
|
||||
|
||||
### Linux 系统管理者 [eBook]
|
||||
|
||||
Paul Cobbaut 编写的另一本免费的电子书。370页长的的书包括了网络,磁盘管理,用户管理,内核管理,库管理等等。
|
||||
|
||||
[Linux System Administration][30]
|
||||
|
||||
### Linux 服务器 [eBook]
|
||||
|
||||
又一本 Paul Cobbaut 编写的[linux-training.be][31]. 这本书包括了网页服务器,mysql,DHCP,DNS,Samba和其他文件服务器。
|
||||
|
||||
[Linux Servers][32]
|
||||
|
||||
### Linux 网络 [eBook]
|
||||
|
||||
网络是系统管理者的面包和黄油,这本由 Paul Cobbaut 编写的书是一本好的参考资料。
|
||||
|
||||
[Linux Networking][33]
|
||||
|
||||
### Linux 存储 [eBook]
|
||||
|
||||
这本由 Paul Cobbaut(对,还是他) 编写的书解释了 Linux 的详细的磁盘管理而且介绍了许多其他的和存储相关的技术
|
||||
|
||||
[Linux Storage][34]
|
||||
|
||||
### Linux 安全 [eBook]
|
||||
|
||||
这是最后一本在这个书单里由 Paul Cobbaut 编写的书。 安全是系统管理员最重要的工作之一。这本书关注文件权限,acls,SELinux,用户和密码等等。
|
||||
|
||||
[Linux Security][35]
|
||||
|
||||
## 你最喜爱的 Linux 资料?
|
||||
|
||||
我知道这是一个免费 Linux 电子书的集合。但是它可以做的更好。
|
||||
|
||||
如果你有其他的在学习 Linux 有更大帮助的资料,请务必和我们共享。请注意只共享合法的下载资料以便我可以根据你的建议更新这篇文章而不会有任何问题。
|
||||
|
||||
我希望你觉得这篇文章在学习 Linux 时有帮助,欢迎你的反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/learn-linux-for-free/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
译者:[yyyfor](https://github.com/yyyfor)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://itsfoss.com/author/abhishek/
|
||||
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/02/free-ebooks-linux-800x450.png
|
||||
[2]:https://www.linuxfoundation.org/
|
||||
[3]:https://www.edx.org
|
||||
[4]:https://www.youtube.com/watch?v=eE-ovSOQK0Y
|
||||
[5]:https://www.edx.org/course/introduction-linux-linuxfoundationx-lfs101x-0
|
||||
[6]:https://linuxjourney.com/
|
||||
[7]:https://www.linuxtrainingacademy.com/
|
||||
[8]:https://courses.linuxtrainingacademy.com/itsfoss-ll5d/
|
||||
[9]:https://linuxnewbieguide.org/ulngebook/
|
||||
[10]:http://www.tldp.org/index.html
|
||||
[11]:http://tldp.org/LDP/intro-linux/intro-linux.pdf
|
||||
[12]:http://linux-training.be/linuxfun.pdf
|
||||
[13]:http://advancedlinuxprogramming.com/alp-folder/advanced-linux-programming.pdf
|
||||
[14]:http://www.linuxfromscratch.org/
|
||||
[15]:http://tldp.org/LDP/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.pdf
|
||||
[16]:https://www.gnu.org/home.en.html
|
||||
[17]:https://www.gnu.org/software/bash/manual/bash.pdf
|
||||
[18]:http://linuxcommand.org/tlcl.php
|
||||
[19]:http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf
|
||||
[20]:http://www.tldp.org/LDP/abs/abs-guide.pdf
|
||||
[21]:https://ia802309.us.archive.org/25/items/pdfy-MgN0H1joIoDVoIC7/The_AWK_Programming_Language.pdf
|
||||
[22]:http://www.thegeekstuff.com/linux-101-hacks-ebook/
|
||||
[23]:https://ubuntu-manual.org/
|
||||
[24]:http://downtoearthlinux.com/resources/just-tell-me-damnit/
|
||||
[25]:https://drive.google.com/file/d/0B5Ymf8oYXx-PWTVJR0pmM3daZUE/view
|
||||
[26]:https://en.wikipedia.org/wiki/LAMP_(software_bundle)
|
||||
[27]:https://debian-handbook.info/about-the-book/
|
||||
[28]:https://www.lpi.org/our-certifications/getting-started
|
||||
[29]:http://www.nongnu.org/lpi-manuals/manual/pdf/GNU-FDL-OO-LPI-201-0.1.pdf
|
||||
[30]:http://linux-training.be/linuxsys.pdf
|
||||
[31]:http://linux-training.be/
|
||||
[32]:http://linux-training.be/linuxsrv.pdf
|
||||
[33]:http://linux-training.be/linuxnet.pdf
|
||||
[34]:http://linux-training.be/linuxsto.pdf
|
||||
[35]:http://linux-training.be/linuxsec.pdf
|
@ -1,41 +1,53 @@
|
||||
用示例讲解 Linux Gunzip 命令
|
||||
用示例讲解 Linux gunzip 命令
|
||||
======
|
||||
|
||||
我们已经讨论过[ Linux 下 **gzip** 命令的用法 ][1]。对于初学者来说,gzip 工具主要用于压缩或者扩展文件。解压时,在 gzip 命令后添加 -d 选项,使用示例如下:
|
||||
我们已经讨论过 [Linux 下 gzip 命令的用法][1]。对于初学者来说,`gzip` 工具主要用于压缩或者展开文件。解压时,在 `gzip` 命令后添加 `-d` 选项即可,使用示例如下:
|
||||
|
||||
```
|
||||
gzip -d [compressed-file-name]
|
||||
```
|
||||
|
||||
不过,在解压或扩展 gzip 创建的压缩文件时,有另一款完全不同的工具可供使用。谈及的这款工具就是 **gunzip**。在本文中,我们会使用一些简单、易于理解的例子来解释 gunzip 命令的用法。文中所有示例及指南都在 Ubuntu 16.04 环境下测试。
|
||||
不过,在解压或扩展 gzip 创建的压缩文件时,有另一款完全不同的工具可供使用。谈及的这款工具就是 `gunzip`。在本文中,我们会使用一些简单、易于理解的例子来解释 `gunzip` 命令的用法。文中所有示例及指南都在 Ubuntu 16.04 环境下测试。
|
||||
|
||||
### Linux gunzip 命令
|
||||
|
||||
我们现在知道压缩文件可以用 'gzip -d' 或 gunzip 命令解压。基本的 gunzip 语法为:
|
||||
我们现在知道压缩文件可以用 `gzip -d` 或 `gunzip` 命令解压。基本的 `gunzip` 语法为:
|
||||
|
||||
```
|
||||
gunzip [compressed-file-name]
|
||||
```
|
||||
|
||||
以下的 Q&A 例子将更清晰地展示 gunzip 工具如何工作:
|
||||
以下的 Q&A 例子将更清晰地展示 `gunzip` 工具如何工作:
|
||||
|
||||
### Q1. 如何使用 gunzip 解压压缩文件?
|
||||
|
||||
解压命令非常简单,仅仅需要将压缩文件名称作为参数传递到 gunzip 命令后。
|
||||
解压命令非常简单,仅仅需要将压缩文件名称作为参数传递到 `gunzip` 命令后。
|
||||
|
||||
```
|
||||
gunzip [archive-name]
|
||||
```
|
||||
|
||||
比如:
|
||||
|
||||
```
|
||||
gunzip file1.gz
|
||||
```
|
||||
|
||||
[![如何使用 gunzip 解压压缩文件?][2]][3]
|
||||
|
||||
### Q2. 如何让 gunzip 不删除原始压缩文件?
|
||||
|
||||
正如你已注意到的那样,gunzip 命令解压后会删除原始压缩文件。如果你想保留原始压缩文件,可以使用 **-c** 选项。
|
||||
正如你已注意到的那样,`gunzip` 命令解压后会删除原始压缩文件。如果你想保留原始压缩文件,可以使用 `-c` 选项。
|
||||
|
||||
```
|
||||
gunzip -c [archive-name] > [outputfile-name]
|
||||
```
|
||||
|
||||
比如:
|
||||
|
||||
```
|
||||
gunzip -c file1.gz > file1
|
||||
```
|
||||
|
||||
[![如何让 gunzip 不删除原始压缩文件?][4]][5]
|
||||
|
||||
@ -43,26 +55,30 @@ gunzip -c file1.gz > file1
|
||||
|
||||
### Q3. 如何用 gunzip 解压文件到其他路径?
|
||||
|
||||
在 Q&A 中我们已经讨论过 **-c** 选项的用法。 使用 gunzip 解压文件到工作目录外的其他路径,仅需要在重定向操作符后添加目标目录的绝对路径即可。
|
||||
在 Q&A 中我们已经讨论过 `-c` 选项的用法。 使用 gunzip 解压文件到工作目录外的其他路径,仅需要在重定向操作符后添加目标目录的绝对路径即可。
|
||||
|
||||
```
|
||||
gunzip -c [compressed-file] > [/complete/path/to/dest/dir/filename]
|
||||
```
|
||||
|
||||
示例如下:
|
||||
|
||||
```
|
||||
gunzip -c file1.gz > /home/himanshu/file1
|
||||
```
|
||||
|
||||
### 更多信息
|
||||
|
||||
以下从 gzip/gunzip man page 中摘录的细节,对于想了解更多的人会有所助益。
|
||||
```
|
||||
gunzip 用命令行列出文件,并且替换每个以正确的幻数开头,后缀名为.gz,-gz,.z,-z,或 _z (忽略) 的压缩文件,删除原始文件。 gunzip 也可识别一些特殊扩展名的压缩文件,如 .tgz 和 .taz 分别是 .tar.gz 和 .tar.Z 的缩写。在压缩时,gzip 在必要情况下使用 .tgz 作为扩展名,而不是只截取为 .tar 作为后缀。
|
||||
以下从 gzip/gunzip 的 man 页中摘录的细节,对于想了解更多的人会有所助益。
|
||||
|
||||
gunzip 目前可以解压 gzip,zip,compress,compress -H,pack 产生的文件。gunzip 自动检测输入文件格式。在使用前两种压缩格式时,gunzip 会检验 32 位循环冗余校验码(CRC)。对于 pack 包,gunzip 会检验压缩长度。标准压缩格式设计上不允许相容性检测。不过 gunzip 有时可以检测出坏的 .Z 文件。如果你解压 .Z 文件时出错,不要因为标准解压没报错就认为 .Z 文件一定是正确的。这通常意味着标准解压过程不检测它的输入,而是直接产生一个错误的输出。SCO compress -H 格式(lzh 压缩方法)不包括 CRC 校验码,但也允许一些相容性检查。
|
||||
> `gunzip` 在命令行接受一系列的文件,并且将每个文件内容以正确的魔法数开始,且后缀名为 `.gz`、`-gz`、`.z`、`-z` 或 `_z` (忽略大小写)的压缩文件,用未压缩的文件替换它,并删除其原扩展名。 `gunzip` 也可识别一些特殊扩展名的压缩文件,如 `.tgz` 和 `.taz` 分别是 `.tar.gz` 和 `.tar.Z` 的缩写。在压缩时,`gzip` 在必要情况下使用 `.tgz` 作为扩展名,而不是只截取掉 `.tar` 后缀。
|
||||
|
||||
> `gunzip` 目前可以解压 `gzip`、`zip`、`compress`、`compress -H`(`pack`)产生的文件。`gunzip` 自动检测输入文件格式。在使用前两种压缩格式时,`gunzip` 会检验 32 位循环冗余校验码(CRC)。对于 pack 包,`gunzip` 会检验压缩长度。标准压缩格式在设计上不允许相容性检测。不过 `gunzip` 有时可以检测出坏的 `.Z` 文件。如果你解压 `.Z` 文件时出错,不要因为标准解压没报错就认为 `.Z` 文件一定是正确的。这通常意味着标准解压过程不检测它的输入,而是直接产生一个错误的输出。SCO 的 `compress -H` 格式(lzh 压缩方法)不包括 CRC 校验码,但也允许一些相容性检查。
|
||||
```
|
||||
|
||||
### 结语
|
||||
|
||||
到目前为止提到的 gunzip 基本用法,并不需要过多的学习曲线。我们已包含了一个初学者开始使用它所必须了解的几乎全部知识。想要了解更多的用法,去看 [man page][6] 吧。
|
||||
到目前为止提到的 `gunzip` 基本用法,并不需要过多的学习曲线。我们已包含了一个初学者开始使用它所必须了解的几乎全部知识。想要了解更多的用法,去看 [man 页面][6] 吧。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -71,7 +87,7 @@ via: https://www.howtoforge.com/linux-gunzip-command/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[erialin](https://github.com/erialin)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
|
@ -1,123 +0,0 @@
|
||||
如何在 Linux/Unix 之上绑定 ntpd 到特定的 IP 地址
|
||||
======
|
||||
|
||||
默认的情况下,我们的 ntpd/NTP 服务器会监听所有的端口或者 IP 地址,也就是:0.0.0.0:123。 怎么才可以在一个 Linux 或是 FreeBSD Unix 服务器上,确保只监听特定的 IP 地址,比如 localhost 或者是 192.168.1.1:123 ?
|
||||
|
||||
NTP 是网络时间协议的首字母简写,这是一个用来同步两台电脑之间时间的协议。ntpd 是一个操作系统守护进程,可以设置并且保证系统的时间与互联网标准时间服务器同步。
|
||||
|
||||
[![如何在Linux和Unix服务器,防止 NTPD 监听0.0.0.0:123 并将其绑定到特定的 IP 地址][1]][1]
|
||||
|
||||
NTP使用 `/etc/directory` 之下的 `ntp.conf`作为配置文件。
|
||||
|
||||
|
||||
|
||||
## /etc/ntp.conf 之中的端口指令
|
||||
|
||||
你可以通过设置端口命令来防止 ntpd 监听 0.0.0.0:123,语法如下:
|
||||
|
||||
```
|
||||
interface listen IPv4|IPv6|all
|
||||
interface ignore IPv4|IPv6|all
|
||||
interface drop IPv4|IPv6|all
|
||||
```
|
||||
|
||||
上面的配置可以使 ntpd 监听或者断开一个网络地址而不需要任何的请求。**这样将会** 举个例子,如果要忽略所有端口之上的监听,加入下面的语句到`/etc/ntp.conf`:
|
||||
|
||||
The above configures which network addresses ntpd listens or dropped without processing any requests. **The ignore prevents opening matching addresses, drop causes ntpd to open the address and drop all received packets without examination.** For example to ignore listing on all interfaces, add the following in /etc/ntp.conf:
|
||||
|
||||
`interface ignore wildcard`
|
||||
|
||||
如果只监听 127.0.0.1 和 192.168.1.1 则是这样:
|
||||
|
||||
```
|
||||
interface listen 127.0.0.1
|
||||
interface listen 192.168.1.1
|
||||
```
|
||||
|
||||
这是我 FreeBSD 云服务器上的样例 /etc/ntp.conf 文件:
|
||||
|
||||
`$ egrep -v '^#|$^' /etc/ntp.conf`
|
||||
|
||||
样例输出为:
|
||||
|
||||
```
|
||||
tos minclock 3 maxclock 6
|
||||
pool 0.freebsd.pool.ntp.org iburst
|
||||
restrict default limited kod nomodify notrap noquery nopeer
|
||||
restrict -6 default limited kod nomodify notrap noquery nopeer
|
||||
restrict source limited kod nomodify notrap noquery
|
||||
restrict 127.0.0.1
|
||||
restrict -6 ::1
|
||||
leapfile "/var/db/ntpd.leap-seconds.list"
|
||||
interface ignore wildcard
|
||||
interface listen 172.16.3.1
|
||||
interface listen 10.105.28.1
|
||||
```
|
||||
|
||||
|
||||
## 重启 ntpd
|
||||
|
||||
在 FreeBSD Unix 之上重新加载/重启 ntpd
|
||||
|
||||
`$ sudo /etc/rc.d/ntpd restart`
|
||||
或者 [在Debian和Ubuntu Linux 之上使用下面的命令][2]:
|
||||
`$ sudo systemctl restart ntp`
|
||||
或者 [在CentOS/RHEL 7/Fedora Linux 之上使用下面的命令][2]:
|
||||
`$ sudo systemctl restart ntpd`
|
||||
|
||||
## 校验
|
||||
|
||||
使用 `netstat` 和 `ss` 命令来检查 ntpd只绑定到了特定的 IP 地址:
|
||||
|
||||
`$ netstat -tulpn | grep :123`
|
||||
或是
|
||||
`$ ss -tulpn | grep :123`
|
||||
样例输出:
|
||||
|
||||
```
|
||||
udp 0 0 10.105.28.1:123 0.0.0.0:* -
|
||||
udp 0 0 172.16.3.1:123 0.0.0.0:* -
|
||||
```
|
||||
使用
|
||||
|
||||
使用 [socksata命令(FreeBSD Unix 服务群)][3]:
|
||||
|
||||
```
|
||||
$ sudo sockstat
|
||||
$ sudo sockstat -4
|
||||
$ sudo sockstat -4 | grep :123
|
||||
```
|
||||
|
||||
|
||||
样例输出:
|
||||
|
||||
```
|
||||
root ntpd 59914 22 udp4 127.0.0.1:123 *:*
|
||||
root ntpd 59914 24 udp4 127.0.1.1:123 *:*
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Vivek Gite 投稿
|
||||
|
||||
这个作者是 nixCraft 的作者并且是一位经验丰富的系统管理员,也是一名 Linux 操作系统和 Unix shell 脚本的训练师。他为全球不同行业,包括 IT、教育业、安全防护、空间研究和非营利性组织的客户工作。关注他的 [Twitter][4], [Facebook][5], [Google+][6]。
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.cyberciti.biz/faq/how-to-bind-ntpd-to-specific-ip-addresses-on-linuxunix/
|
||||
|
||||
作者:[Vivek Gite][a]
|
||||
译者:[Drshu](https://github.com/Drshu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.cyberciti.biz
|
||||
[1]:https://www.cyberciti.biz/media/new/faq/2017/10/how-to-prevent-ntpd-to-listen-on-all-interfaces-on-linux-unix-box.jpg
|
||||
[2]:https://www.cyberciti.biz/faq/restarting-ntp-service-on-linux/
|
||||
[3]:https://www.cyberciti.biz/faq/freebsd-unix-find-the-process-pid-listening-on-a-certain-port-commands/
|
||||
[4]:https://twitter.com/nixcraft
|
||||
[5]:https://facebook.com/nixcraft
|
||||
[6]:https://plus.google.com/+CybercitiBiz
|
@ -1,164 +0,0 @@
|
||||
在 Linux 上安装被使用 Docker
|
||||
======
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/use-containers.jpg?itok=s3YLmYHs)
|
||||
|
||||
容器现在风靡于 IT 界 -- 这很好理解。容器是轻量级的,包含应用运行所需所有东西(代码,库,运行时环境,系统设置,以及依赖关系)的独立的包。每个容器都有自己的 CPU,内存,block I/O,以及网络资源,所有这些都不依赖于单独的内核和操作系统。这也是容器与虚拟机之间最大的不同; 相比之下,虚拟机是一个运行于主机操作系统上的完整的操作系统平台,而容器不是。
|
||||
|
||||
容器允许你以一种前所未有的方式扩展交付能力(不管内部还是外部的)。例如,你可以快速部署多个 NGINX 实例(甚至可以应用于多个不同的阶段 -- 比如开发和生产阶段)。跟虚拟机不同,容器不会消耗太多系统资源。
|
||||
|
||||
[Docker][1] 使得创建,部署,和管理容器变得特别简单。更好的是,安装和使用 Docker 在 Linux 平台上特别的方便。
|
||||
|
||||
我将会向你演示在 Linux 上安装 Docker 是多么方便,同时带你入门 Docker。我的演示平台是 [Ubuntu 16.04 Server][2],但流程在大多数其他 Linux 平台都差不多。
|
||||
|
||||
我这里假设你已经启动了 Ubuntu Server 16.04。
|
||||
|
||||
### 安装
|
||||
|
||||
由于 Ubuntu Server 16.04 缺少图形界面,我会完全在完全通过命令行来安装和使用 Docker。在你安装前,你需要更新 apt 然后进行必要的升级。一定要注意,若系统内核升级了,你会需要重启系统。因此最好挑个服务器能重启的时间进行。
|
||||
|
||||
运行下面命令更新 apt:
|
||||
```
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
完成后,使用命令升级系统:
|
||||
```
|
||||
sudo apt upgrade
|
||||
```
|
||||
|
||||
若内核升级了,你需要用下面命令重启服务器:
|
||||
```
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
若内核没有升级,你就可以安装 Docker 了(无需重启)。安装 Docker 的命令为:
|
||||
```
|
||||
sudo apt install docker.io
|
||||
```
|
||||
|
||||
若你使用的是其他 Linux 发行版,当尝试用相应的包管理器来安装时却发现没有 docker.io 包,则你应该安装 docker 包。例如,在 [Fedora][3] 上安装应该用命令:
|
||||
```
|
||||
sudo dnf install docker
|
||||
```
|
||||
|
||||
若你使用的是 CentOS 7,那么最好使用安装脚本来安装 docker。首先使用命令 `sudo yum check-update` 更新系统。升级完后,输入下面命令来下载并运行所需的脚本:
|
||||
```
|
||||
curl -fsSL https://get.docker.com/ | sh
|
||||
```
|
||||
|
||||
默认情况下,只有管理员权限能够运行 docker 命令。考虑到安全问题,你不会想用 root 用户或使用 sudo 来运行 Docker 的。要解决这个问题,你需要将自己的用户加入到 docker 组中。命令如下:
|
||||
```
|
||||
sudo usermod -a -G docker $USER
|
||||
```
|
||||
|
||||
完成操作后,登出系统然后再重新登陆,应该就搞定了。不过若你的平台是 Fedora,则添加用户到 docker 组时会发现这个组是不存在的。那该怎么办呢?你需要首先创建这个组。命令如下:
|
||||
```
|
||||
sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
登出后再登陆。就可以开始用 Docker 了。
|
||||
|
||||
### 启动,暂停以及启用 Docker
|
||||
|
||||
安装好 Docker 后,你可以让系统在启动时自动启动 Docker 守护进程。使用下面两个命令来实现这一点:
|
||||
```
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
```
|
||||
|
||||
若需要暂停或重启 Docker 守护进程,则命令为:
|
||||
```
|
||||
sudo systemctl stop docker
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
现在可以用 Docker 来部署容器了。
|
||||
|
||||
### 拉取镜像
|
||||
|
||||
对 Docker 来说,镜像是构建容器的基石。你可以拉下一个镜像 (比如 [NGINX][4]) 然后根据这个镜像部署任意多个容器出来。使用镜像前,你首先需要把镜像拉取到系统中。镜像从注册仓库中拉取,默认情况下安装好的 Docker 包含了一个默认的注册仓库 [Docker Hub][5] -- 这个注册仓库包含了大量别人所贡献的镜像(即包活官方的镜像也包括用户自己贡献的镜像)。
|
||||
|
||||
假设你想要拉取一个 Nginx web 服务器相关的镜像。在开始拉取前,先检查一下系统中已经有了哪些镜像。输入 `docker images` 命令你会发现现在还没有镜像存在(图 1)。
|
||||
|
||||
![Docker][7]
|
||||
|
||||
|
||||
图 1:还没有镜像。
|
||||
|
||||
[Used with permission][8]
|
||||
|
||||
让我们来拉取一个镜像。使用下面命令可以从 Docker Hub 中下载 Nginx 镜像:
|
||||
```
|
||||
docker pull nginx
|
||||
```
|
||||
|
||||
上面命令会从 Docker Hub 下载最新的(官方的) Nginx 镜像。现在再运行 `docker images` 命令就能看到有列出镜像了(图 2)。
|
||||
|
||||
![Docker][10]
|
||||
|
||||
|
||||
图 2:NGINX 镜像已经被拉取下来了。
|
||||
|
||||
[Used with permission][8]
|
||||
|
||||
注意到我这里说的是 "官方" Nginx 镜像了吗?在 Docker Hub 上有很多的非官方 Nginx 镜像。这些非官方镜像都是基于各种不同的目的而创建出来的。你可以使用下面过命令来搜索 Docker Hub 中的所有 Nginx 镜像
|
||||
```
|
||||
docker search nginx
|
||||
```
|
||||
|
||||
你会发现(图 3),有很多基于不同目的所创建的 Nginx 镜像(反向代理,PHP-FPM(LCTT 注:FastCGI Process Manager(FastCGI 进程管理器)是一个 PHPFastCGI 管理器,旨在将 FastCGI 进程管理整合进 PHP 包中。)功能,LetsEncrypt(LCTT 注:由 ISRG(Internet Security Research Group) 提供的免费 SSL 项目),Bitnami(LCTT 注:一个开源项目,提供 wordpress、joomla、drupal、bbpress 等开源程序的傻瓜式安装包下载,所有的安装包内置了服务器环境),在树梅派上使用 Nginx 和 Drupal,等等很多很多)。
|
||||
|
||||
![Docker hub][12]
|
||||
|
||||
|
||||
图 3:Docker Hub 上找到的各种 NGINX 镜像。
|
||||
|
||||
[Used with permission][8]
|
||||
|
||||
|
||||
假设,你想要下载内建有反向代理功能的 Nginx 镜像。这个非官方的镜像为 jwilder/nginx-proxy。因此输入下面命令来拉取这个镜像:
|
||||
```
|
||||
docker pull jwilder/nginx-proxy
|
||||
```
|
||||
|
||||
再输入 `docker images` 命令来查看新拉下来的这个镜像(图 4)。
|
||||
|
||||
![Nginx][14]
|
||||
|
||||
|
||||
图 4:已经有了两种不同的 NGINX 镜像了。
|
||||
|
||||
[Used with permission][8]
|
||||
|
||||
处于谨慎考虑,我建议只使用官方镜像,毕竟你无法确定非官方镜像是否包含了恶意代码。
|
||||
|
||||
有了镜像后就可以用它来部署容器了。下次我们再聊聊如何通过这些 Nginx 镜像来发布容器。
|
||||
|
||||
Docker 是一个超级强力的系统可以让你的工作更简单,让你的公司更具有伸缩性,也更灵活。想知道 Docker 还能做什么,运行 `man docker` 然后阅读他的帮助文档吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/learn/intro-to-linux/2017/11/how-install-and-use-docker-linux
|
||||
|
||||
作者:[Jack Wallen][a]
|
||||
译者:[lujun9972](https://github.com/lujun9972)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linux.com/users/jlwallen
|
||||
[1]:https://www.docker.com/
|
||||
[2]:http://releases.ubuntu.com/16.04/
|
||||
[3]:https://getfedora.org/
|
||||
[4]:https://www.nginx.com/
|
||||
[5]:https://hub.docker.com/
|
||||
[6]:/files/images/docker1jpg
|
||||
[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_1.jpg?itok=CxSyyXyF (Docker)
|
||||
[8]:/licenses/category/used-permission
|
||||
[9]:/files/images/docker2jpg
|
||||
[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_2.jpg?itok=TESa7bYr (Docker)
|
||||
[11]:/files/images/docker3jpg
|
||||
[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_3.jpg?itok=_7F4QWqx (Docker hub)
|
||||
[13]:/files/images/docker4jpg
|
||||
[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/docker_4.jpg?itok=f13E1L0Q (Nginx)
|
@ -0,0 +1,85 @@
|
||||
Torrents - 你需要知道的一切事情
|
||||
======
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrenting-how-torrent-works_orig.jpg)
|
||||
|
||||
**Torrents** — 每次听到这个词时,在我的脑海里想到的唯一的事情就是免费的电影、游戏、和被破解的软件。但是我们并不知道它们是如何工作的,在 Torrents 中涉及到各种概念。因此,通过这篇文章我们从技术的角度来了解 **torrenting** 是什么。
|
||||
|
||||
### Torrents 是什么?
|
||||
|
||||
Torrents 是一个到因特网上文件位置的链接。它们不是一个文件,它们仅仅是动态指向到你想去下载的原始文件上。
|
||||
|
||||
例如:如果你点击 [Google Chrome][1],你可以从谷歌的服务器上下载 Google Chrome 浏览器。
|
||||
|
||||
如果你明天、或者下周、或者下个月再去点击那个链接,这个文件仍然可以从谷歌服务器上去下载。
|
||||
|
||||
但是当我们使用 torrents 下载时,它并没有固定的服务器。文件是从以前使用 torrents 下载的其它人的个人电脑上下载的。
|
||||
|
||||
### Torrents 是如何工作的?
|
||||
|
||||
[![Peer to peer network](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent_orig.png)][2]
|
||||
|
||||
假设 ‘A’ 上有一些视频,它希望以 torrent 方式去下载。因此,他创建了一个 torrent,并将这个链接发送给 ‘B’,这个链接包含了那个视频在因特网上的准确 IP 地址的信息。因此,当 ‘B’ 开始下载那个文件的时候,‘B’ 连接到 ‘A’ 的计算机。在 ‘B’ 下载完成这个视频之后,‘B’ 将开始做为种子,也就是 ‘B’ 将允许其它的 ‘C’ 或者 ‘D’ 从 ‘B’ 的计算机上下载它。
|
||||
|
||||
因此每个人先下载文件然后会上传,下载的人越多,下载的速度也越快。并且在任何情况下,如果想停止上传,也没有问题,随时可以。这样做并不会成为什么问题,除非很多的人下载而上传的人很少。
|
||||
|
||||
### 播种者和索取者
|
||||
|
||||
[![kickass torrents website](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/seeders_orig.png)][3]
|
||||
|
||||
下载完成特定文件的用户将会即刻做为上传者,因此,可以被新用户下载的已下载者称为播种者。
|
||||
|
||||
而一些还没有完成特定文件的下载者,并且还正在下载的用户称为索取者。
|
||||
|
||||
### 块
|
||||
|
||||
[![qbittorrent software for linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/peers_orig.png)][4]
|
||||
|
||||
所有的 torrent 文件都独立分割成固定大小的数据包,因此,它们可以非线性顺序和随机顺序下载。每个块都有唯一的标识,因此,一旦所有的块下载完成之后,它们会被拼接出原始文件。
|
||||
|
||||
正是因为这种机制,如果你正在从某人处下载一个文件,假如这个时候因某些原因他停止了上传,你可以继续从其它的播种者处继续下载,而不需要从头开始重新下载。
|
||||
|
||||
### 对端
|
||||
|
||||
对端是指当前连接到你的索取者。一个正在上传的索取者,不论它下载了多少块,它就是一个对端。
|
||||
|
||||
**例如:**
|
||||
|
||||
一个已经下载了文件的前 50 个块的用户就是一个索取者,但是,他又同时上传这些文件,而你只有前 10 个块,因此,你可以从他那里下载最多 50 个块。这时候他就成了你的对端。
|
||||
|
||||
### 最佳实践
|
||||
|
||||
当你下载一个 torrent 时,总是选择最大的播种者。这就是最佳经验。
|
||||
|
||||
这里并没有最小的标准,但是只要确保你选择的是最大的那一个播种者就可以了。
|
||||
|
||||
### Torrent 相关的法律
|
||||
|
||||
[![piracy is illegal](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent-laws_orig.png)][5]
|
||||
|
||||
Torrent 相关的法律和其它的法律并没有什么区别,对受版权保护的其它任何东西一样,侵权行为会受到法律的制裁。大多数的政府都拦截 torrent 站点和协议,但是 torrenting 本身并不是有害的东西。
|
||||
|
||||
Torrents 对快速分享文件是非常有用的,并且它们被用来共享开源社区的软件,因为它们能节约大量的服务器资源。但是,许多人却因为盗版而使用它们。
|
||||
|
||||
### 结束语
|
||||
|
||||
Torrenting 是降低服务器上负载的一个非常完美的技术。Torrenting 可以使我们将下载速度提升到网卡的极限,这是非常好的。但是,在这种非中心化的服务器上,盗版成为一种必然发生的事。限制我们分享的内容,从不去下载盗版的东西,这是我们的道德责任。
|
||||
|
||||
请在下面的评论中分享你使用 torrents 的心得,分享你喜欢的、法律许可下载的 torrent 网站。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxandubuntu.com/home/torrents-everything-you-need-to-know
|
||||
|
||||
作者:[LINUXANDUBUNTU][a]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxandubuntu.com
|
||||
[1]:https://www.google.com/chrome/
|
||||
[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent_orig.png
|
||||
[3]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/seeders_orig.png
|
||||
[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/peers_orig.png
|
||||
[5]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/torrent-laws_orig.png
|
@ -0,0 +1,153 @@
|
||||
使用 Ansible 在树莓派上构建一个基于 Linux 的高性能计算系统
|
||||
============================================================
|
||||
|
||||
### 使用低成本的硬件和开源软件设计一个高性能计算集群。
|
||||
|
||||
![Building a Linux-based HPC system on the Raspberry Pi with Ansible](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 "Building a Linux-based HPC system on the Raspberry Pi with Ansible")
|
||||
图片来源:opensource.com
|
||||
|
||||
在我的 [Opensource.com 上前面的文章中][14],我介绍了 [OpenHPC][15] 项目,它的目标是致力于加速高性能计算(HPC)的创新。这篇文章将更深入来介绍使用 OpenHPC 的特性来构建一个小型的 HPC 系统。将它称为 _HPC 系统_ 可能有点“扯虎皮拉大旗”的意思,因此,更确切的说法应该是,通过 OpenHPC 项目发布的 [方法构建集群][16] 系统。
|
||||
|
||||
这个集群由两台树莓派 3 系统作为活动计算节点,以及一台虚拟机作为主节点,结构示意如下:
|
||||
|
||||
|
||||
![Map of HPC cluster](https://opensource.com/sites/default/files/u128651/hpc_with_pi-1.png "Map of HPC cluster")
|
||||
|
||||
我的主节点运行的是 x86_64 架构的 CentOS 操作系统,而计算节点运行了 aarch64 的轻度修改版的 CentOS 操作系统。
|
||||
|
||||
下图是真实的设备工作照:
|
||||
|
||||
|
||||
![HPC hardware setup](https://opensource.com/sites/default/files/u128651/hpc_with_pi-2.jpg "HPC hardware setup")
|
||||
|
||||
去配置一台像上图这样的 HPC 系统,我是按照 OpenHPC 集群构建方法 —— [CentOS 7.4/aarch64 + Warewulf + Slurm 安装指南][17] (PDF) 的一些步骤来做的。这个方法包括 [Warewulf][18] 提供的使用说明;因为我的那三个系统是手动安装的,我跳过了 Warewulf 部分以及创建 [Ansible playbook][19] 的一些步骤。
|
||||
|
||||
|
||||
在 [Ansible][26] playbooks 中设置完成我的集群之后,我就可以向资源管理器提交作业了。在我的这个案例中, [Slurm][27] 充当了资源管理器,它是集群中的一个实例,由它来决定我的作业什么时候在哪里运行。其中一种可做的事情是,在集群上启动一个简单的作业:
|
||||
```
|
||||
[ohpc@centos01 ~]$ srun hostname
|
||||
calvin
|
||||
```
|
||||
|
||||
如果需要更多的资源,我可以去告诉 Slurm,我希望在 8 个 CPU 上去运行我的命令:
|
||||
|
||||
```
|
||||
[ohpc@centos01 ~]$ srun -n 8 hostname
|
||||
hobbes
|
||||
hobbes
|
||||
hobbes
|
||||
hobbes
|
||||
calvin
|
||||
calvin
|
||||
calvin
|
||||
calvin
|
||||
```
|
||||
|
||||
在第一个示例中,Slurm 在一个单个的 CPU 上运行了指定的命令(`hostname`),而在第二个示例中,Slurm 在 8 个 CPU 上运行了那个命令。我的计算节点一个命名为 `calvin`,而另一个命名为 `hobbes`;在上面的命令输出部分可以看到它们的名字。每个计算节点都是由 4 个 CPU 核心的树莓派 3 构成的。
|
||||
|
||||
在我的集群中提交作业的另一种方法是使用命令 `sbatch`,它可以用于运行脚本,将输出写入到一个文件,而不是我的终端上。
|
||||
|
||||
```
|
||||
[ohpc@centos01 ~]$ cat script1.sh
|
||||
#!/bin/sh
|
||||
date
|
||||
hostname
|
||||
sleep 10
|
||||
date
|
||||
[ohpc@centos01 ~]$ sbatch script1.sh
|
||||
Submitted batch job 101
|
||||
```
|
||||
|
||||
它将创建一个名为 `slurm-101.out` 的输出文件,这个输出文件包含下列的内容:
|
||||
|
||||
```
|
||||
Mon 11 Dec 16:42:31 UTC 2017
|
||||
calvin
|
||||
Mon 11 Dec 16:42:41 UTC 2017
|
||||
```
|
||||
|
||||
为示范资源管理器的基本功能、简单的和一系列的命令行工具,这个集群系统是挺合适的,但是,去配置一个类似HPC 系统去做各种工作就有点无聊了。
|
||||
|
||||
一个更有趣的应用是在这个集群的所有可用 CPU 上运行一个 [Open MPI][20] 并行作业。我使用了一个基于 [Game of Life][21] 的应用,它被用于一个名为“使用 Red Hat 企业版 Linux 跨多种架构运行 `Game of Life`“的 [视频][22]。除了以前实现的基于 MPI 的 `Game of Life` 之外,在我的集群中现在运行的这个版本对每个涉及的主机的单元格颜色都是不同的。下面的脚本以图形输出的方式来交互式启动应用:
|
||||
|
||||
```
|
||||
$ cat life.mpi
|
||||
#!/bin/bash
|
||||
|
||||
module load gnu6 openmpi3
|
||||
|
||||
if [[ "$SLURM_PROCID" != "0" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
mpirun ./mpi_life -a -p -b
|
||||
```
|
||||
|
||||
我使用下面的命令来启动作业,它告诉 Slurm,为这个作业分配 8 个 CPU:
|
||||
|
||||
```
|
||||
$ srun -n 8 --x11 life.mpi
|
||||
```
|
||||
|
||||
为了演示,这个作业有一个图形界面,它展示了当前计算的结果:
|
||||
|
||||
|
||||
![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-3.png)
|
||||
|
||||
红色单元格是由其中一个计算节点来计算的,而绿色单元格是由另外一个计算节点来计算的。我也可以让 `Game of Life` 程序为使用的每个 CPU 核心(这里的每个计算节点有四个核心)去生成不同的颜色,这样它的输出如下:
|
||||
|
||||
|
||||
![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-4.png)
|
||||
|
||||
感谢 OpenHPC 提供的软件包和安装方法,因为它们我可以去配置一个由两个计算节点和一个主节点的 HPC 式的系统。我可以在资源管理器上提交作业,然后使用 OpenHPC 提供的软件在我的树莓派的 CPU 上去启动 MPI 应用程序。
|
||||
|
||||
* * *
|
||||
|
||||
_想学习更多的关于使用 OpenHPC 去构建树莓派集群,请参与 Adrian Reber 在 [DevConf.cz 2018][10] 的讨论,它于 1月 26-28 日在 Brno,Czech Republic 举行,以及在 [CentOS Dojo 2018][11] ,它于 2 月 2 日在 Brussels 举行。_
|
||||
|
||||
### 关于作者
|
||||
|
||||
[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/gotchi-square.png?itok=PJKu7LHn)][23] Adrian Reber —— Adrian 是 Red Hat 的高级软件工程师,他早在 2010 年就开始了迁移的过程,迁移到高性能计算环境中,从那个时候起迁移了许多的程序,并因此获得了博士学位,然后加入了 Red Hat 公司并开始去迁移到容器。偶尔他仍然去迁移单个进程,并且它至今仍然对高性能计算非常感兴趣。[关于我的更多信息点这里][12]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/how-build-hpc-system-raspberry-pi-and-openhpc
|
||||
|
||||
作者:[Adrian Reber ][a]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/adrianreber
|
||||
[1]:https://opensource.com/resources/what-are-linux-containers?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[2]:https://opensource.com/resources/what-docker?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[3]:https://opensource.com/resources/what-is-kubernetes?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[4]:https://developers.redhat.com/blog/2016/01/13/a-practical-introduction-to-docker-container-terminology/?utm_campaign=containers&intcmp=70160000000h1s6AAA
|
||||
[5]:https://opensource.com/file/384031
|
||||
[6]:https://opensource.com/file/384016
|
||||
[7]:https://opensource.com/file/384021
|
||||
[8]:https://opensource.com/file/384026
|
||||
[9]:https://opensource.com/article/18/1/how-build-hpc-system-raspberry-pi-and-openhpc?rate=l9n6B6qRcR20LJyXEoUoWEZ4mb2nDc9sFZ1YSPc60vE
|
||||
[10]:https://devconfcz2018.sched.com/event/DJYi/openhpc-introduction
|
||||
[11]:https://wiki.centos.org/Events/Dojo/Brussels2018
|
||||
[12]:https://opensource.com/users/adrianreber
|
||||
[13]:https://opensource.com/user/188446/feed
|
||||
[14]:https://opensource.com/article/17/11/openhpc
|
||||
[15]:https://openhpc.community/
|
||||
[16]:https://openhpc.community/downloads/
|
||||
[17]:https://github.com/openhpc/ohpc/releases/download/v1.3.3.GA/Install_guide-CentOS7-Warewulf-SLURM-1.3.3-aarch64.pdf
|
||||
[18]:https://en.wikipedia.org/wiki/Warewulf
|
||||
[19]:http://people.redhat.com/areber/openhpc/ansible/
|
||||
[20]:https://www.open-mpi.org/
|
||||
[21]:https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
|
||||
[22]:https://www.youtube.com/watch?v=n8DvxMcOMXk
|
||||
[23]:https://opensource.com/users/adrianreber
|
||||
[24]:https://opensource.com/users/adrianreber
|
||||
[25]:https://opensource.com/users/adrianreber
|
||||
[26]:https://www.ansible.com/
|
||||
[27]:https://slurm.schedmd.com/
|
||||
[28]:https://opensource.com/tags/raspberry-pi
|
||||
[29]:https://opensource.com/tags/programming
|
||||
[30]:https://opensource.com/tags/linux
|
||||
[31]:https://opensource.com/tags/ansible
|
@ -0,0 +1,131 @@
|
||||
# 如何在 Linux / Unix 上使用 awk 打印文件名
|
||||
|
||||
我想在 Linux / 类Unix 系统上使用 awk 打印文件名。 如何使用 awk 的 BEGIN 特殊模式打印文件名? 我可以使用 gawk/awk 打印当前输入文件的名称吗?( LCTT 注:读者最好能有一些 awk 的背景知识,否则阅读本文的时候会有一些困惑)
|
||||
|
||||
在 FILENAME 变量中存放着当前输入文件的名称。 您可以使用 FILENAME 显示或打印当前输入文件名,如果在命令行中未指定文件,则FILENAME的值为“ - ”(标准输入)( LCTT 注:多次按下回车键即可看到效果)。 但是,除非由 getline 设置,否则 FILENAME 在 BEGIN 特殊模式中未定义。
|
||||
|
||||
### 使用 awk 打印文件名
|
||||
|
||||
使用语法如下:
|
||||
|
||||
```
|
||||
awk '{ print FILENAME }' fileNameHere
|
||||
awk '{ print FILENAME }' /etc/hosts
|
||||
```
|
||||
因 awk 逐行读取文件,因此,你可能看到多个文件名,为了避免这个情况,你可以使用如下的命令:( LCTT注:FNR 表示当前记录数,只在文件中有效)
|
||||
|
||||
```
|
||||
awk 'FNR == 1{ print FILENAME } ' /etc/passwd
|
||||
awk 'FNR == 1{ print FILENAME } ' /etc/hosts
|
||||
```
|
||||
![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-print-filename-using-awk-on-Linux-or-Unix.jpg)
|
||||
|
||||
### 使用 awk 的 BEGIN 特殊规则打印文件名
|
||||
|
||||
使用下面的语法:( LCTT 注:ARGV[I] 表示输入的第 i 个参数)
|
||||
|
||||
```
|
||||
awk 'BEGIN{print ARGV[1]}' fileNameHere
|
||||
awk 'BEGIN{print ARGV[1]}{ print "someting or do something on data" }END{}' fileNameHere
|
||||
awk 'BEGIN{print ARGV[1]}' /etc/hosts
|
||||
```
|
||||
示例输出:
|
||||
|
||||
```
|
||||
/etc/hosts
|
||||
|
||||
```
|
||||
|
||||
然而,ARGV\[1\] 并不是每一次都能奏效,例如:
|
||||
|
||||
`ls -l /etc/hosts | awk 'BEGIN{print ARGV[1]} { print }'`
|
||||
|
||||
你需要将它修改如下(假设 ls -l 只产生一行输出):
|
||||
|
||||
`ls -l /etc/hosts | awk '{ print "File: " $9 ", Owner:" $3 ", Group: " $4 }'`
|
||||
|
||||
示例输出:
|
||||
|
||||
```
|
||||
File: /etc/hosts, Owner:root, Group: root
|
||||
|
||||
```
|
||||
|
||||
### 处理由通配符指定的多个文件名
|
||||
|
||||
使用如下的示例语法:
|
||||
|
||||
```
|
||||
awk '{ print FILENAME; nextfile } ' *.c
|
||||
awk 'BEGIN{ print "Starting..."} { print FILENAME; nextfile }END{ print "....DONE"} ' *.conf
|
||||
```
|
||||
示例输出:
|
||||
|
||||
```
|
||||
Starting...
|
||||
blkid.conf
|
||||
cryptconfig.conf
|
||||
dhclient6.conf
|
||||
dhclient.conf
|
||||
dracut.conf
|
||||
gai.conf
|
||||
gnome_defaults.conf
|
||||
host.conf
|
||||
idmapd.conf
|
||||
idnalias.conf
|
||||
idn.conf
|
||||
insserv.conf
|
||||
iscsid.conf
|
||||
krb5.conf
|
||||
ld.so.conf
|
||||
logrotate.conf
|
||||
mke2fs.conf
|
||||
mtools.conf
|
||||
netscsid.conf
|
||||
nfsmount.conf
|
||||
nscd.conf
|
||||
nsswitch.conf
|
||||
openct.conf
|
||||
opensc.conf
|
||||
request-key.conf
|
||||
resolv.conf
|
||||
rsyncd.conf
|
||||
sensors3.conf
|
||||
slp.conf
|
||||
smartd.conf
|
||||
sysctl.conf
|
||||
vconsole.conf
|
||||
warnquota.conf
|
||||
wodim.conf
|
||||
xattr.conf
|
||||
xinetd.conf
|
||||
yp.conf
|
||||
....DONE
|
||||
|
||||
```
|
||||
|
||||
nextfile 告诉 awk 停止处理当前的输入文件。 下一个输入记录读取来自下一个输入文件。 更多信息,请参见 awk/[gawk][1] 命令手册页:
|
||||
|
||||
```
|
||||
man awk
|
||||
man gawk
|
||||
```
|
||||
|
||||
### 关于作者
|
||||
|
||||
作者是 nixCraft 的创立者,也是经验丰富的系统管理员和 Linux/Unix shell 脚本的培训师。 他曾与全球各行各业的客户合作,涉及 IT,教育,国防和空间研究以及非营利部门等多个行业。 您可以在 [Twitter][2],[Facebook][3] 和 [Google+][4]上关注他。 可以通过订阅我的 [RSS][5] 来获取更多的关于**系统管理,Linux/Unix ,和开源主题**的相关资料。
|
||||
|
||||
via: https://www.cyberciti.biz/faq/how-to-print-filename-with-awk-on-linux-unix/
|
||||
|
||||
作者:Vivek GIte[][a]
|
||||
译者:[amwps290](https://github.com/amwps290)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.cyberciti.biz/
|
||||
[1]:https://www.gnu.org/software/gawk/manual/
|
||||
[2]:https://twitter.com/nixcraft
|
||||
[3]:https://facebook.com/nixcraft
|
||||
[4]:https://plus.google.com/+CybercitiBiz
|
||||
[5]:https://www.cyberciti.biz/atom/atom.xml
|
86
sources/tech/20180206 Programming in Color with ncurses.md → translated/tech/20180206 Programming in Color with ncurses.md
Normal file → Executable file
86
sources/tech/20180206 Programming in Color with ncurses.md → translated/tech/20180206 Programming in Color with ncurses.md
Normal file → Executable file
@ -1,17 +1,16 @@
|
||||
Leemeans translating
|
||||
Programming in Color with ncurses
|
||||
使用ncurses进行颜色编程
|
||||
======
|
||||
In parts [one][1] and [two][2] of my article series about programming with the ncurses library, I introduced a few curses functions to draw text on the screen, query characters from the screen and read from the keyboard. To demonstrate several of these functions, I created a simple adventure game in curses that drew a game map and player character using simple characters. In this follow-up article, I show how to add color to a curses program.
|
||||
在我的使用ncurses库进行编程的系列文章的[第一篇][1]和[第二篇][2]中,我已经介绍了一些curses的函数来在屏幕上作画、从屏幕上查询和从键盘读取字符。为了搞清楚这些函数,我使用curses来利用简单字符绘制游戏地图和玩家字符创建了一个简单的冒险游戏。在这篇紧接着的文章里,我展示了如何为你的curses程序添加颜色。
|
||||
|
||||
Drawing on the screen is all very well and good, but if it's all white-on-black text, your program might seem dull. Colors can help convey more information—for example, if your program needs to indicate success or failure. In such a case, you could display text in green or red to help emphasize the outcome. Or, maybe you simply want to use colors to "snazz" up your program to make it look prettier.
|
||||
在屏幕上绘图一切都挺好的,但是如果只有黑底白字的文本,你的程序可能看起来很无趣。颜色可以帮助传递更多的信息。举个例子,如果你的程序需要报告(执行)成功或者(执行)失败时。在这样的情况下你可以使用绿色或者红色来帮助强调输出。或者,你只是简单地想要“潮艺”一下给你的程序来让它看起来更美观。
|
||||
|
||||
In this article, I use a simple example to demonstrate color manipulation via the curses functions. In my previous article, I wrote a basic adventure-style game that lets you move a player character around a crudely drawn map. However, the map was entirely black and white text, relying on shapes to suggest water (~) or mountains (^), so let's update the game to use colors.
|
||||
在这篇文章中,我用一个简单的例子来展示通过curses函数进行颜色操作。在我先前的文章中,我写了一个允许你在一个粗糙绘制的地图上移动玩家字符的初级冒险类游戏。但是那里面的地图完全是白色和黑色的文本,通过形状来表明是水(~)或者山(^)。所以,让我们将游戏更新到使用颜色(的版本)吧。
|
||||
|
||||
### Color Essentials
|
||||
### 颜色要素
|
||||
|
||||
Before you can use colors, your program needs to know if it can rely on the terminal to display the colors correctly. On modern systems, this always should be true. But in the classic days of computing, some terminals were monochromatic, such as the venerable VT52 and VT100 terminals, usually providing white-on-black or green-on-black text.
|
||||
在你可以使用颜色之前,你的程序得要知道它是否可以依靠终端正确地显示颜色。在现代操作系统上,此处应该永远为true。但是在经典的计算机上,一些终端是单色的,例如令人尊敬的VT52和VT100终端,一般(它们)提供黑底白色或者黑底绿色的文本。
|
||||
|
||||
To query the terminal capability for colors, use the has_colors() function. This will return a true value if the terminal can display color, and a false value if not. It is usually used to start an if block, like this:
|
||||
可以使用has_colors()函数查询终端的颜色功能。这个函数将会在终端可以显示颜色的时候返回true,否则将会返回false。这个函数一般用于if块的开头,就像这样:
|
||||
|
||||
```
|
||||
|
||||
@ -23,9 +22,9 @@ if (has_colors() == FALSE) {
|
||||
|
||||
```
|
||||
|
||||
Having determined that the terminal can display color, you then can set up curses to use colors with the start_color() function. Now you're ready to define the colors your program will use.
|
||||
在知道终端可以显示颜色之后,你可以使用start_color()函数来设置curses使用颜色。现在是时候定义程序将要使用的颜色了。
|
||||
|
||||
In curses, you define colors in pairs: a foreground color on a background color. This allows curses to set both color attributes at once, which often is what you want to do. To establish a color pair, use init_pair() to define a foreground and background color, and associate it to an index number. The general syntax is:
|
||||
在curses中,你应该按对定义颜色:一个前景色放在一个背景色上。这样允许curses一次性设置两个颜色属性,这也是一般你想要使用的方式。通过init_pair()函数可以定义一个前景色和背景色并关联到索引数字来设置颜色对。大致语法如下:
|
||||
|
||||
```
|
||||
|
||||
@ -33,7 +32,7 @@ init_pair(index, foreground, background);
|
||||
|
||||
```
|
||||
|
||||
Consoles support only eight basic colors: black, red, green, yellow, blue, magenta, cyan and white. These colors are defined for you with the following names:
|
||||
控制台支持八种基础的颜色:黑色、红色、绿色、黄色、蓝色、品红色、青色和白色。这些颜色通过下面的名称为你定义好了:
|
||||
|
||||
* COLOR_BLACK
|
||||
|
||||
@ -51,9 +50,9 @@ Consoles support only eight basic colors: black, red, green, yellow, blue, magen
|
||||
|
||||
* COLOR_WHITE
|
||||
|
||||
### Applying the Colors
|
||||
### 应用颜色
|
||||
|
||||
In my adventure game, I'd like the grassy areas to be green and the player's "trail" to be a subtle yellow-on-green dotted path. Water should be blue, with the tildes in the similar cyan color. I'd like mountains to be grey, but black text on a white background should make for a reasonable compromise. To make the player's character more visible, I'd like to use a garish red-on-magenta scheme. I can define these colors pairs like so:
|
||||
在我的冒险游戏中,我想要让草地呈现绿色而玩家的足迹变成不易察觉的绿底黄色点迹。水应该是蓝色,那些(表示波浪的)腭化符号应该是近似青色的。我想让山是灰色的,但是我可以用白底黑色文本做一个可用的折中方案。(译注:意为终端预设的颜色没有灰色,使用白底黑色文本做一个折中方案)为了让玩家的字符更易见,我想要使用一个刺目的品红底红色设计。我可以像这样定义这些颜色对:
|
||||
|
||||
```
|
||||
|
||||
@ -65,8 +64,7 @@ init_pair(4, COLOR_RED, COLOR_MAGENTA);
|
||||
|
||||
```
|
||||
|
||||
To make my color pairs easy to remember, my program defines a few symbolic constants:
|
||||
|
||||
为了让颜色对更容易记忆,我的程序中定义了一些符号常量:
|
||||
```
|
||||
|
||||
#define GRASS_PAIR 1
|
||||
@ -77,8 +75,7 @@ To make my color pairs easy to remember, my program defines a few symbolic const
|
||||
|
||||
```
|
||||
|
||||
With these constants, my color definitions become:
|
||||
|
||||
有了这些常量,我的颜色定义就变成了:
|
||||
```
|
||||
|
||||
start_color();
|
||||
@ -89,8 +86,7 @@ init_pair(PLAYER_PAIR, COLOR_RED, COLOR_MAGENTA);
|
||||
|
||||
```
|
||||
|
||||
Whenever you want to display text using a color, you just need to tell curses to set that color attribute. For good programming practice, you also should tell curses to undo the color combination when you're done using the colors. To set the color, use attron() before calling functions like mvaddch(), and then turn off the color attributes with attroff() afterward. For example, when I draw the player's character, I might do this:
|
||||
|
||||
在任何时候你想要使用颜色显示文本,你只需要告诉curses设置那种颜色属性。为了更好的编程实践,你同样应该在你完成了颜色使用的时候告诉curses取消颜色组合。为了设置颜色,应该在调用像mvaddch()这样的函数之前使用attron(),然后通过attroff()关闭颜色属性。例如,在我绘制玩家的字符的时候,我应该这样做:
|
||||
```
|
||||
|
||||
attron(COLOR_PAIR(PLAYER_PAIR));
|
||||
@ -99,8 +95,7 @@ attroff(COLOR_PAIR(PLAYER_PAIR));
|
||||
|
||||
```
|
||||
|
||||
Note that applying colors to your programs adds a subtle change to how you query the screen. Normally, the value returned by mvinch() is of type chtype Without color attributes, this is basically an integer and can be used as such. But, colors add extra attributes to the characters on the screen, so chtype carries extra color information in an extended bit pattern. If you use mvinch(), the returned value will contain this extra color value. To extract just the "text" value, such as in the is_move_okay() function, you need to apply a bitwise & with the A_CHARTEXT bit mask:
|
||||
|
||||
记住将颜色应用到你的程序添加了不可见的改变到你如何查询屏幕。一般来讲,由mvinch()函数返回的值是**没有**带颜色属性的类型chtype,这个值基本上是一个整型值也可以就当作整型值来用。但是,由于(使用)颜色添加了额外的属性到屏幕上的字符上,所以chtype按照扩展的位模式携带了额外的颜色信息。一旦你使用mvinch(),返回值将会包含这些额外的颜色值。为了只提取**文本**值,例如在is_move_okay()函数中,你需要和A_CHARTEXT做&位运算:
|
||||
```
|
||||
|
||||
int is_move_okay(int y, int x)
|
||||
@ -116,8 +111,7 @@ int is_move_okay(int y, int x)
|
||||
|
||||
```
|
||||
|
||||
With these changes, I can update the adventure game to use colors:
|
||||
|
||||
通过这些修改,我可以用颜色更新这个冒险游戏:
|
||||
```
|
||||
|
||||
/* quest.c */
|
||||
@ -145,14 +139,14 @@ int main(void)
|
||||
int y, x;
|
||||
int ch;
|
||||
|
||||
/* initialize curses */
|
||||
/* 初始化curses */
|
||||
|
||||
initscr();
|
||||
keypad(stdscr, TRUE);
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
/* initialize colors */
|
||||
/* 初始化颜色 */
|
||||
|
||||
if (has_colors() == FALSE) {
|
||||
endwin();
|
||||
@ -168,19 +162,18 @@ int main(void)
|
||||
|
||||
clear();
|
||||
|
||||
/* initialize the quest map */
|
||||
/* 初始化探索地图 */
|
||||
|
||||
draw_map();
|
||||
|
||||
/* start player at lower-left */
|
||||
/* 在左下角创建新角色 */
|
||||
|
||||
y = LINES - 1;
|
||||
x = 0;
|
||||
|
||||
do {
|
||||
|
||||
/* by default, you get a blinking cursor - use it to
|
||||
indicate player * */
|
||||
/* 默认情况下,你获得了一个闪烁的光标--用来指明玩家 * */
|
||||
|
||||
attron(COLOR_PAIR(PLAYER_PAIR));
|
||||
mvaddch(y, x, PLAYER);
|
||||
@ -190,7 +183,7 @@ int main(void)
|
||||
|
||||
ch = getch();
|
||||
|
||||
/* test inputted key and determine direction */
|
||||
/* 测试输入键值并获取方向 */
|
||||
|
||||
switch (ch) {
|
||||
case KEY_UP:
|
||||
@ -246,7 +239,7 @@ int is_move_okay(int y, int x)
|
||||
{
|
||||
int testch;
|
||||
|
||||
/* return true if the space is okay to move into */
|
||||
/* 当空白处可以进入的时候返回true */
|
||||
|
||||
testch = mvinch(y, x);
|
||||
return (((testch & A_CHARTEXT) == GRASS)
|
||||
@ -257,9 +250,9 @@ void draw_map(void)
|
||||
{
|
||||
int y, x;
|
||||
|
||||
/* draw the quest map */
|
||||
/* 绘制探索地图 */
|
||||
|
||||
/* background */
|
||||
/* 背景 */
|
||||
|
||||
attron(COLOR_PAIR(GRASS_PAIR));
|
||||
for (y = 0; y < LINES; y++) {
|
||||
@ -267,7 +260,7 @@ void draw_map(void)
|
||||
}
|
||||
attroff(COLOR_PAIR(GRASS_PAIR));
|
||||
|
||||
/* mountains, and mountain path */
|
||||
/* 山峰和山路 */
|
||||
|
||||
attron(COLOR_PAIR(MOUNTAIN_PAIR));
|
||||
for (x = COLS / 2; x < COLS * 3 / 4; x++) {
|
||||
@ -279,7 +272,7 @@ void draw_map(void)
|
||||
mvhline(LINES / 4, 0, GRASS, COLS);
|
||||
attroff(COLOR_PAIR(GRASS_PAIR));
|
||||
|
||||
/* lake */
|
||||
/* 湖 */
|
||||
|
||||
attron(COLOR_PAIR(WATER_PAIR));
|
||||
for (y = 1; y < LINES / 2; y++) {
|
||||
@ -290,8 +283,7 @@ void draw_map(void)
|
||||
|
||||
```
|
||||
|
||||
Unless you have a keen eye, you may not be able to spot all of the changes necessary to support color in the adventure game. The diff tool shows all the instances where functions were added or code was changed to support colors:
|
||||
|
||||
你可能不能认出所有为了在冒险游戏里面支持颜色需要的修改,除非你目光敏锐。diff工具展示了所有为了支持颜色而添加的函数或者修改的代码:
|
||||
```
|
||||
|
||||
$ diff quest-color/quest.c quest/quest.c
|
||||
@ -361,34 +353,32 @@ $ diff quest-color/quest.c quest/quest.c
|
||||
|
||||
```
|
||||
|
||||
### Let's Play—Now in Color
|
||||
### 开始玩吧--现在有颜色了
|
||||
|
||||
The program now has a more pleasant color scheme, more closely matching the original tabletop gaming map, with green fields, blue lake and imposing gray mountains. The hero clearly stands out in red and magenta livery.
|
||||
程序现在有了更舒服的颜色设计了,更匹配起初的桌游地图,有绿地、蓝色的湖和壮观的灰色山峰。英雄穿着红色的制服十分夺目。
|
||||
|
||||
![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/quest-map_0.jpg)
|
||||
|
||||
Figure 1\. A Simple Tabletop Game Map, with a Lake and Mountains
|
||||
图 1\. 一个简单的带湖和山的桌游地图
|
||||
|
||||
![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/quest-color-start.png)
|
||||
|
||||
Figure 2\. The player starts the game in the lower-left corner.
|
||||
图 2\.玩家站在左下角
|
||||
|
||||
![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/quest-color-1.png)
|
||||
|
||||
Figure 3\. The player can move around the play area, such as around the lake, through the mountain pass and into unknown regions.
|
||||
|
||||
With colors, you can represent information more clearly. This simple example uses colors to indicate playable areas (green) versus impassable regions (blue or gray). I hope you will use this example game as a starting point or reference for your own programs. You can do so much more with curses, depending on what you need your program to do.
|
||||
|
||||
In a follow-up article, I plan to demonstrate other features of the ncurses library, such as how to create windows and frames. In the meantime, if you are interested in learning more about curses, I encourage you to read Pradeep Padala's [NCURSES Programming HOWTO][3], at the Linux Documentation Project.
|
||||
图 3\. 玩家可以在游戏区域移动,比如围绕湖,通过山的通道到达未知的区域。
|
||||
|
||||
通过颜色,你可以更清楚地展示信息。这个例子使用颜色指出可游戏的区域(绿色)相对着不可通过的区域(蓝色或者灰色)。我希望你可以使用这个示例游戏作为你自己的程序的一个起点或者参照。取决于你需要你的程序做什么,你可以通过curses做得更多。
|
||||
|
||||
在下一篇文章,我计划展示ncurses库的其它特性,比如怎样创建窗口和边框。同时,如果你对于学习 curses 有兴趣,我建议你去读位于 [Linux 文档计划](http://www.tldp.org)的 Pradeep Padala 写的 [NCURSES Programming HOWTO](http://tldp.org/HOWTO/NCURSES-Programming-HOWTO)。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxjournal.com/content/programming-color-ncurses
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[leemeans](https://github.com/leemeans)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
@ -396,4 +386,4 @@ via: http://www.linuxjournal.com/content/programming-color-ncurses
|
||||
[a]:http://www.linuxjournal.com/users/jim-hall
|
||||
[1]:http://www.linuxjournal.com/content/getting-started-ncurses
|
||||
[2]:http://www.linuxjournal.com/content/creating-adventure-game-terminal-ncurses
|
||||
[3]:http://tldp.org/HOWTO/NCURSES-Programming-HOWTO
|
||||
[3]:http://tldp.org/HOWTO/NCURSES-Programming-HOWTO
|
@ -1,80 +0,0 @@
|
||||
为初学者准备的 Linux rmdir 命令(案例教程)
|
||||
======
|
||||
|
||||
在 Linux 命令行上删除文件和目录,我们已经讨论过 [rm 命令][1] 的使用。然而,这里有另一个相关的命令行工具,专门针对目录的删除。这是所指的工具就是 **rmdir**,本教程中,我们将根据一些简单的实例来讨论它。
|
||||
|
||||
#### Linux rmdir 命令
|
||||
|
||||
见名知意,rmdir(removeDirectory) 命令专门针对删除目录,不过通常目录内空空如也。如下是它的语法:
|
||||
|
||||
```
|
||||
rmdir [OPTION]... DIRECTORY...
|
||||
```
|
||||
|
||||
下面是 man 文档的说明:
|
||||
```
|
||||
删除目录(索引),如其目录为空。
|
||||
|
||||
```
|
||||
|
||||
在理解此程序如何工作方面,下面的问答风格的案例可能会给您带来更好的灵感。
|
||||
|
||||
#### Q1. rmdir 命令如何工作?
|
||||
|
||||
这非常直接,只需将目录名作为输入参数传递给它。
|
||||
比如:
|
||||
|
||||
```
|
||||
rmdir test-dir
|
||||
```
|
||||
|
||||
[![rmdir 命令如何工作][2]][3]
|
||||
|
||||
#### Q2. 如何让 rmdir 忽视非空目录?
|
||||
|
||||
通常情况下,rmdir 命令会在您删除非空目录时抛出一个错误。然而,如果需要的话,您可以在非空目录下使用 --ignore-fail-on-non-empty 选项,忽略它。
|
||||
|
||||
比如说:
|
||||
|
||||
[![如何让 rmdir 忽视非空目录][4]][5]
|
||||
|
||||
#### Q3. 如何让 rmdir 命令移除父目录?
|
||||
|
||||
和 [mkdir][6] 一样,您可以通过要求 rmdir 命令在其父目录执行操作。这意味着,您可以一次性删除目录和目录的上级目录。这个功能可以通过 -p 命令选项实现。
|
||||
|
||||
比如,下面的命令将会删除 'test' 和 'test-dir' 目录。
|
||||
|
||||
```
|
||||
rmdir -p test/test-dir/
|
||||
```
|
||||
|
||||
**注意**: 欲此操作生效,所有被删除的父目录都不应该包含任何空目录之外的目录。
|
||||
|
||||
#### Q4. rmdir 和 rm -r 有何区别?
|
||||
|
||||
如果还有印象,您还可以通过提供 -r 选项的 rm 命令删除目录。那 rmdir 和 rm -r 区别何在?rmdir 仅在空目录下生效 - 您没有办法使用 rmdir 删除非空目录。
|
||||
|
||||
因此,rmdir 在删除需要检测目录是否为空的情况下,是一个有效的工具。
|
||||
|
||||
#### 总结
|
||||
|
||||
相信您会认同,rmdir 并不是一个难以理解和使用的复杂命令。除此之外,它仅提供少量命令行选项。在此,我们几乎讨论了所有的选项,如果您想掌握的更好,练习在本教程提到的案例即可。关于 rmdir,[这里另有 man 文档][7],备您不时之需。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/linux-rmdir-command/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[CYLeft](https://github.com/CYLeft)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com
|
||||
[1]:https://www.howtoforge.com/linux-rm-command/
|
||||
[2]:https://www.howtoforge.com/images/command-tutorial/rm-basic-usage1.png
|
||||
[3]:https://www.howtoforge.com/images/command-tutorial/big/rm-basic-usage1.png
|
||||
[4]:https://www.howtoforge.com/images/command-tutorial/rmdir-ignore-nonempty.png
|
||||
[5]:https://www.howtoforge.com/images/command-tutorial/big/rmdir-ignore-nonempty.png
|
||||
[6]:https://www.howtoforge.com/linux-mkdir-command/
|
||||
[7]:https://linux.die.net/man/1/rmdir
|
Loading…
Reference in New Issue
Block a user