From c93cc62cf6f0010bafbdc325cf5dc8442243a05c Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Apr 2020 11:15:29 +0800 Subject: [PATCH 1/4] APL --- sources/tech/20200211 Navigating man pages in Linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20200211 Navigating man pages in Linux.md b/sources/tech/20200211 Navigating man pages in Linux.md index 662a1d48af..0d90822c52 100644 --- a/sources/tech/20200211 Navigating man pages in Linux.md +++ b/sources/tech/20200211 Navigating man pages in Linux.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 37b694ee849170a91c72aeacbed15599e50da453 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Apr 2020 11:59:48 +0800 Subject: [PATCH 2/4] TSL --- .../20200211 Navigating man pages in Linux.md | 179 ------------------ .../20200211 Navigating man pages in Linux.md | 172 +++++++++++++++++ 2 files changed, 172 insertions(+), 179 deletions(-) delete mode 100644 sources/tech/20200211 Navigating man pages in Linux.md create mode 100644 translated/tech/20200211 Navigating man pages in Linux.md diff --git a/sources/tech/20200211 Navigating man pages in Linux.md b/sources/tech/20200211 Navigating man pages in Linux.md deleted file mode 100644 index 0d90822c52..0000000000 --- a/sources/tech/20200211 Navigating man pages in Linux.md +++ /dev/null @@ -1,179 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Navigating man pages in Linux) -[#]: via: (https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Navigating man pages in Linux -====== -The man pages on a Linux system can do more than provide information on particular commands. They can help discover commands you didn't realize were available. -[Hello I'm Nik][1] [(CC0)][2] - -Man pages provide essential information on Linux commands and many users refer to them often, but there’s a lot more to the man pages than many of us realize. - -You can always type a command like “man who” and get a nice description of how the man command works, but exploring commands that you might not know could be even more illuminating. For example, you can use the man command to help identify commands to handle some unusually challenging task or to show options that can help you use a command you already know in new and better ways. - -Let’s navigate through some options and see where we end up. - -[MORE ON NETWORK WORLD: Linux: Best desktop distros for newbies][3] - -### Using man to identify commands - -The man command can help you find commands by topic. If you’re looking for a command to count the lines in a file, for example, you can provide a keyword. In the example below, we’ve put the keyword in quotes and added blanks so that we don’t get commands that deal with “accounts” or “accounting” along with those that do some counting for us. - -``` -$ man -k ' count ' -anvil (8postfix) - Postfix session count and request rate control -cksum (1) - checksum and count the bytes in a file -sum (1) - checksum and count the blocks in a file -timer_getoverrun (2) - get overrun count for a POSIX per-process timer -``` - -To show commands that relate to new user accounts, we might try a command like this: - -``` -$ man -k "new user" -newusers (8) - update and create new users in batch -useradd (8) - create a new user or update default new user information -zshroadmap (1) - informal introduction to the zsh manual The Zsh Manual, … -``` - -Just to be clear, the third item in the list above makes a reference to “new users” liking the material and is not a command for setting up, removing or configuring user accounts. The man command is simply matching words in the command description, acting very much like the apropos command. Notice the numbers in parentheses after each command listed above. These relate to the man page sections that contain the commands. - -### Identifying the manual sections - -The man command sections divide the commands into categories. To list these categories, type “man man” and look for descriptions like those below. You very likely won’t have Section 9 commands on your system. - -[][4] - -``` -1 Executable programs or shell commands -2 System calls (functions provided by the kernel) -3 Library calls (functions within program libraries) -4 Special files (usually found in /dev) -5 File formats and conventions eg /etc/passwd -6 Games -7 Miscellaneous (including macro packages and conventions), e.g. - man(7), groff(7) -8 System administration commands (usually only for root) -9 Kernel routines [Non standard] -``` - -Man pages cover more than what we typically think of as “commands”. As you can see from the above descriptions, they cover system calls, library calls, special files and more. - -The listing below shows where man pages are actually stored on Linux systems. The dates on these directories will vary because, with updates, some of these sections will get new content while others will not. - -``` -$ ls -ld /usr/share/man/man? -drwxr-xr-x 2 root root 98304 Feb 5 16:27 /usr/share/man/man1 -drwxr-xr-x 2 root root 65536 Oct 23 17:39 /usr/share/man/man2 -drwxr-xr-x 2 root root 270336 Nov 15 06:28 /usr/share/man/man3 -drwxr-xr-x 2 root root 4096 Feb 4 10:16 /usr/share/man/man4 -drwxr-xr-x 2 root root 28672 Feb 5 16:25 /usr/share/man/man5 -drwxr-xr-x 2 root root 4096 Oct 23 17:40 /usr/share/man/man6 -drwxr-xr-x 2 root root 20480 Feb 5 16:25 /usr/share/man/man7 -drwxr-xr-x 2 root root 57344 Feb 5 16:25 /usr/share/man/man8 -``` - -Note that the man page files are generally **gzipped** to save space. The man command unzips them as needed whenever you use the man command. - -``` -$ ls -l /usr/share/man/man1 | head -10 -total 12632 -lrwxrwxrwx 1 root root 9 Sep 5 06:38 [.1.gz -> test.1.gz --rw-r--r-- 1 root root 563 Nov 7 05:07 2to3-2.7.1.gz --rw-r--r-- 1 root root 592 Apr 23 2016 411toppm.1.gz --rw-r--r-- 1 root root 2866 Aug 14 10:36 a2query.1.gz --rw-r--r-- 1 root root 2361 Sep 9 15:13 aa-enabled.1.gz --rw-r--r-- 1 root root 2675 Sep 9 15:13 aa-exec.1.gz --rw-r--r-- 1 root root 1142 Apr 3 2018 aaflip.1.gz --rw-r--r-- 1 root root 3847 Aug 14 10:36 ab.1.gz --rw-r--r-- 1 root root 2378 Aug 23 2018 ac.1.gz -``` - -### Listing man pages by section - -Even just looking at the first 10 man pages in Section 1 (as shown above), you are likely to see some commands that are new to you – maybe **a2query** or **aaflip** (shown above). - -An even better strategy for exploring commands is to list commands by section without looking at the files themselves but, instead, using a man command that shows you the commands and provides a brief description of each. - -In the command below, the **-s 1** instructs man to display information on commands in section 1. The **-k .** makes the command work for all commands rather than specifying a particular keyword; without this, the man command would come back and ask “What manual page do you want?” So, use a keyword to select a group of related commands or a dot to show all commands in a section. - -``` -$ man -s 1 -k . -2to3-2.7 (1) - Python2 to Python3 converter -411toppm (1) - convert Sony Mavica .411 image to ppm -as (1) - the portable GNU assembler. -baobab (1) - A graphical tool to analyze disk usage -busybox (1) - The Swiss Army Knife of Embedded Linux -cmatrix (1) - simulates the display from "The Matrix" -expect_dislocate (1) - disconnect and reconnect processes -red (1) - line-oriented text editor -enchant (1) - a spellchecker -… -``` - -### How many man pages are there? - -If you’re curious about how many man pages there are in each section, you can count them by section with a command like this: - -``` -$ for num in {1..8} -> do -> man -s $num -k . | wc -l -> done -2382 -493 -2935 -53 -441 -11 -245 -919 -``` - -The exact number may vary, but most Linux systems will have a similar number of commands. If we use a command that adds these numbers together, we can see that the system that this command is running on has nearly 7,500 man pages. That’s a lot of commands, system calls, etc. - -``` -$ for num in {1..8} -> do -> num=`man -s $num -k . | wc -l` -> tot=`expr $num + $tot` -> echo $tot -> done -2382 -2875 -5810 -5863 -6304 -6315 -6560 -7479 <=== total -``` - -There’s a lot you can learn by reading man pages, but exploring them in other ways can help you become aware of commands you may not have known were available on your system. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html - -作者:[Sandra Henry-Stocker][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/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://unsplash.com/photos/YiRQIglwYig -[2]: https://creativecommons.org/publicdomain/zero/1.0/ -[3]: https://www.networkworld.com/slideshow/153439/linux-best-desktop-distros-for-newbies.html#tk.nww-infsb -[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/translated/tech/20200211 Navigating man pages in Linux.md b/translated/tech/20200211 Navigating man pages in Linux.md new file mode 100644 index 0000000000..5a160269e9 --- /dev/null +++ b/translated/tech/20200211 Navigating man pages in Linux.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Navigating man pages in Linux) +[#]: via: (https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 中遨游手册页的海洋 +====== + +> Linux 系统上的手册页可以做的不仅仅是提供特定命令的信息。它们可以帮助你发现你没有意识到的命令。 + +[Hello I'm Nik][1] [(CC0)][2] + +手册页提供了关于 Linux 命令的基本信息,很多用户经常参考它,但手册页的内容比我们很多人意识到的要多得多。 + +你总是可以输入一个像 `man who` 这样的命令,然后得到 `who` 命令的工作原理的漂亮描述,但是探索你可能不知道的命令可能会更有启发。例如,你可以使用 `man` 命令来帮助确定处理一些非常具有挑战性的任务的命令,或者显示一些选项,这些选项可以帮助你以新的更好的方式使用你已经知道的命令。 + +让我们来浏览一些选项,看看最终的结果是什么。 + +### 用 man 去识别命令 + +`man` 命令可以帮助你按主题查找命令。例如,如果你要找一个计算文件中的行数的命令,你可以提供一个关键字。在下面的例子中,我们把关键字 “count” 放在了引号中,并添加了空格,这样我们就不会得到与 “accounts” 或 “accounting” 相关的命令,而是得到那些可以为我们做一些计算的命令。 + +``` +$ man -k ' count ' +anvil (8postfix) - Postfix session count and request rate control +cksum (1) - checksum and count the bytes in a file +sum (1) - checksum and count the blocks in a file +timer_getoverrun (2) - get overrun count for a POSIX per-process timer +``` + +为了显示与新用户账户相关的命令,我们可以尝试使用这样的命令。 + +``` +$ man -k "new user" +newusers (8) - update and create new users in batch +useradd (8) - create a new user or update default new user information +zshroadmap (1) - informal introduction to the zsh manual The Zsh Manual, … +``` + +需要说明的是,上面的第三项只是提到 “new users” 类似的内容,并不是设置、删除或配置用户账号的命令。`man` 命令只是在命令描述中匹配了一些词,作用很像 `apropos` 命令。注意上面列出的每个命令后面的括号中的数字。这些数字与包含这些命令的手册页的部分有关。 + +### 确定手册页的部分 + +`man` 命令部分将命令划分为不同的类别。要列出这些类别,请键入 `man man`,并查看类似下面的描述。你的系统中很可能没有第 9 部分的命令。 + +- `1`:可执行程序或 shell 命令 +- `2`:系统调用(内核提供的函数) +- `3`:库调用(程序库内的函数) +- `4`:特殊文件(通常在可以 `/dev` 中找到) +- `5`:文件格式和惯例,例如 `/etc/passwd` +- `6`:游戏 +- `7`:杂项(包括宏包和约定),例如 `man`(7)、`groff`(7) +- `8`:系统管理命令(通常只由 root 用户使用) +- `9`:内核例程(非标准) + +手册页涵盖了比我们通常认为的“命令”更多的内容。从上面的描述中可以看到,它们涵盖了系统调用、库调用、特殊文件等等。 + +下面的列表显示了 Linux 系统中的手册页的实际存储位置。这些目录上的日期会有所不同,因为随着更新,其中一些部分会有新的内容,而另一些则不会。 + +``` +$ ls -ld /usr/share/man/man? +drwxr-xr-x 2 root root 98304 Feb 5 16:27 /usr/share/man/man1 +drwxr-xr-x 2 root root 65536 Oct 23 17:39 /usr/share/man/man2 +drwxr-xr-x 2 root root 270336 Nov 15 06:28 /usr/share/man/man3 +drwxr-xr-x 2 root root 4096 Feb 4 10:16 /usr/share/man/man4 +drwxr-xr-x 2 root root 28672 Feb 5 16:25 /usr/share/man/man5 +drwxr-xr-x 2 root root 4096 Oct 23 17:40 /usr/share/man/man6 +drwxr-xr-x 2 root root 20480 Feb 5 16:25 /usr/share/man/man7 +drwxr-xr-x 2 root root 57344 Feb 5 16:25 /usr/share/man/man8 +``` + +注意,为了节省空间,手册页文件一般都是 gzip 压缩的。每当你使用 `man` 命令时,`man` 命令会根据需要解压。 + +``` +$ ls -l /usr/share/man/man1 | head -10 +total 12632 +lrwxrwxrwx 1 root root 9 Sep 5 06:38 [.1.gz -> test.1.gz +-rw-r--r-- 1 root root 563 Nov 7 05:07 2to3-2.7.1.gz +-rw-r--r-- 1 root root 592 Apr 23 2016 411toppm.1.gz +-rw-r--r-- 1 root root 2866 Aug 14 10:36 a2query.1.gz +-rw-r--r-- 1 root root 2361 Sep 9 15:13 aa-enabled.1.gz +-rw-r--r-- 1 root root 2675 Sep 9 15:13 aa-exec.1.gz +-rw-r--r-- 1 root root 1142 Apr 3 2018 aaflip.1.gz +-rw-r--r-- 1 root root 3847 Aug 14 10:36 ab.1.gz +-rw-r--r-- 1 root root 2378 Aug 23 2018 ac.1.gz +``` + +### 按部分列出的手册页 + +即使只看第 1 部分的前 10 个手册页(如上所示),你也可能会看到一些新的命令 —— 也许是 `a2query` 或 `aaflip`(如上所示)。 + +探索命令的更好策略是按节列出命令,不查看文件本身,而是使用 `man` 命令向你显示命令并提供每个命令的简要说明。 + +在下面的命令中,`-s 1` 指示 `man` 显示第 1 部分中的命令信息。`-k .` 使该命令对所有命令都有效,而不是指定一个特定的关键字;如果没有这个,`man` 命令就会回过头来问:“你想要什么手册页?”所以,使用关键字来选择一组相关的命令,或者使用点来显示一个部分中的所有命令。 + +``` +$ man -s 1 -k . +2to3-2.7 (1) - Python2 to Python3 converter +411toppm (1) - convert Sony Mavica .411 image to ppm +as (1) - the portable GNU assembler. +baobab (1) - A graphical tool to analyze disk usage +busybox (1) - The Swiss Army Knife of Embedded Linux +cmatrix (1) - simulates the display from "The Matrix" +expect_dislocate (1) - disconnect and reconnect processes +red (1) - line-oriented text editor +enchant (1) - a spellchecker +… +``` + +### 有几本手册页? + +如果你对每个部分中有多少手册页感到好奇,可以使用以下命令按部分对它们进行计数: + +``` +$ for num in {1..8} +> do +> man -s $num -k . | wc -l +> done +2382 +493 +2935 +53 +441 +11 +245 +919 +``` + +确切的数量可能有所不同,但是大多数 Linux 系统的命令数量差不多。如果我们使用命令将这些数字加在一起,我们可以看到运行该命令的系统上有将近 7500 个手册页。有很多命令,系统调用等。 + +``` +$ for num in {1..8} +> do +> num=`man -s $num -k . | wc -l` +> tot=`expr $num + $tot` +> echo $tot +> done +2382 +2875 +5810 +5863 +6304 +6315 +6560 +7479 <=== total +``` + +阅读手册页可以学到很多东西,但是以其他方式浏览手册页可以帮助你了解系统上可能不知道的命令。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/YiRQIglwYig +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/slideshow/153439/linux-best-desktop-distros-for-newbies.html#tk.nww-infsb +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world From 15a4fb2a6e1e2d42a75143f627597d62f8703001 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Apr 2020 12:30:46 +0800 Subject: [PATCH 3/4] PRF @tinyeyeser --- ...ontrol the firewall at the command line.md | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/translated/tech/20200320 Control the firewall at the command line.md b/translated/tech/20200320 Control the firewall at the command line.md index d496e169a1..e9b0699347 100644 --- a/translated/tech/20200320 Control the firewall at the command line.md +++ b/translated/tech/20200320 Control the firewall at the command line.md @@ -1,47 +1,47 @@ [#]: collector: "lujun9972" -[#]: translator: "tinyeyeser " -[#]: reviewer: " " +[#]: translator: "tinyeyeser" +[#]: reviewer: "wxy" [#]: publisher: " " [#]: url: " " [#]: subject: "Control the firewall at the command line" [#]: via: "https://fedoramagazine.org/control-the-firewall-at-the-command-line/" [#]: author: "Paul W. Frields https://fedoramagazine.org/author/pfrields/" -命令行下玩转防火墙(Fedora) +在 Fedora 命令行下玩转防火墙 ====== -![][1] +![](https://img.linux.net.cn/data/attachment/album/202004/12/123040ghxuicphyhsoppch.jpg) 网络防火墙,顾名思义:为了阻止不需要的网络连接而设置的防护性屏障。在与外界建立连接或是提供网络服务时常常会用到。例如,在学校或是咖啡厅里使用笔记本电脑时,你一定不想某个陌生人窥探你的电脑。 -每个 Fedora 系统都内置了一款防火墙。这是 Linux 内核网络功能的一部分。本文介绍如何通过 *firewall-cmd* 命令修改防火墙的配置。 +每个 Fedora 系统都内置了一款防火墙。这是 Linux 内核网络功能的一部分。本文介绍如何通过 `firewall-cmd` 命令修改防火墙的配置。 ### 网络基础 本文并不教授计算机网络的[所有知识][2],但还是会简单介绍一些网络基础。 -网络中的所有计算机都有一个 *IP 地址*,可以把它想象成一个邮箱地址,有了邮箱地址,邮件才知道发往何处。每台计算机还会拥有一组*端口*,端口号范围从0到65535。同样的,你可以把这些端口想象成用来连接邮箱地址的连接点。 +网络中的所有计算机都有一个 *IP 地址*,可以把它想象成一个邮箱地址,有了邮箱地址,邮件才知道发往何处。每台计算机还会拥有一组*端口*,端口号范围从 0 到 65535。同样的,你可以把这些端口想象成用来连接邮箱地址的连接点。 -通常情况下,端口会是一个标准端口号或是根据应用程序的应答要求选定的一个端口范围。例如,一台 web server 通常会保留 80 端口用于 HTTP 通信,443 端口用于 HTTPS。小于1024的端口主要用于系统或常见用途,1024-49151端口用于注册,49152及以上端口多为临时使用(只短时间启用)。 +通常情况下,端口会是一个标准端口号或是根据应用程序的应答要求选定的一个端口范围。例如,一台 Web 服务器通常会保留 80 端口用于 HTTP 通信,443 端口用于 HTTPS。小于 1024 的端口主要用于系统或常见用途,1024-49151 端口是已经注册的,49152 及以上端口多为临时使用(只限短时间使用)。 -互联网传输中最常见的两个协议,[TCP][4] 和 [UDP][5]。当要传输的数据很重要,不能有丢包时,就使用TCP协议,如果数据包没有按顺序到达,还需要重组为正确的顺序。UDP协议则更多用于对时间敏感的服务,为了保证时效性,有时允许丢失部分数据。 +互联网传输中最常见的两个协议,[TCP][4] 和 [UDP][5]。当要传输的数据很重要,不能有丢包时,就使用 TCP 协议,如果数据包没有按顺序到达,还需要重组为正确的顺序。UDP 协议则更多用于对时间敏感的服务,为了保证时效性,有时允许丢失部分数据。 -系统中运行的应用,例如 web server,会保留一些端口(例如上文提到的80和443)。在网络传输过程中,主机会为传输的两端建立一个链接,一端是源地址和源端口,另一端是目的地址和目的端口。 +系统中运行的应用,例如 Web 服务器,会保留一些端口(例如上文提到的 80 和 443)。在网络传输过程中,主机会为传输的两端建立一个链接,一端是源地址和源端口,另一端是目的地址和目的端口。 -网络防火墙就是基于地址、端口及其他标准的一组规则集,来对网络数据的传输进行屏蔽或阻断的。通过 *fire-cmd* 命令,我们就可以查看或修改防火墙的工作配置。 +网络防火墙就是基于地址、端口及其他标准的一组规则集,来对网络数据的传输进行屏蔽或阻断的。通过 `firewall-cmd` 命令,我们就可以查看或修改防火墙的工作配置。 ### 防火墙域(zone) -为了验证防火墙是否开启,使用 *firewall-cmd* 命令,输入时要加上[sudo](https://fedoramagazine.org/howto-use-sudo/)。(通常,在运行了[PolicyKit](https://en.wikipedia.org/wiki/Polkit)的环境中,你也可以不加 *sudo*) +为了验证防火墙是否开启,使用 `firewall-cmd` 命令,输入时要加上 [sudo](https://fedoramagazine.org/howto-use-sudo/)。(通常,在运行了 [PolicyKit](https://en.wikipedia.org/wiki/Polkit) 的环境中,你也可以不加 `sudo`) ``` $ sudo firewall-cmd --state running ``` -firewalld 服务支持任意数量的域。每个域都可以拥有独立的配置和防护规则。一台 Fedora 工作站的外部接口(例如 WIFI 或有线网卡)其默认域为 *FedoraWorkstation*。 +firewalld 服务支持任意数量的域。每个域都可以拥有独立的配置和防护规则。一台 Fedora 工作站的外部接口(例如 WIFI 或有线网卡)其默认域为 `FedoraWorkstation`。 -要看有哪些域是激活状态,可以使用 *–get-active-zones* 选项。在本示例中,有两个网卡,有线以太网卡 *wlp2s0* 和虚拟( libvirt )桥接网卡 *virbr0* : +要看有哪些域是激活状态,可以使用 `-–get-active-zones` 选项。在本示例中,有两个网卡,有线以太网卡 `wlp2s0` 和虚拟(libvirt)桥接网卡 `virbr0`: ``` $ sudo firewall-cmd --get-active-zones @@ -60,58 +60,54 @@ $ sudo firewall-cmd --get-zones FedoraServer FedoraWorkstation block dmz drop external home internal libvirt public trusted work ``` -查询默认域中防火墙放行了哪些系统,使用 *–list-services* 选项。下例给出了一个定制系统的查询结果,你可以看到与常见的结果有些不同。 +查询默认域中防火墙放行了哪些系统,使用 `-–list-services` 选项。下例给出了一个定制系统的查询结果,你可以看到与常见的结果有些不同。 ``` $ sudo firewall-cmd --list-services dhcpv6-client mdns samba-client ssh ``` -该系统对外开启了四个服务。每个服务都对应一个常见端口。例如 *ssh* 服务对应 22 端口。 +该系统对外开启了四个服务。每个服务都对应一个常见端口。例如 `ssh` 服务对应 22 端口。 -如果要查看当前域中防火墙还开启了哪些端口,可以使用 *list-ports* 选项。当然,你也可以随时对其他域进行查询: +如果要查看当前域中防火墙还开启了哪些端口,可以使用 `--list-ports` 选项。当然,你也可以随时对其他域进行查询: ``` $ sudo firewall-cmd --list-ports --zone=FedoraWorkstation 1025-65535/udp 1025-65535/tcp ``` -结果表明,从 1025 到 65535 端口(包含UDP和TCP)默认都是开启的。 +结果表明,从 1025 到 65535 端口(包含 UDP 和 TCP)默认都是开启的。 ### 修改域、端口及服务 -以上的配置都是预先设计好的防火墙策略(design decision*)。是为了确保新手用户安装的应用都能够正常访问网络。如果你确定自己心里有数,想要一个保护性更强的策略,可以将接口放入 _FedoraServer_ 域,明确禁止所有端口的访问。_(**警告**:如果你的服务器之前是联网状态,这么做可能会导致连接中断,那你就得到机房里去修改更多的配置项!)_ +以上的配置都是预先设计好的防火墙策略。是为了确保新手用户安装的应用都能够正常访问网络。如果你确定自己心里有数,想要一个保护性更强的策略,可以将接口放入 `FedoraServer` 域,明确禁止所有端口的访问。(**警告**:如果你的服务器之前是联网状态,这么做可能会导致连接中断,那你就得到机房里去修改更多的配置项!) ``` $ sudo firewall-cmd --change-interface= --zone=FedoraServer success ``` -* _*本文并不讨论如何制定防火墙策略,Fedora社区里已经有很多讨论了。你大可以按照自身需要来修改配置。_ +**本文并不讨论如何制定防火墙策略,Fedora 社区里已经有很多讨论了。你大可以按照自身需要来修改配置。** -如果你想要开放某个服务的常见端口,可以将该服务加入默认域(或使用 _-zone_ 指定一个不同的域)。还可以一次性将其加入多个域。下例开放了 HTTP 和 HTTPS 的常见端口80、443: +如果你想要开放某个服务的常见端口,可以将该服务加入默认域(或使用 `--zone` 指定一个不同的域)。还可以一次性将其加入多个域。下例开放了 HTTP 和 HTTPS 的常见端口 80、443: ``` $ sudo firewall-cmd --add-service=http --add-service=https success ``` -并非所有的服务都有默认端口,不过大部分都是有的。使用 _–get-services_ 选项可以查看完整列表。 +并非所有的服务都有默认端口,不过大部分都是有的。使用 `-–get-services` 选项可以查看完整列表。 -如果你想指定某个特定端口号,可以直接用数字和协议进行配置。(多数情况下,_–add-service_ 和 _–add-port_ 这两个选项是合在一起使用的)下例开启的是UDP协议的网络启动服务: +如果你想指定某个特定端口号,可以直接用数字和协议进行配置。(多数情况下,`-–add-service` 和 `-–add-port` 这两个选项是合在一起使用的)下例开启的是 UDP 协议的网络启动服务: ``` $ sudo firewall-cmd --add-port=67/udp success ``` -**重要**:如果想要在系统重启或是 firewalld 服务重启后,配置仍然生效,**必须**在命令中加上 _–permanent_ 选项。本文中的例子只是临时修改了配置,下次遇到系统重启或是 firewalld 服务重启,这些配置就失效了。 +**重要**:如果想要在系统重启或是 firewalld 服务重启后,配置仍然生效,**必须**在命令中加上 `-–permanent` 选项。本文中的例子只是临时修改了配置,下次遇到系统重启或是 firewalld 服务重启,这些配置就失效了。 -以上只是 _firewall-cmd_ 和 firewalld 服务诸多功能中的一小部分。firewalld 项目的[主页][8]还有更多信息值得你去探索和尝试。 - -* * * - -_Photo by [Jakob Braun][9] on [Unsplash][10]._ +以上只是 `firewall-cmd` 和 firewalld 服务诸多功能中的一小部分。firewalld 项目的[主页][8]还有更多信息值得你去探索和尝试。 -------------------------------------------------------------------------------- @@ -120,7 +116,7 @@ via: https://fedoramagazine.org/control-the-firewall-at-the-command-line/ 作者:[Paul W. Frields][a] 选题:[lujun9972][b] 译者:[tinyeyeser](https://github.com/tinyeyeser) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a9fb67ea1394d254a1deb9fa503a223aa956c0e2 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Apr 2020 12:31:20 +0800 Subject: [PATCH 4/4] PUB @tinyeyeser https://linux.cn/article-12103-1.html --- .../20200320 Control the firewall at the command line.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20200320 Control the firewall at the command line.md (99%) diff --git a/translated/tech/20200320 Control the firewall at the command line.md b/published/20200320 Control the firewall at the command line.md similarity index 99% rename from translated/tech/20200320 Control the firewall at the command line.md rename to published/20200320 Control the firewall at the command line.md index e9b0699347..4cf7283963 100644 --- a/translated/tech/20200320 Control the firewall at the command line.md +++ b/published/20200320 Control the firewall at the command line.md @@ -1,8 +1,8 @@ [#]: collector: "lujun9972" [#]: translator: "tinyeyeser" [#]: reviewer: "wxy" -[#]: publisher: " " -[#]: url: " " +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12103-1.html" [#]: subject: "Control the firewall at the command line" [#]: via: "https://fedoramagazine.org/control-the-firewall-at-the-command-line/" [#]: author: "Paul W. Frields https://fedoramagazine.org/author/pfrields/"