Merge pull request #16 from LCTT/master

Update from LCTT
This commit is contained in:
chen ni 2019-07-04 17:41:27 +08:00 committed by GitHub
commit 060fec3295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 867 additions and 419 deletions

View File

@ -0,0 +1,117 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11054-1.html)
[#]: subject: (4 cool terminal multiplexers)
[#]: via: (https://fedoramagazine.org/4-cool-terminal-multiplexers/)
[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/)
4 款很酷的终端复用器
======
![][1]
Fedora 系统对很多用户来说都很舒适。它有一个令人惊叹的桌面,可以轻松地完成日常任务。而在这光鲜的表面之下是由 Linux 系统提供的支持,而终端是高级用户使用这些底层能力的最简单方法。默认的终端简单且功能有限。但是,*终端复用器*能让你的终端变得非常强大。本文展示了一些流行的终端多路复用器以及如何安装它们。
为什么要用它?嗯,首先,它可以让你注销你的系统,而同时*让你的终端会话不受干扰*。退出你的控制台,这样安全,在其他地方旅行时通过远程登录 SSH 继续之前的操作是非常有用的。这里有一些工具可以看下。
最古老和最知名的终端多路复用器之一是 `screen`。但是,由于其代码不再维护,本文将重点介绍最近的应用。 (“最近的”是相对而言的,其中一些已存在多年!)
### Tmux
`tmux``screen` 最广泛使用的替代品之一。它有高度可配置的接口。你可以根据需要对 `tmux` 进行编程以启动特定类型的会话。在前面发表的这篇文章中你会发现更多关于 tmux 的信息:
- [使用 tmux 实现更强大的终端][2]
已经是 `tmux` 用户?你可能会喜欢[这篇使你的 tmux 会话更有效的文章][3]。
要安装 `tmux`,由于你可能已经在终端中,请带上 `sudo` 使用 `dnf`
```
$ sudo dnf install tmux
```
要开始学习,请运行 `tmux` 命令。单窗格窗口以你的默认 shell 启动。tmux 使用*修饰键*来表示接下来会发出命令。默认情况下,此键为 `Ctrl+B`。如果输入 `Ctrl+B, C`,你将创建一个带有 shell 的新窗口。
提示:使用 `Ctrl+B, ?` 进入帮助模式,会列出你可以使用的所有键。为了简单起见,你先查看 `bind-key -T prefix` 开头的行。这些是你可以在修饰键之后立即使用的键,可以用来配置你的 `tmux` 会话。你可以按 `Ctrl+C` 退出帮助模式回 `tmux`
要完全退出 `tmux`,请使用标准 `exit` 命令或 `Ctrl+D` 退出所有 shell。
### Dvtm
你可能最近在 Fedroa Magzine 上看到过一篇 [dwm一个动态窗口管理器][4]的文章。像 `dwm` 一样,`dvtm` 用于平铺窗口管理,但是是用在终端中。它的设计坚持 UNIX 的“做好一件事”的理念,在这里是管理终端中的窗口。
安装 `dvtm` 也很简单。但是,如果你想要前面提到的注销功能,你还需要 `abduco` 包来处理 dvtm 的会话管理。
```
$ sudo dnf install dvtm abduco
```
`dvtm` 已经映射了许多管理终端窗口的按键。默认情况下,它使用 `Ctrl+G` 作为其修饰键。这个按键告诉 `dvtm` 接下来的字符将成为它应该处理的命令。例如, `Ctrl+G, C` 创建一个新窗口,`Ctrl+G, X` 将其关闭。
有关使用 `dvtm` 的更多信息,请查看 `dvtm` 的[主页][5],其中包含大量提示和入门信息。
### Byobu
虽然 `byobu` 本身并不是真正的多路复用器 —— 它封装了 `tmux` 甚至更老的 `screen` 来添加功能,但它也值得在这里一提。通过帮助菜单和窗口选项卡,以便更加容易地找到那些功能,`byobu` 使终端复用器更适合初学者。
当然它也可以在 Fedora 仓库中找到。要安装它,请使用以下命令:
```
$ sudo dnf install byobu
```
默认情况下,`byobu` 会在内部运行 `screen`,因此你可能希望运行 `byobu-tmux` 来封装 `tmux`。你可以使用 `F9` 键打开帮助菜单以获取更多信息,来帮助你入门。
### Mtm
`mtm` 是你可以找到的最小的复用器之一。事实上,它只有大约 1000 行代码!如果你处于受限的环境(例如旧硬件、最小容器等)中,你可能会发现它很有用。要开始使用,你需要安装一些包。
```
$ sudo dnf install git ncurses-devel make gcc
```
然后克隆 `mtm` 所在的仓库:
```
$ git clone https://github.com/deadpixi/mtm.git
```
进入 `mtm` 文件夹并构建程序:
```
$ make
```
你可能会收到一些警告,但完成后,你将会有一个非常小的 `mtm` 程序。使用以下命令运行它:
```
$ ./mtm
```
你可以在 [GitHub 页面][6]上找到该程序的所有文档。
这里只是一些终端复用器。你有想推荐的么?请在下面留下你的评论,享受在终端中创建窗口吧!
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/4-cool-terminal-multiplexers/
作者:[Paul W. Frields][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/pfrields/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2018/08/tmuxers-4-816x345.jpg
[2]: https://fedoramagazine.org/use-tmux-more-powerful-terminal/
[3]: https://fedoramagazine.org/4-tips-better-tmux-sessions/
[4]: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/
[5]: http://www.brain-dump.org/projects/dvtm/#why
[6]: https://github.com/deadpixi/mtm
[7]: https://unsplash.com/photos/48yI_ZyzuLo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[8]: https://unsplash.com/search/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText

View File

@ -1,34 +1,30 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11051-1.html)
[#]: subject: (5 Easy Ways To Free Up Space (Remove Unwanted or Junk Files) on Ubuntu)
[#]: via: (https://www.2daygeek.com/linux-remove-delete-unwanted-junk-files-free-up-space-ubuntu-mint-debian/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
5种简单的方法来在 Ubuntu 上释放空间(移除不想要的或没有用的文件)
5 种在 Ubuntu 上释放空间的简单方法
======
我们中的大多数人可能在系统磁盘存储不足的情况下执行这个操作。
![](https://img.linux.net.cn/data/attachment/album/201907/03/165641h0xy91x9109wz19w.jpg)
我们中的大多数人可能在 Linux 系统磁盘存储不足的情况下执行这个操作。
大多数人可能在系统磁盘存储不足的情况下执行释放空间这个操作,也可能在 Linux 系统磁盘存储满了的情况下执行这个操作。
它应该被经常执行,来为安装一个新的应用程序和处理其它文件弥补磁盘存储空间。
内务处理是 Linux 管理员的一个日常任务,管理员允许内务处理在阈值下维持磁盘利用率。
它应该被经常执行,来为安装一个新的应用程序和处理其它文件弥补磁盘存储空间。保持可用空间是 Linux 管理员的一个日常任务,以允许磁盘利用率维持在阈值之下。
这里有一些我们可以清理我们系统空间的方法。
当你有 TB 级存储容量时,不需要清理你的系统。
但是,如果你空间有限,那么释放磁盘空间,变的不可避免。
当你有 TB 级存储容量时,可能不需要清理你的系统。但是,如果你空间有限,那么释放磁盘空间就变的不可避免。
在这篇文章中,我将向你展示一些最容易的或简单的方法来清理你的 Ubuntu 系统,获得更多空间。
### 在 Ubuntu 系统上如何检查可用的空间?
在你的系统上使用 **[df 命令][1]** 来检查当前磁盘利用率。
在你的系统上使用 [df 命令][1] 来检查当前磁盘利用率。
```
$ df -h
@ -42,17 +38,12 @@ tmpfs 997M 0 997M 0% /sys/fs/cgroup
```
图形界面用户可以使用“磁盘利用率分析器工具”来查看当前利用率。
[![][2]![][2]][3]
### 1) 移除不再需要的软件包
![][3]
下面的命令移除系统不再需要依赖的库和软件包。
#### 1) 移除不再需要的软件包
这些软件包自动地安装来使一个被安装软件包满足的依赖关系。
同样,它移除安装在系统中的旧的 Linux 内核。
它移除不再被系统需要的孤立的软件包,但是不清除它们。
下面的命令移除系统不再需要的依赖库和软件包。这些软件包是自动安装的,以使一个安装的软件包满足依赖关系。同样,它也会移除安装在系统中的 Linux 旧内核。它会移除不再被系统需要的孤儿软件包,但是不会清除它们。
```
$ sudo apt-get autoremove
@ -71,7 +62,7 @@ After this operation, 189 MB disk space will be freed.
Do you want to continue? [Y/n]
```
为清除它们,与命令一起使用 `--purge` 选项。
为清除它们,可以与命令一起使用 `--purge` 选项。
```
$ sudo apt-get autoremove --purge
@ -90,26 +81,21 @@ After this operation, 189 MB disk space will be freed.
Do you want to continue? [Y/n]
```
### 2) 清空回收站
#### 2) 清空回收站
这可能有风险,你可能有大量的无用数据存在于你的回收站中。
它占用你的系统空间。这是最好的一个方法来在你的系统上清理这些无用的数据,并获取一些可用的空间。
有可能你的回收站里面有大量的无用数据。它会占用你的系统空间。最好解决方法之一是在你的系统上清理这些无用的数据,以获取一些可用的空间。
为清理这些,简单地使用文件管理器来清空你的回收站。
[![][2]![][2]][4]
### 3) 清理 APT 缓存文件
![][4]
Ubuntu 使用 **[APT 命令][5]** (高级软件包工具)用于软件包管理,像:安装,移除,搜索等等。
#### 3) 清理 APT 缓存文件
默认情况下,每个 Linux 操作系统在它们各自的命令保留下载和安装的软件包的缓冲
Ubuntu 使用 [APT 命令][5](高级软件包工具)用于软件包管理,如:安装、移除、搜索等等
Ubuntu 也做相同的事,它以缓冲的形式在你的磁盘上保留它下载和安装的每次更新
一般 Linux 操作系统会在各自的目录下保留下载和安装的软件包的缓冲文件
Ubuntu 在 /var/cache/apt/archives 目录中保留 DEB 软件包的缓冲文件。
随着时间推移,这些缓存可能快速增长,并在你的系统上占有很多空间。
Ubuntu 也一样它在你的磁盘上以缓冲的形式保留它下载和安装的每次更新。Ubuntu 在 `/var/cache/apt/archives` 目录中保留 DEB 软件包的缓冲文件。随着时间推移,这些缓存可能快速增长,并在你的系统上占有很多空间。
运行下面的命令来检查当前 APT 缓存文件的使用率。
@ -118,30 +104,29 @@ $ sudo du -sh /var/cache/apt
147M /var/cache/apt
```
清理过时的 deb 软件包。我想说,一点都清理不干净。
下面的命令会清理过时的 deb 软件包。我想说,一点都清理不干净。
```
$ sudo apt-get autoclean
```
移除所有在 apt 缓存中的软件包。
下面的命令会移除所有在 apt 缓存中的软件包。
```
$ sudo apt-get clean
```
### 4) 卸载不使用的应用程序
#### 4) 卸载不使用的应用程序
我可能要求你来检查在你的系统上安装的软件包和游戏,删除它们,如果你很少使用。
这需要你来检查在你的系统上安装的软件包和游戏,删除它们,如果你很少使用的话
这可以简单地完成,通过 “Ubuntu 软件中心”。
[![][2]![][2]][6]
这可以通过 “Ubuntu 软件中心” 简单地做到。
### 5) 清理缩略图缓存
![][6]
缓存文件夹是程序存储它们可能再次需要的数据的地方,它是为速度保留的,而不是必需保留的。它可以被再次生成或再次下载。
#### 5) 清理缩略图缓存
假如它真的填满你的硬盘,那么你可以删除一些东西而不用担心。
缓存文件夹是程序存储它们可能再次需要的数据的地方,它是为速度保留的,而不是必需保留的。它可以被再次生成或再次下载。假如它真的填满你的硬盘,那么你可以删除一些东西而不用担心。
运行下面的命令来检查当前 APT 缓存的利用率。
@ -163,7 +148,7 @@ via: https://www.2daygeek.com/linux-remove-delete-unwanted-junk-files-free-up-sp
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11050-1.html)
[#]: subject: (BitTorrent Client Deluge 2.0 Released: Heres Whats New)
[#]: via: (https://itsfoss.com/deluge-2-release/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
@ -12,33 +12,27 @@ BitTorrent 客户端 Deluge 2.0 发布:新功能介绍
你可能已经知道 [Deluge][1] 是[最适合 Linux 用户的 Torrent 客户端][2]之一。然而,最近的稳定版本差不多是两年前的了。
尽管它在积极开发中,但直到最近才出了一个主要的稳定版本。我们写这篇文章时,最新版本恰好是 2.0.2。所以,如果你还没有下载最新的稳定版本,请尝试一下。
尽管它在积极开发中,但直到最近才出了一个主要的稳定版本。我们写这篇文章时,最新版本恰好是 2.0.2。所以,如果你还没有下载最新的稳定版本,请尝试一下。
不管如何,如果你好奇的话,让我们谈下有哪些新的功能。
![Deluge][3]
不管如何,如果你感兴趣的话,让我们看看有哪些新的功能。
### Deluge 2.0 的主要改进
新版本引入了多用户支持,这是一个非常需要的功能。
除此之外,还有一些性能改进可以更快地加载更多的种子。
新版本引入了多用户支持,这是一个非常需要的功能。除此之外,还有一些性能改进可以更快地加载更多的种子。
此外,在 2.0 版本中Deluge 使用了 Python 3对 Python 2.7 提供最低支持。即使是用户界面,他们也从 GTK UI 迁移到了 GTK3。
根据发行说明,还有一些更重要的补充/改进,包括:
* 多用户支持。
  * 性能提升,可以更快地加载数千个种子。
  * 一个模拟 GTK/Web UI 的新控制台 UI。
  * GTK UI 迁移到 GTK3并伴随 UI 改进和补充。
  * 磁链预获取功能以便在添加种子时选择文件。
  * 完全支持 libtorrent 1.2。
  * 语言切换支持。
  * 改进了在 ReadTheDocs 托管的文档。
  * AutoAdd 插件取代了内置功能。
* 多用户支持。
* 性能提升,可以更快地加载数千个种子。
* 一个模拟 GTK/Web UI 的新控制台 UI。
* GTK UI 迁移到 GTK3并带有 UI 改进和补充。
* 磁链预获取功能可以在添加种子时选择文件。
* 完全支持 libtorrent 1.2。
* 语言切换支持。
* 改进了在 ReadTheDocs 托管的文档。
* AutoAdd 插件取代了内置功能。
### 如何安装或升级到 Deluge 2.0
@ -46,17 +40,15 @@ BitTorrent 客户端 Deluge 2.0 发布:新功能介绍
对于任何 Linux 发行版,你都应该遵循官方[安装指南][5](使用 PPA 或 PyPi。但是如果你要升级你应该留意发行说明中提到的
“_Deluge 2.0与 Deluge 1.x 客户端或守护进程不兼容,因此这些也需要升级。如果第三方脚本直接连接到 Deluge 客户端那么可能也不兼容且需要迁移。_”
> “_Deluge 2.0 与 Deluge 1.x 客户端或守护进程不兼容,因此这些也需要升级。如果第三方脚本直接连接到 Deluge 客户端那么可能也不兼容且需要迁移。_”
因此,坚持在升级主版本之前备份你的[配置][6]以免数据丢失。
而且,如果你是插件作者,那么需要升级它以使其与新版本兼容。
因此,坚持在升级主版本之前备份你的[配置][6]以免数据丢失。而且,如果你是插件作者,那么需要升级它以使其与新版本兼容。
直接下载的安装包尚不包含 Windows 和 Mac OS。但是说明中提到他们正在进行中。
除此之外,你可以按照更新后的官方文档中的[安装指南][5]来手动安装它们。
**总结**
### 总结
你如何看待最新的稳定版本?你是否将 Deluge 用作 BitTorrent 客户端?或者你是否找到了其他更好的选择?
@ -69,7 +61,7 @@ via: https://itsfoss.com/deluge-2-release/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,43 +1,44 @@
[#]: collector: (lujun9972)
[#]: translator: (chen-ni)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11049-1.html)
[#]: subject: (Leading in the Python community)
[#]: via: (https://opensource.com/article/19/6/naomi-ceder-python-software-foundation)
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
Python 社区的领袖
领导 Python 社区
======
对话现任 Python 软件基金会董事会主席 Naomi Ceder
![Hands together around the word trust][1]
> 对话现任 Python 软件基金会董事会主席 Naomi Ceder。
![](https://img.linux.net.cn/data/attachment/album/201907/03/155715vrhkvapiiia9i3zp.jpg)
和开源软件世界的很多其他领袖一样,[Python 软件基金会][3]PSF的董事会主席 [Naomi Ceder][2] 通过一种不同寻常的方式走进了 Python 世界。正如她在 2017 年 PyCon España 大会上的 [keynote][4] 的标题所说,她是因为这个编程语言而来,因为这个社区而留下的。在我们和她的一次近期的交流中,她分享了自己成为 Python 社区领袖的历程,并且就“是什么让 Python 如此特别”这个问题提供了一些独到的见解。
### 从授课到编程
Naomi 的职业生涯是从古典文学开始的。她取得了拉丁文和古希腊文的博士学位并且辅修了印欧语言学。在一家私立学校教授拉丁语的同时她开始接触了计算机学习如何编程、如何拆机进行升级或者维修。1995 年,她开始在 [Yggdrasil Linux][5] 系统上开发开源软件,并且帮助建立了印第安纳州韦恩堡的 [Linux 用户小组][6]
Naomi 的职业生涯是从古典文学开始的。她取得了拉丁文和古希腊文的博士学位并且辅修了印欧语言学。在一家私立学校教授拉丁语的同时她开始接触了计算机学习如何编程、如何拆机进行升级或者维修。1995 年,她开始在 [Yggdrasil Linux][5] 系统上开发开源软件,并且帮助建立了印第安纳州韦恩堡的 [Linux 用户小组][6]
作为一名教师Naomi 相信在中学教授编程课程是非常重要的,因为等到大多数人上大学的时候,他们已经认为编程和科技相关的职业已经不是自己可以从事的了。她表示,更早地教授相关课程有助于增加科技人才的供给,提高人才的多元化和经验的广度,从而更好地满足行业需求。
大约在 2001 年前后,她决定从学习人类语言转向研究计算机语言,并同时教授计算机课程和管理学校的 IT 系统。在 2001 年的 Linux World 大会上听了一整天 PSF 主席 Guido Van Rossum 关于 Python 的演讲之后,她对 Python 的热情被点燃了。在那个时候Python 还只是一门晦涩难懂的语言,但是她是如此喜欢 Python以至于在她的学校开始使用 Python 记录学生信息、进行系统管理。
大约在 2001 年前后,她决定从学习人类语言转向研究计算机语言,并同时教授计算机课程和管理学校的 IT 系统。在 2001 年的 Linux World 大会上听了一整天时任 PSF 主席 Guido Van Rossum LCTT 译注:也是 Python 创始人)关于 Python 的演讲之后,她对 Python 的热情被点燃了。在那个时候Python 还只是一门晦涩难懂的语言,但是她是如此喜欢 Python以至于在她的学校开始使用 Python 记录学生信息、进行系统管理。
### 领导 Python 社区
Naomi 表示,“社区是 Python 成功背后的关键因素。开源软件的核心思想是分享,很少有人真的喜欢一个人坐在那儿盯着屏幕写代码。真正的满足来源于和别人交流想法,并且共同创造一些东西。”
她在第一届 [PyCon][7] 大会上发表了演讲,并且从此之后一直是一名参与者和领导者。她组织了一些 birds-of-a-feather 讨论会LCTT 译注一种在大会参与者之间进行的基于兴趣的小规模讨论活动、PyCon 和 PyCon UK 大会的海报展示会、教育峰会,以及 PyCon 大会的西班牙语频道。
她在第一届 [PyCon][7] 大会上发表了演讲,并且从此之后一直是一名参与者和领导者。她组织了一些 <ruby>趣味相投<rt>birds-of-a-feather<rt></ruby> 讨论会LCTT 译注:birds-of-a-feather一种在大会参与者之间进行的基于兴趣的非正式小规模讨论活动、PyCon 和 PyCon UK 大会的海报展示会、教育峰会,以及 PyCon 大会的西班牙语频道。
她同时是 *[The Quick Python Book][9]* 一书的作者,并且联合创立了 [Trans\*Code][10]“英国唯一一个专注于变性者的问题和机遇的黑客节”LCTT 译注黑客节是一种让软件开发、设计、项目管理等相关人员相聚在一起针对软件项目进行高强度合作的活动。Naomi 表示,“随着科技能够提供越来越多的机遇,确保传统意义上的边缘化群体能够同等地享受到这些机遇成为了一件更为重要的事情。”
她同时是 《[The Quick Python Book][9]》一书的作者,并且联合创立了 [Trans*Code][10]“英国唯一一个专注于变性者的问题和机遇的黑客节”LCTT 译注:<ruby>黑客节<rt>hack event</rt></ruby>是一种让软件开发、设计、项目管理等相关人员相聚在一起针对软件项目进行高强度合作的活动。Naomi 表示,“随着科技能够提供越来越多的机遇,确保传统意义上的边缘化群体能够同等地享受到这些机遇成为了一件更为重要的事情。”
### 通过 PSF 进行贡献
作为 PSF 的董事会主席Naomi 积极地参与着该组织对 Python 语言和其使用者的支持工作。除了赞助 PyCon 大会的举办之外PSF 基金会还为世界各地的小型聚会、大型会议和研习会提供资助。2018 年,该组织发放的资助接近 335000 美元,其中大多数款项的金额都在 500 美元到 5000 美元之间。
PSF 的短期目标是成为一个由专业员维护的可持续的、稳定的、成熟的非盈利机构。它的长期目标包括发展可以提供对 Python 开发工作有效支持的各种资源,以及扩展该组织对全世界范围内 Python 教育工作的支持。
PSF 的短期目标是成为一个由专业员维护的可持续的、稳定的、成熟的非盈利机构。它的长期目标包括发展可以提供对 Python 开发工作有效支持的各种资源,以及扩展该组织对全世界范围内 Python 教育工作的支持。
这些工作都需要来自社区的经济上的支持。Naomi 表示PSF “最大的资金来源是 PyCon 大会。为了确保 PSF 的可持续性,我们同事也关注使用 Python 的企业的赞助,这是我们增长最快的部分。”会员价格是每年 99 美元,并且 [捐款和募捐人][12] 同样也在帮助维持该组织的工作。
这些工作都需要来自社区的经济上的支持。Naomi 表示PSF “最大的资金来源是 PyCon 大会。为了确保 PSF 的可持续性,我们同时也关注使用 Python 的企业的赞助,这是我们增长最快的部分。”会员费是每年 99 美元,并且 [捐款和募捐人][12] 同样也在帮助维持该组织的工作。
你可以在 PSF 的 [年度报告][13] 中了解该组织的更多工作情况。
@ -48,7 +49,7 @@ via: https://opensource.com/article/19/6/naomi-ceder-python-software-foundation
作者:[Don Watkins][a]
选题:[lujun9972][b]
译者:[chen-ni](https://github.com/chen-ni)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,92 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (An eco-friendly internet of disposable things is coming)
[#]: via: (https://www.networkworld.com/article/3406462/an-eco-friendly-internet-of-disposable-things-is-coming.html)
[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/)
An eco-friendly internet of disposable things is coming
======
Researchers are creating a non-hazardous, bacteria-powered miniature battery that can be implanted into shipping labels and packaging to monitor temperature and track packages in real time.
![Thinkstock][1]
Get ready for a future of disposable of internet of things (IoT) devices, one that will mean everything is connected to networks. It will be particularly useful in logistics, being used in single-use plastics in retail packaging and throw-away shippers carboard boxes.
How it will happen? The answer is when non-hazardous, disposable bio-batteries make it possible. And that moment might be approaching. Researchers say theyre closer to commercializing a bacteria-powered miniature battery that they say will propel the IoDT.
**[ Learn more: [Download a PDF bundle of five essential articles about IoT in the enterprise][2] ]**
The “internet of disposable things is a new paradigm for the rapid evolution of wireless sensor networks,” says Seokheun Choi, an associate professor at Binghamton University, [in an article on the schools website][3].
“Current IoDTs are mostly powered by expensive and environmentally hazardous batteries,” he says. Those costs can be significant in any kind of large-scale deployment, he says. And furthermore, with exponential growth, the environmental concerns would escalate rapidly.
The miniaturized battery that Chois team has come up with is uniquely charged through power created by bacteria. It doesnt have metals and acids in it. And its designed specifically to provide energy to sensors and radios in single-use IoT devices. Those could be the kinds of sensors ideal for supply-chain logistics where the container is ultimately going to end up in a landfill, creating a hazard.
Another use case is real-time analysis of packaged food, with sensors monitoring temperature and location, preventing spoilage and providing safer food handling. For example, a farm product could be tracked for on-time delivery, as well as have its temperature measured, all within the packaging, as it moves from packaging facility to consumer. In the event of a food-borne illness outbreak, say, one can quickly find out where the product originated—which apparently is hard to do now.
Other use cases could be battery-impregnated shipping labels that send real-time data to the internet. Importantly, in both use cases, packaging can be discarded without added environmental concerns.
### How the bacteria-powered batteries work
A slow release of nutrients provide the energy to the bacteria-powered batteries, which the researchers say can last up to eight days. “Slow and continuous reactions” convert the microbial nutrients into “long standing power,” they say in [their paper's abstract][4].
“Our biobattery is low-cost, disposable, and environmentally-friendly,” Choi says.
Origami, the Japanese paper-folding skill used to create objects, was an inspiration for a similar microbial-based battery project the group wrote about last year in a paper. This one is liquid-based and not as long lasting. A bacteria-containing liquid was absorbed along the porous creases in folded paper, creating the paper-delivered power source, perhaps to be used in a shipping label.
“Low-cost microbial fuel cells (MFCs) can be done efficiently by using a paper substrate and origami techniques,” [the group wrote then][5].
Scientists, too, envisage electronics now printed on circuit boards (PCBs) and can be toxic on disposal being printed entirely on eco-friendly paper. Product cycles, such as those found now in mobile devices and likely in future IoT devices, are continually getting tighter—thus PCBs are increasingly being disposed. Solutions are needed, experts say.
Put the battery in the paper, too, is the argument here. And while youre at it, get the biodegradation of the used-up biobattery to help break-down the organic-matter paper.
Ultimately, Choi believes that the power-creating bacteria could even be introduced naturally by the environment—right now its added on by the scientists.
**More on IoT:**
* [What is the IoT? How the internet of things works][6]
* [What is edge computing and how its changing the network][7]
* [Most powerful Internet of Things companies][8]
* [10 Hot IoT startups to watch][9]
* [The 6 ways to make money in IoT][10]
* [What is digital twin technology? [and why it matters]][11]
* [Blockchain, service-centric networking key to IoT success][12]
* [Getting grounded in IoT networking and security][2]
* [Building IoT-ready networks must become a priority][13]
* [What is the Industrial IoT? [And why the stakes are so high]][14]
Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3406462/an-eco-friendly-internet-of-disposable-things-is-coming.html
作者:[Patrick Nelson][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Patrick-Nelson/
[b]: https://github.com/lujun9972
[1]: https://images.techhive.com/images/article/2017/04/green-data-center-intro-100719502-large.jpg
[2]: https://www.networkworld.com/article/3269736/internet-of-things/getting-grounded-in-iot-networking-and-security.html
[3]: https://www.binghamton.edu/news/story/1867/everything-will-connect-to-the-internet-someday-and-this-biobattery-could-h
[4]: https://www.sciencedirect.com/science/article/abs/pii/S0378775319305580
[5]: https://www.sciencedirect.com/science/article/pii/S0960148117311606
[6]: https://www.networkworld.com/article/3207535/internet-of-things/what-is-the-iot-how-the-internet-of-things-works.html
[7]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html
[8]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html
[9]: https://www.networkworld.com/article/3270961/internet-of-things/10-hot-iot-startups-to-watch.html
[10]: https://www.networkworld.com/article/3279346/internet-of-things/the-6-ways-to-make-money-in-iot.html
[11]: https://www.networkworld.com/article/3280225/internet-of-things/what-is-digital-twin-technology-and-why-it-matters.html
[12]: https://www.networkworld.com/article/3276313/internet-of-things/blockchain-service-centric-networking-key-to-iot-success.html
[13]: https://www.networkworld.com/article/3276304/internet-of-things/building-iot-ready-networks-must-become-a-priority.html
[14]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html
[15]: https://www.facebook.com/NetworkWorld/
[16]: https://www.linkedin.com/company/network-world

View File

@ -1,210 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To Find The Port Number Of A Service In Linux)
[#]: via: (https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/)
[#]: author: (sk https://www.ostechnix.com/author/sk/)
How To Find The Port Number Of A Service In Linux
======
![Find The Port Number Of A Service In Linux OS][1]
You might often need to find the port names and numbers for some reasons. If so, youre in luck. Today, in this brief tutorial, we are going to see the easiest and quickest ways to find the port number of a service in Linux operating system. There could be many methods to do it, but I am aware of the following three methods only at present. Read on.
### Find The Port Number Of A Service In Linux
**Method 1 Using[Grep][2] command:**
To find the default port number of a given service in Linux using grep command, just run:
```
$ grep <port> /etc/services
```
For example, to find the default port of a SSH service, simply run:
```
$ grep ssh /etc/services
```
Its that simple. This command should work on most Linux distributions. Here is the sample output from my Arch Linux test box:
```
ssh 22/tcp
ssh 22/udp
ssh 22/sctp
sshell 614/tcp
sshell 614/udp
netconf-ssh 830/tcp
netconf-ssh 830/udp
sdo-ssh 3897/tcp
sdo-ssh 3897/udp
netconf-ch-ssh 4334/tcp
snmpssh 5161/tcp
snmpssh-trap 5162/tcp
tl1-ssh 6252/tcp
tl1-ssh 6252/udp
ssh-mgmt 17235/tcp
ssh-mgmt 17235/udp
```
As you can see in the above output, the default port number of SSH service is 22.
Let us find the port number of Apache web server. To do so, the command would be:
```
$ grep http /etc/services
# http://www.iana.org/assignments/port-numbers
http 80/tcp www www-http # WorldWideWeb HTTP
http 80/udp www www-http # HyperText Transfer Protocol
http 80/sctp # HyperText Transfer Protocol
https 443/tcp # http protocol over TLS/SSL
https 443/udp # http protocol over TLS/SSL
https 443/sctp # http protocol over TLS/SSL
gss-http 488/tcp
gss-http 488/udp
webcache 8080/tcp http-alt # WWW caching service
webcache 8080/udp http-alt # WWW caching service
[...]
```
How about FTP port number? Thats easy!
```
$ grep ftp /etc/services
ftp-data 20/tcp
ftp-data 20/udp
# 21 is registered to ftp, but also used by fsp
ftp 21/tcp
ftp 21/udp fsp fspd
tftp 69/tcp
[...]
```
**Method 2 Using getent command**
As you can see, the above commands shows all port names and numbers for the given search term “ssh”, “http” and “ftp”. That means, you will get a quite long output of all port names that matches with the given search term.
You can, however, narrow down the result to exact output using “getent” command like below:
```
$ getent services ssh
ssh 22/tcp
$ getent services http
http 80/tcp www www-http
$ getent services ftp
ftp 21/tcp
```
If you dont know the port name but the port number, simply replace the port name with number like below:
```
$ getent services 80
http 80/tcp
```
To display all port names and numbers, simply run:
```
$ getent services
```
* * *
**Suggested read:**
* [**How To Change Apache Default Port To A Custom Port**][3]
* [**How To Change FTP Default Port To A Custom Port**][4]
* [**How To Change SSH Default Port To A Custom Port**][5]
* * *
**Method 3 Using Whatportis Utility**
The **Whatportis** is a simple python script used to find port names and numbers. Unlike the above commands, this utility displays the output in a nice tabular column format.
Make sure you have installed PIP package manager. If not, refer the following link.
* [**How To Manage Python Packages Using Pip**][6]
Once installed PIP, run the following command to install Whatportis utility.
```
$ pip install whatportis
```
Now, you can find what port is associated with a service as shown below.
```
$ whatportis ssh
$ whatportis ftp
$ whatportis http
```
Sample output from my CentOS 7 server:
![][7]
Find The Port Number Of A Service In Linux
If you dont know the exact name of a service, use **like** flag to display the relevant results.
```
$ whatportis mysql --like
```
The above commands helped you to find what port is associated with a service. You can also find what service is associated with a port number like below.
```
$ whatportis 993
```
You can even display the results in **JSON** format.
```
$ whatportis 993 --json
```
![][8]
For more details, refer the GitHub repository.
* [**Whatportis GitHub Repository**][9]
And, thats all for now. You know now how to find the port names and numbers in Linux using three simple methods. If you know any other methods/commands, let me know in the comment section below. I will check and update this guide accordingly.
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/
作者:[sk][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2018/06/Find-The-Port-Number-720x340.png
[2]: https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/
[3]: https://www.ostechnix.com/how-to-change-apache-ftp-and-ssh-default-port-to-a-custom-port-part-1/
[4]: https://www.ostechnix.com/how-to-change-apache-ftp-and-ssh-default-port-to-a-custom-port-part-2/
[5]: https://www.ostechnix.com/how-to-change-apache-ftp-and-ssh-default-port-to-a-custom-port-part-3/
[6]: https://www.ostechnix.com/manage-python-packages-using-pip/
[7]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis.png
[8]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis-1.png
[9]: https://github.com/ncrocfer/whatportis

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
@ -9,8 +9,7 @@
How to use Tig to browse Git logs
======
Tig is more than just a text-mode interface for Git. Here's how it can
enhance your daily workflow.
Tig is more than just a text-mode interface for Git. Here's how it can enhance your daily workflow.
![A person programming][1]
If you work with Git as your version control system, you've likely already resigned yourself to the fact that Git is a complicated beast. It is a fantastic tool, but it can be cumbersome to navigate Git repositories. That's where a tool like [Tig][2] comes in.

View File

@ -0,0 +1,199 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (6 open source web browser alternatives)
[#]: via: (https://opensource.com/article/19/7/open-source-browsers)
[#]: author: (Bryant Son https://opensource.com/users/brson/users/lauren-pritchett/users/scottnesbitt)
6 open source web browser alternatives
======
Chrome and Firefox are on the list, but you'll find some other
interesting options, too.
![web development and design, desktop and browser][1]
Open source web browsers have come a long way since Microsoft dominated the web browser market with its closed source Internet Explorer (IE). For many years, IE was the standard browser for Microsoft's Windows operating system, while Safari (also closed source) was the default browser for MacOS. Then Mozilla's introduction of Firefox, followed by Google's release of Chrome, sparked a revolution in open source internet browsers. Those two are extremely well known but are not the only open source browsers available.
This article introduces seven open source browsers, summarizes their features, and shares how you can contribute to them.
Name / Link to Contribute | License | Supported OSes
---|---|---
[Brave][2] | MPL 2.0 | All
[Chrome/Chromium][3] | BSD | All
[Firefox][4] | MPL 2.0 | All
[Konqueror][5] | GPL | Linux
[Lynx][6] | GPL | Linux, Windows, DOS
[Midori][7] | LGPL | Linux, Windows
### Brave
The [Brave browser][8] was created with the goal of blocking all but user-approved advertisements and website trackers. [Brendan Eich][9], the creator of JavaScript and a co-founder of the Mozilla Foundation, leads the Brave project as the CEO and a co-founder.
**Pros of Brave:**
* No ads or web trackers
* Speed
* Security
* Chromium [extension support][10]
* Bugs are tracked in [Brave QA central][11]
**Cons of Brave:**
* The opt-in micro-payment system to support content creators has an unclear pathway to get your payments to your intended recipient
You can find Brave's source code (available under the Mozilla Public License) in its extensive [GitHub repositories][2] (there are 140 repos as of this writing).
### Chrome/Chromium
[Google Chrome][12], inarguably, is the most [widely used][13] internet browser—open source or otherwise. I remember when Google introduced the first version of Chrome. Mozilla Firefox, which came out much earlier, was riding a wave of popularity. The first version of Chrome was so slow, buggy, and disappointing, which led me to think it wouldn't be successful. But, boy, I was wrong. Chrome got better and better, and the browser eventually surpassed Firefox's browser market share. Google Chrome is still known as a "memory hog" due to its heavy random access memory (RAM) utilization. Regardless, Chrome is by far the most popular browser, and it's loved by many due to its simplicity and speed.
**Pros of Google Chrome/Chromium:**
* Simplicity
* Speed
* Many useful built-in features
**Cons of Google Chrome/Chromium:**
* Heavy memory usage
* Chrome (not Chromium) has proprietary code
Chromium, which is the open source project behind the Chrome browser, is available under the Berkeley Software Distribution (BSD) license. Note that the Chrome browser also has some closed source code. To contribute, visit the [Contributing to Chromium][14] page.
### Firefox
Although Chrome is now the most popular browser, [Mozilla Firefox][15] is the one that started the whole open source web browser sensation. Before Mozilla Firefox, Internet Explorer seemed to be undefeatable. But the birth of Firefox shook that belief. One interesting bit of trivia is that its co-founder [Blake Ross][16] was only 19 years old when Firefox was released.
**Pros of Mozilla Firefox:**
* Security
* Many extensions are available
* Uniform user experience across different systems
**Cons of Mozilla Firefox:**
* Heavy memory usage
* Some HTML5 compatibility issue
Firefox's source code is available under the Mozilla Public License (MPL), and it maintains comprehensive guidelines on [how to contribute][4].
### Konqueror
[Konqueror][17] may not be the most well-known internet browser, and that is okay because it is responsible for KHTML, the browser engine forked by Apple and then Google for the Safari and Chrome browsers (and subsequently used by Brave, Vivaldi, and several other browsers). Today, Konqueror can use either its native KHTML engine or the Chromium fork. Konqueror is maintained by the international [KDE][18] free software community, and it's easy to find on most Linux desktops.
**Pros of Konqueor:**
* Pre-installed on many Linux desktops
* Fast and efficient
* Built-in ad-blocker and pop-up blocker
* Customizable URL shortcuts
* Doubles as a file manager, man page viewer, and much more
**Cons of Konqueror:**
* Primarily runs in Linux
* Requires several KDE libraries to be installed
Konqueror's source code is available under the GNU Public License (GPL). You can find its detailed [documentation][19] and [source code][5] on the KDE website.
### Lynx
Ah, [Lynx][20]. Lynx is a unique browser as it is entirely text-based. It is also the oldest web browser still in use and still under development. You might think, "who would use a text-based browser?" But it works, and there is a big community supporting this special open source browser.
**Pros of Lynx:**
* Extremely lightweight
* Extremely minimal
* Extremely secure
* Supports DOS and Windows
* Ideal for testing and safe browsing
**Cons of Lynx:**
* Nothing but text
Lynx's source code is available under the GNU Public License (GPL) and maintained on [GitHub][6].
### Midori
If you hear "Midori," you might think of a green-hued cocktail. But the [Midori browser][21] is an open source, lightweight browser. If you want a simple and lightweight browser, Midori might be an interesting one to look at. But note that there is no stable release for this browser, and it is known to be quite buggy.
**Pros of Midori:**
* Simple
* Lightweight
**Cons of Midori:**
* Still no stable release
* Buggy
* Almost no extensions
* No process isolation
Midori's source code is available under the GNU Lesser General Public License (LGPL) and maintained on [GitHub][7].
* * *
Do you know another open source browser that I should have mentioned on this list? Please share it in the comments.
Web browsers that run in a terminal window are alive and kicking. They're niche, but still get the...
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/7/open-source-browsers
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson/users/lauren-pritchett/users/scottnesbitt
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh (web development and design, desktop and browser)
[2]: https://github.com/brave
[3]: https://www.chromium.org/Home
[4]: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Introduction
[5]: https://kde.org/applications/internet/org.kde.konqueror/development
[6]: https://github.com/kurtchen/Lynx
[7]: https://github.com/midori-browser/core
[8]: https://brave.com
[9]: https://en.wikipedia.org/wiki/Brendan_Eich
[10]: https://support.brave.com/hc/en-us/articles/360017909112-How-can-I-add-extensions-to-Brave-
[11]: https://community.brave.com/c/legacy/qa
[12]: https://www.google.com/chrome/
[13]: https://www.statista.com/statistics/544400/market-share-of-internet-browsers-desktop/
[14]: https://chromium.googlesource.com/chromium/src/+/master/docs/contributing.md
[15]: https://www.mozilla.org/firefox/
[16]: https://en.wikipedia.org/wiki/Blake_Ross
[17]: https://kde.org/applications/internet/org.kde.konqueror
[18]: https://kde.org
[19]: https://docs.kde.org/stable5/en/applications/konqueror/index.html
[20]: http://lynx.browser.org/
[21]: https://www.midori-browser.org/

View File

@ -0,0 +1,200 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Parse arguments with Python)
[#]: via: (https://opensource.com/article/19/7/parse-arguments-python)
[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/notsag)
Parse arguments with Python
======
Parse Python like a pro with the argparse module.
![COBOL punch card][1]
If you're using [Python][2] for any amount of development, you have probably issued a command in a terminal, even if only to launch a Python script or install a Python module with [pip][3]. Commands may be simple and singular:
```
`$ ls`
```
Commands also might take an argument:
```
`$ ls example`
```
Commands can also have options or flags:
```
`$ ls --color example`
```
Sometimes options also have arguments:
```
`$ sudo firewall-cmd  --list-all --zone home`
```
### Arguments
The POSIX shell automatically splits whatever you type as a command into an array. For instance, here is a simple command:
```
`$ ls example`
```
The command **ls** is position **$0**, and the argument **example** is in position **$1**.
You _could_ write a loop to iterate over each item; determine whether it is the command, an option, or an argument; and take action accordingly. Luckily, a module called [argparse][4] already exists for that.
### Argparse
The argparse module is easy to integrate into your Python programs and has several convenience features. For instance, if your user changes the order of options or uses one option that takes no arguments (called a _Boolean_, meaning the option toggles a setting on or off) and then another that requires an argument (such as **\--color red**, for example), argparse can handle the variety. If your user forgets an option that's required, the argparse module can provide a friendly error message.
Using argparse in your application starts with defining what options you want to provide your user. There are several different kinds of arguments you can accept, but the syntax is consistent and simple.
Here's a simple example:
```
#!/usr/bin/env python
import argparse
import sys
def getOptions(args=sys.argv[1:]):
    parser = argparse.ArgumentParser(description="Parses command.")
    parser.add_argument("-i", "--input", help="Your input file.")
    parser.add_argument("-o", "--output", help="Your destination output file.")
    parser.add_argument("-n", "--number", type=int, help="A number.")
    parser.add_argument("-v", "--verbose",dest='verbose',action='store_true', help="Verbose mode.")
    options = parser.parse_args(args)
    return options
```
This code sample creates a function called **getOptions** and tells Python to look at each potential argument preceded by some recognizable string (such as **\--input** or **-i**). Any option that Python finds is returned out of the function as an **options** object (**options** is an arbitrary name and has no special meaning; it's just a data object containing a summary of all the arguments that the function has parsed).
By default, any argument given by the user is seen by Python as a string. If you need to ingest an integer (a number), you must specify that an option expects **type=int**, as in the **\--number** option in the sample code.
If you have an argument that just turns a feature on or off, then you must use the **boolean** type, as with the **\--verbose** flag in the sample code. This style of option simply stores **True** or **False**, specifying whether or not the user used the flag. If the option is used, then **stored_true** is activated.
Once the **getOptions** function runs, you can use the contents of the **options** object and have your program make decisions based on how the user invoked the command. You can see the contents of **options** with a test print statement. Add this to the bottom of your example file:
```
`print(getOptions())`
```
Then run the code with some arguments:
```
$ python3 ./example.py -i foo -n 4
Namespace(input='foo', number=4, output=None, verbose=False)
```
### Retrieving values
The **options** object in the sample code contains any value provided by the user (or a derived Boolean value) in keys named after the long option. In the sample code, for instance, the **\--number** option can be retrieved by looking at **options.number**.
```
options = getOptions(sys.argv[1:])
if options.verbose:
    print("Verbose mode on")
else:
    print("Verbose mode off")
print(options.input)
print(options.output)
print(options.number)
# Insert Useful Python Code Here...
```
The Boolean option, **\--verbose** in the example, is determined by testing whether **options.verbose** is True (meaning the user did use the **\--verbose** flag) or False (the user did not use the **\--verbose** flag), and taking some action accordingly.
### Help and feedback
Argparse also includes a built-in **\--help** (**-h** for short) option that provides a helpful tip on how the command is used. This is derived from your code, so it takes no extra work to generate this help system:
```
$ ./example.py --help
usage: example.py [-h] [-i INPUT] [-o OUTPUT] [-n NUMBER] [-v]
Parses command.
optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Your input file.
  -o OUTPUT, --output OUTPUT
                        Your destination output file.
  -n NUMBER, --number NUMBER
                        A number.
  -v, --verbose         Verbose mode.
```
### Python parsing like a pro
This a simple example that demonstrates how to deal with parsing arguments in a Python application and how to quickly and efficiently document their syntax. The next time you write a quick Python script, give it some options with argparse. You'll thank yourself later, and your command will feel less like a quick hack and more like a "real" Unix command!
Here's the sample code, which you can use for testing:
```
#!/usr/bin/env python3
# GNU All-Permissive License
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.
import argparse
import sys
def getOptions(args=sys.argv[1:]):
    parser = argparse.ArgumentParser(description="Parses command.")
    parser.add_argument("-i", "--input", help="Your input file.")
    parser.add_argument("-o", "--output", help="Your destination output file.")
    parser.add_argument("-n", "--number", type=int, help="A number.")
    parser.add_argument("-v", "--verbose",dest='verbose',action='store_true', help="Verbose mode.")
    options = parser.parse_args(args)
    return options
options = getOptions(sys.argv[1:])
if options.verbose:
    print("Verbose mode on")
else:
    print("Verbose mode off")
print(options.input)
print(options.output)
print(options.number)
```
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/7/parse-arguments-python
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth/users/notsag
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cobol-card-punch-programming-code.png?itok=6W6PUqUi (COBOL punch card)
[2]: https://www.python.org/
[3]: https://pip.pypa.io/en/stable/installing/
[4]: https://pypi.org/project/argparse/

View File

@ -0,0 +1,195 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To Find The Port Number Of A Service In Linux)
[#]: via: (https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/)
[#]: author: (sk https://www.ostechnix.com/author/sk/)
如何在 Linux 中查找服务的端口号
======
![Find The Port Number Of A Service In Linux OS][1]
由于某些原因,你可能经常需要查找端口名称和端口号。如果是这样,你很幸运。今天,在这个简短的教程中,我们将看到在 Linux 系统中最简单、最快捷的查找服务端口号的方法。可能有很多方法可以做到,但我目前只知道以下三种方法。请继续阅读。
### 在 Linux 中查找服务的端口号
**方法1使用 [grep][2] 命令**
要使用 grep 命令在 Linux 中查找指定服务的默认端口号,只需运行:
```
$ grep <port> /etc/services
```
例如,要查找 SSH 服务的默认端口,只需运行:
```
$ grep ssh /etc/services
```
就这么简单。此命令应该适用于大多数 Linux 发行版。以下是我的 Arch Linux 测试机中的示例输出:
```
ssh 22/tcp
ssh 22/udp
ssh 22/sctp
sshell 614/tcp
sshell 614/udp
netconf-ssh 830/tcp
netconf-ssh 830/udp
sdo-ssh 3897/tcp
sdo-ssh 3897/udp
netconf-ch-ssh 4334/tcp
snmpssh 5161/tcp
snmpssh-trap 5162/tcp
tl1-ssh 6252/tcp
tl1-ssh 6252/udp
ssh-mgmt 17235/tcp
ssh-mgmt 17235/udp
```
正如你在上面的输出中所看到的SSH 服务的默认端口号是 22。
让我们找到 Apache Web 服务器的端口号。为此,命令是:
```
$ grep http /etc/services
# http://www.iana.org/assignments/port-numbers
http 80/tcp www www-http # WorldWideWeb HTTP
http 80/udp www www-http # HyperText Transfer Protocol
http 80/sctp # HyperText Transfer Protocol
https 443/tcp # http protocol over TLS/SSL
https 443/udp # http protocol over TLS/SSL
https 443/sctp # http protocol over TLS/SSL
gss-http 488/tcp
gss-http 488/udp
webcache 8080/tcp http-alt # WWW caching service
webcache 8080/udp http-alt # WWW caching service
[...]
```
FTP 端口号是什么?这很简单!
```
$ grep ftp /etc/services
ftp-data 20/tcp
ftp-data 20/udp
# 21 is registered to ftp, but also used by fsp
ftp 21/tcp
ftp 21/udp fsp fspd
tftp 69/tcp
[...]
```
**方法 2使用 getent 命令**
如你所见,上面的命令显示指定搜索词 “ssh”、“http” 和 “ftp” 的所有端口名称和数字。这意味着,你将获得与给定搜索词匹配的所有端口名称的相当长的输出。
但是,你可以使用 “getent” 命令精确输出结果,如下所示:
```
$ getent services ssh
ssh 22/tcp
$ getent services http
http 80/tcp www www-http
$ getent services ftp
ftp 21/tcp
```
如果你不知道端口名称,但是知道端口号,那么你只需将端口名称替换为数字:
```
$ getent services 80
http 80/tcp
```
要显示所有端口名称和端口号,只需运行:
```
$ getent services
```
**方法 3使用 Whatportis 程序**
**Whatportis** 是一个简单的 python 脚本,来用于查找端口名称和端口号。与上述命令不同,此程序以漂亮的表格形式输出。
确保已安装 PIP 包管理器。如果没有,请参考以下链接。
* [**如何使用 Pip 管理 Python 包**][6]
安装 PIP 后,运行以下命令安装 Whatportis 程序。
```
$ pip install whatportis
```
现在,你可以找到与服务关联的端口,如下所示。
```
$ whatportis ssh
$ whatportis ftp
$ whatportis http
```
我的 CentOS 7 服务器的示例输出:
![][7]
在 Linux 中查找服务的端口号
如果你不知道服务的确切名称,请使用 **like** 标志来显示相关结果。
```
$ whatportis mysql --like
```
上述命令帮助你查找与服务关联的端口。你还可以找到与端口号相关联的服务,如下所示。
```
$ whatportis 993
```
你甚至可以以 **JSON** 格式显示结果。
```
$ whatportis 993 --json
```
![][8]
有关更多详细信息,请参阅 GitHub 仓库。
* [**Whatportis GitHub 仓库**][9]
就是这些了。你现在知道了如何使用三种简单方法在 Linux 中查找端口名称和端口号。如果你知道任何其他方法/命令,请在下面的评论栏告诉我。我会查看并更相应地更新本指南。
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-find-the-port-number-of-a-service-in-linux/
作者:[sk][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2018/06/Find-The-Port-Number-720x340.png
[2]: https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/
[6]: https://www.ostechnix.com/manage-python-packages-using-pip/
[7]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis.png
[8]: https://www.ostechnix.com/wp-content/uploads/2018/06/whatportis-1.png
[9]: https://github.com/ncrocfer/whatportis

View File

@ -1,122 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (4 cool terminal multiplexers)
[#]: via: (https://fedoramagazine.org/4-cool-terminal-multiplexers/)
[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/)
4 款很酷的终端复用器
======
![][1]
Fedora 系统对很多用户来说都很舒适。它有一个令人惊叹的桌面,可以轻松地完成日常任务。表面之下有 Linux 系统的全部功能终端是高级用户使用它们的最简单的方法。默认的终端简单且功能有限。但是_终端复用器_能让你的终端变得非常强大。本文展示了一些流行的终端多路复用器以及如何安装它们。
你为什么要用它首先它可以让你注销你的系统同时_让你的终端会话不受干扰_。退出你的控制台加密它在其他地方旅行时通过远程登录 SSH 继续之前的操作是非常有用的。这里有一些工具可以看下。
最古老和最知名的终端多路复用器之一是 _screen_。但是,由于代码不再维护,本文将重点介绍最近的应用。 (“最近的”是相对的,其中一些已存在多年!)
### Tmux
_tmux_ 是 _screen_ 的最广泛使用的替换之一。它有高度可配置的接口。你可以根据需要对 tmux 进行编程以启动特定类型的会话。在前面发表的这篇文章中你会发现更多关于 tmux 的信息:
> [使用 tmux 实现更强大的终端][2]
已经是 tmux 用户?你可能会喜欢[这篇使你的 tmux 会话更有效的文章][3]。
要安装 tmux由于你可能已经在终端中请使用 _dnf_ 并带上 _sudo_
```
$ sudo dnf install tmux
```
要开始学习,请运行 _tmux_ 命令。单窗格窗口以你的默认 shell 启动。tmux 使用_修饰键_来表示接下来会发出命令。默认情况下此键为 **Ctrl+B**。如果输入 **Ctrl+B, C**,你将创建一个带有 shell 的新窗口。
提示:使用 **Ctrl+B, ?** 进入帮助模式,会列出你可以使用的所有键。为了简单起见,你先查看 _bind-key -T prefix_ 开头的行。这些是你可以在修饰键之后立即使用的键,可以用来配置你的 tmux 会话。你可以按 **Ctrl+C** 退出帮助模式回 tmux。
要完全退出 tmux请使用标准 _exit_ 命令或 _Ctrl+D_ 退出所有 shell。
### Dvtm
你可能最近在 Fedroa Magzine上看到过一篇 [dwm一个动态窗口管理器][4]的文章。像 dwm 一样_dvtm_ 用于平铺窗口管理,但是用在终端中。它的设计坚持 UNIX 的“做好一件事”的理念,在这里是管理终端中的窗口。
安装 dvtm 也很简单。但是,如果你想要前面提到的注销功能,你还需要 _abduco_ 包来处理 dvtm 的会话管理。
```
$ sudo dnf install dvtm abduco
```
dvtm 已经映射了许多管理终端窗口的按键。默认情况下,它使用 **Ctrl+G** 作为其修饰键。这个按键告诉 dvtm 接下来的字符将成为它应该处理的命令。例如, **Ctrl+G, C** 创建一个新窗口,**Ctrl+G, X** 将其关闭。
有关使用 dvtm 的更多信息,请查看 dvtm 的[主页][5],其中包含大量提示和入门信息。
### Byobu
虽然 _byobu_ 本身并不是真正的多路复用器 - 它封装了 _tmux_ 甚至更老的 _screen_ 来添加功能但它也值得在这里一提。通过帮助菜单和窗口选项卡以便更加容易地找到功能Byobu 使终端复用器更适合初学者。
当然它也可以在 Fedora 仓库中找到。要安装它,请使用以下命令:
```
$ sudo dnf install byobu
```
默认情况下_byobu_ 会在内部运行 _screen_,因此你可能希望运行 _byobu-tmux_ 来封装 _tmux_。你可以使用 **F9** 键打开帮助菜单以获取更多信息,来帮助你入门。
### Mtm
_mtm_ 是你可以找到的最小的复用器之一。事实上,它只有大约 1000 行代码!如果你处于受限的环境(例如旧硬件、最小容器等)中,你可能会发现它很有用。要开始使用,你需要安装一些包。
```
$ sudo dnf install git ncurses-devel make gcc
```
然后克隆 mtm 所在的仓库:
```
$ git clone https://github.com/deadpixi/mtm.git
```
进入 _mtm_ 文件夹并构建程序:
```
$ make
```
你可能会收到一些警告,但完成后,你将会有一个非常小的 _mtm_ 程序。使用以下命令运行它:
```
$ ./mtm
```
你可以在 [GitHub 页面][6]上找到该程序的所有文档。
这里只是一些终端复用器。你有想推荐的么?请在下面留下你的评论,享受在终端中创建窗口吧!
* * *
_由 _[ _Michael_][7]_ 拍摄,发布于 [Unsplash][8]。_
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/4-cool-terminal-multiplexers/
作者:[Paul W. Frields][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/pfrields/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2018/08/tmuxers-4-816x345.jpg
[2]: https://fedoramagazine.org/use-tmux-more-powerful-terminal/
[3]: https://fedoramagazine.org/4-tips-better-tmux-sessions/
[4]: https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/
[5]: http://www.brain-dump.org/projects/dvtm/#why
[6]: https://github.com/deadpixi/mtm
[7]: https://unsplash.com/photos/48yI_ZyzuLo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[8]: https://unsplash.com/search/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText