Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-12-02 11:57:59 +08:00
commit 9d2de4a266
13 changed files with 1004 additions and 951 deletions

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11635-1.html)
[#]: subject: (6 signs you might be a Linux user)
[#]: via: (https://opensource.com/article/19/10/signs-linux-user)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
@ -12,7 +12,7 @@ Linux 资深用户的 6 大特征
> 如果你是 Linux 资深用户,则可能会有这些共同倾向。
![Tux with binary code background][1]
![](https://img.linux.net.cn/data/attachment/album/201912/02/093348ek4jcyvj4wahytwq.jpg)
Linux 用户千差万别,但是我们许多人都有一些相同的习惯。你可能没有本文列出的任何特征,而且如果你是个 Linux 新用户,你可能还不能理解这些特征……
@ -20,17 +20,17 @@ Linux 用户千差万别,但是我们许多人都有一些相同的习惯。
### 1、理所当然纪元始于 1970 年 1 月 1 日
关于 Unix 计算机时钟为何在重置时总是将其设置回 1970-01-01 的传闻有很多。但有点令人感到乏味的事实是Unix “纪元”是用于同步的通用且简单的参考点。例如,万圣节在儒略历中是今年的 304 日,但我们通常将该节日称为 “31 日”。我们知道指的是哪个月 31 日,因为我们有个共同的参考点:我们知道万圣节在 10 月庆祝,而 10 月是一年中的第十个月,并且我们知道前面每一个月包含多少天。没有这些值,虽然我们可以使用传统的计时方法(如月相)来跟踪特殊的季节性事件,但是计算机显然不具备这种能力。
关于 Unix 计算机时钟为何在重置时总是将其设置回 1970-01-01 的传闻有很多。但有点令人感到乏味的事实是Unix “纪元”是用于同步的通用且简单的参考点。例如,万圣节在儒略历中是今年的 304 日,但我们通常将该节日称为 “31 号”。我们知道指的是哪个月的 31 号,因为我们有个共同的参考点:我们知道万圣节在 10 月庆祝,而 10 月是一年中的第十个月,并且我们知道前面每一个月包含多少天。没有这些值,虽然我们可以使用传统的计时方法(如月相)来跟踪特殊的季节性事件,但是计算机显然不具备这种能力。
计算机需要确定且明确定义的值,因此将值 `1970-01-01T00:00:00Z` 选择为 Unix 纪元的开始。每当 [POSIX][2] 计算机的时间不准确时诸如网络时间协议NTP之类的服务就可以向其提供自 `1970-01-01T00:00:00Z` 以来的秒数,计算机可以将其转换为人类易于识别的日期。
日期和时间是在计算中要追踪的著名的复杂事物,主要是因为几乎所有标准都有例外。一个月并不总是有 30 天,一年也不总是有 365 天,甚至每年有多少秒钟也往往会有所不同。如果你正在寻找一个有趣而令人沮丧的编程练习,请尝试编程一个可靠的日历应用程序!
日期和时间是在计算中要追踪的著名的复杂事物,主要是因为几乎所有标准都有例外。一个月并不总是有 30 天,一年也不总是有 365 天,甚至每年有多少秒钟也往往会有所不同。如果你正在寻找一个有趣而令人沮丧的编程练习,那么请尝试编程一个可靠的日历应用程序!
### 2、输入超过两个字母你就会觉得麻烦
众所周知,最常见的 Unix 命令都超简短。除了 `cd`、`ls` 和 `mv` 之类的命令外,还有一个命令简直不能再短了:`w`(它根据 `/var/run/utmp` 文件显示当前登录了)。
众所周知,最常见的 Unix 命令都超简短。除了 `cd`、`ls` 和 `mv` 之类的命令外,还有一个命令简直不能再短了:`w`(它根据 `/var/run/utmp` 文件显示当前登录了)。
一方面,极短的命令似乎很不直观。新用户可能不会猜测到键入 `ls`<ruby>列出<rt>list</rt></ruby>目录。但是,一旦学习命令,它们肯定是越短越好。如果你整天都在终端上度过,那么你键入的击键次数越少就意味着你可以更多的时间来完成工作。
一方面,极短的命令似乎很不直观。新用户可能不会猜测到键入 `ls`<ruby>列出<rt>list</rt></ruby>目录。但是,一旦学习命令,它们肯定是越短越好。如果你整天都在终端上度过,那么你键入的击键次数越少就意味着你可以更多的时间来完成工作。
幸运的是,单字母命令并不太多,因此你可以使用大多数字母作为别名。例如,我经常使用 Emacs以至于我觉得 `emacs` 的输入时间太长,因此通过将下面这行添加到 `.bashrc` 文件中,将其别名为 `e`
@ -78,10 +78,10 @@ $ cp report-latest.txt reports_daily/2019-31-10.log
trash $HOME/Documents/reports-latest.txt
wget myserver.local/reports/daily/report-latest.txt \
-P $HOME/Documents/udpates_daily/`date --iso-8601`.log
-P $HOME/Documents/udpates_daily/`date --iso-8601`.log
cp $HOME/Documents/udpates_daily/`date --iso-8601`.log \
$HOME/Documents/reports-latest.txt
$HOME/Documents/reports-latest.txt
```
你可以把你的脚本叫做 `get-reports.sh` 并在每天早晨手动启动它,或者甚至可以将其输入到 crontab 中,以便计算机可以执行此任务而无需你进行任何干预。
@ -93,7 +93,7 @@ $HOME/Documents/reports-latest.txt
3. 将图像导出为修改后的文件
4. 关闭应用程序
如果你一天要做几次你可能会对这种重复感到厌倦。但是由于你是在图形用户界面GUI中执行这些操作的因此你需要知道如何编写 GUI 脚本以使其自动化。某些应用程序,例如 [GIMP][4],具有丰富的脚本接口,但是其过程显然不同于仅修改一堆命令并将其存储到文件中那么简单。
如果你一天要做几次你可能会对这种重复感到厌倦。但是由于你是在图形用户界面GUI中执行这些操作的因此你需要知道如何对 GUI 编写脚本以使其自动化。某些应用程序,例如 [GIMP][4],具有丰富的脚本接口,但是其过程显然不同于仅修改一堆命令并将其存储到文件中那么简单。
再说一次,有时在命令行中有与你在 GUI 中所做的等效的操作。将文档从一种文本格式转换为另一种格式可以使用 [Pandoc][5],处理图像可以使用 [Image Magick][6],音乐和视频也可以通过命令行进行编辑和转换,等等。最大的问题是你需要知道要查找什么,通常是学习新的(有时是复杂的)命令。但是,在终端中按比例缩小图像比在 GUI 中显然更简单:
@ -107,7 +107,7 @@ convert "${1}" -scale 50% `basename "${1}" .jpg`_50.jpg
### 5、发行版之间跳来跳去
我在家里是一个热情的 Slackware 用户,而在工作时是一个 RHEL 用户。实际上,这不是事实,我现在在工作时是 Fedora 用户。除了有时候我使用 CentOS有时候我还会运行 [Mageia][7]。
我在家里是一个热情的 Slackware 用户,而在工作时是一个 RHEL 用户。实际上,这不是事实,我现在在工作时是 Fedora 用户。除了有时候我使用 CentOS偶尔我还会运行 [Mageia][7]。
![Debian on a PowerPC64 box, image CC BY SA Claudio Miranda][8]
@ -123,7 +123,7 @@ convert "${1}" -scale 50% `basename "${1}" .jpg`_50.jpg
### 6、你对开源充满热情
无论你的经验如何,如果你是 Linux 用户,那么你无疑会对开源充满热情。无论你是每天通过[共创艺术品] [11]还是代码来表达你的热情,还是将其升华到只在自由而自在环境中完成工作,你都生活并构筑于开源之上。因为有了千千万万个你,所以有了开源社区,社区因你而变得更加丰富。
无论你的经验如何,如果你是 Linux 用户,那么你无疑会对开源充满热情。无论你是每天通过[共创艺术品] [11]还是代码来表达你的热情,还是将其升华到只在自由而自在环境中完成工作,你都生活并构筑于开源之上。因为有了千千万万个你,所以有了开源社区,社区因你而变得更加丰富。
有太多的东西我没有提到。作为 Linux 用户,还有什么可以出卖你的身份?让我们在评论中知道!

View File

@ -0,0 +1,85 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11632-1.html)
[#]: subject: (Edit images on Fedora easily with GIMP)
[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/)
[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/)
在 Fedora 上使用 GIMP 轻松编辑图像
======
![][1]
GIMPGNU Image Manipulation Program 的缩写)是自由开源的图像处理软件。它有很多的功能,从简单的图像编辑,到复杂的滤镜、脚本,甚至是动画,它是流行的商业同类软件的一款很好的替代品。
继续阅读来学习如何在 Fedora 上安装和使用 GIMP。这篇文章涉及基本的日常图像编辑工作。
### 安装 GIMP
GIMP 在官方 Fedora 存储库中可获得。为安装它,运行:
```
sudo dnf install gimp
```
### 单窗口模式
在你打开应用程序后,它显示带有工具箱和主编辑区的暗色主题窗口。注意,它有两种窗口模式,你可以通过选择“<ruby>窗口<rt>Windows</rt></ruby> -> <ruby>单窗口模式<rt>Single Window Mode</rt></ruby>”在其中切换。通过选中这个选项,用户界面的所有组件将显示在单个窗口中。否则,它们将是分离的。
### 加载图像
![][2]
为加载图像,转到“<ruby>文件<rt>File</rt></ruby> -> <ruby>打开<rt>Open</rt></ruby>”,然后选择你的文件并选择你的图像文件。
### 重新调整一个图像的大小
为重新调整图像大小,你可以基于一对参数重新调整大小,包括像素和百分比 —— 在编辑图像时,这两个参数很方便。
让我们假使我们需要缩小 Fedora 30 背景图像到它当前大小的 75%。为此,选择“<ruby>图像<rt> Image</rt></ruby> -> <ruby>比例<rt>Scale</rt></ruby>”,然后在比例对话框上,在单位下拉列表中选择“<ruby>百分比<rt>percentage</rt></ruby>”。接下来,输入 “75” 作为宽度或高度,然后按 Tab 键。默认情况下,其它尺寸将自动地调整大小,以相应地与更改的尺寸保持纵横比。现在,保存其它选项不变,并按比例。
![][3]
该图像缩小到其原始尺寸的 75%。
### 旋转图像
旋转是一种变换操作,因此,你可以从主菜单下的“<ruby>图像<rt>Image</rt></ruby> -> <ruby>变换<rt>Transform</rt></ruby>”下找到它,其中有图像旋转 90° 或 180° 的选项。在上述选项下也有垂直或水平翻转图像的选项。
让我们假使我们需要旋转图像 90°。在应用一次 90° 顺时针旋转和水平翻转后,我们的图像将看起来像这样:
![Transforming an image with GIMP][4]
### 添加文本
添加文本非常简单。只需要从工具箱中选择 “A” 图标,然后,在你的图像上,单击你想要添加文本的位置。如果工具箱不可见,从“<ruby>窗口<rt>Windows</rt></ruby> -> <ruby>新建工具箱<rt>New Toolbox</rt></ruby>”打开它。
当你编辑文本时,你可能注意到,文本对话框有字体自定义选项,包括字体系列、字体大小等等。
![Adding text to image in GIMP][5]
### 保存和导出
你可以从“<ruby>文件<rt>File</rt></ruby> -> <ruby>保存<rt>Save</rt></ruby>”或通过按 `Ctrl+S` 来将你的编辑保存为一个带有 `.xcf` 扩展名的 GIMP 工程。或者,你可以导出你的图像,例如,以 PNG 或 JPEG 格式。为导出图像,转到“<ruby>文件<rt>File</rt></ruby> -> <ruby>导出为<rt>Export As</rt></ruby>”或按 `Ctrl+Shift+E`,接下来,在你面前将产生一个你可以选择输出图像和名称的对话框。
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/
作者:[Mehdi Haghgoo][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/powergame/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg
[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png
[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png
[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png
[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png

View File

@ -0,0 +1,200 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11633-1.html)
[#]: subject: (How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8)
[#]: via: (https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
如何在 CentOS 8/RHEL 8 上安装 Ansible自动化工具
======
Ansible 是给 Linux 系统管理员使用的出色自动化工具。它是一种开源配置工具,能让系统管理员可以从一个中心节点(即 Ansible 服务器)管理数百台服务器。将 Ansible 与 Puppet、Chef 和 Salt 等类似工具进行比较时,它是首选的配置工具,因为它不需要任何代理,并且可以工作在 SSH 和 python 上。
![](https://img.linux.net.cn/data/attachment/album/201912/01/223012czkxt6dhku6snhxn.jpg)
在本教程中,我们将学习如何在 CentOS 8 和 RHEL 8 系统上安装和使用 Ansble。
Ansible 实验环境信息:
* 最小化安装的 CentOS 8 / RHEL 8 服务器192.168.1.10),且有互联网连接
* 两个 Ansible 节点 - Ubuntu 18.04 LTS 192.168.1.20 和 CentOS 7 192.168.1.30
### CentOS 8 上的 Ansible 安装步骤
Ansible 包不在 CentOS 8 默认的软件包仓库中。因此,我们需要执行以下命令启用 [EPEL 仓库][3]
```
[root@linuxtechi ~]$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
```
启用 epel 仓库后,执行以下 `dnf` 命令安装 Ansible
```
[root@linuxtechi ~]$ sudo dnf install ansible
```
上面命令的输出:
![dnf-install-ansible-centos8][4]
成功安装 Ansible 后,运行以下命令验证它的版本:
```
[root@linuxtechi ~]$ sudo ansible --version
```
![Ansible-version-CentOS8][5]
上面的输出确认在 CentOS 8 上安装完成。
让我们看下 RHEL 8 系统。
### RHEL 8 上的 Ansible 安装步骤
如果你有有效的 RHEL 8 订阅,请使用以下订阅管理器命令启用 Ansble 仓库:
```
[root@linuxtechi ~]$ sudo subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms
```
启用仓库后,执行以下 `dnf` 命令安装 Ansible
```
[root@linuxtechi ~]$ sudo dnf install ansible -y
```
安装 Ansible 及其依赖包后,执行以下命令来验证它的版本:
```
[root@linuxtechi ~]$ sudo ansible --version
```
### 在 CentOS 8 / RHEL 8 上通过 pip3 安装 Ansible 的可选方法
如果你希望使用 `pip`Python 的包管理器)安装 Ansible请首先使用以下命令安装 pyhton3 和 python3-pip 包:
```
[root@linuxtechi ~]$ sudo dnf install python3 python3-pip -y
```
安装 python3 后,运行以下命令来验证它的版本:
```
[root@linuxtechi ~]$ python3 -V
Python 3.6.8
[root@linuxtechi ~]$
```
用下面的 `pip3` 命令安装 Ansible
```
[root@linuxtechi ~]$ pip3 install ansible --user
```
输出:
![Ansible-Install-pip3-centos8][6]
上面的输出确认 Ansible 已成功使用 `pip3` 安装。让我们看下如何使用 Ansible。
### 如何使用 Ansible 自动化工具?
当我们使用 `yum``dnf` 命令安装 Ansible 时,它的配置文件、清单文件和角色目录会自动在 `/etc/ansible` 文件夹下创建。
让我们添加一个名称为 `labservers` 的组,并在 `/etc/ansible/hosts` 文件中给该组添加上述的 Ubuntu 18.04 和 CentOS 7 系统的 IP 地址:
```
[root@linuxtechi ~]$ sudo vi /etc/ansible/hosts
[labservers]
192.168.1.20
192.168.1.30
```
保存并退出文件。
更新清单文件(`/etc/ansible/hosts`)后,将用户的 ssh 公钥放到属于 `labservers` 组的远程系统。
让我们首先使用 `ssh-keygen` 命令生成本地用户的公钥和私钥:
```
[root@linuxtechi ~]$ ssh-keygen
```
现在使用以下命令在 Ansible 服务器及其客户端之间交换公钥:
```
[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi
[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi
```
现在,让我们尝试几个 Ansible 命令,首先使用 `ping` 模块验证 Ansible 服务器与客户端的连接:
```
[root@linuxtechi ~]$ ansible -m ping "labservers"
```
注意: 如果我们没有在上面的命令中指定清单文件,那么它将引用默认主机文件(即 `/etc/ansible/hosts`)。
输出:
![ansible-ping-module-centos8][7]
让我们使用 Ansible shell 命令检查每个客户端的内核版本:
```
[root@linuxtechi ~]$ ansible -m command -a "uname -r" "labservers"
192.168.1.30 | CHANGED | rc=0 >>
4.15.0-20-generic
192.168.1.20 | CHANGED | rc=0 >>
3.10.0-327.el7.x86_64
[root@linuxtechi ~]$
```
使用以下命令列出清单文件中的所有主机:
```
[root@linuxtechi ~]$ ansible all -i /etc/ansible/hosts --list-hosts
hosts (4):
192.168.100.1
192.168.100.10
192.168.1.20
192.168.1.30
[root@linuxtechi ~]$
```
使用以下 Ansible 命令仅列出 `labservers` 组中的主机:
```
root@linuxtechi ~]$ ansible labservers -i /etc/ansible/hosts --list-hosts
hosts (2):
192.168.1.20
192.168.1.30
[root@linuxtechi ~]$
```
本文就是这些了,我们成功演示了如何在 CentOS 8 和 RHEL 8 系统中安装和使用 Ansible。请分享你的反馈和意见。
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/
作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Ansible-CentOS8-RHEL8.png
[3]: http://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/dnf-install-ansible-centos8-1536x652.png
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-version-CentOS8.png
[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-Install-pip3-centos8-1536x545.png
[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/ansible-ping-module-centos8.png

View File

@ -1,230 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 tips for GNU Debugger)
[#]: via: (https://opensource.com/article/19/9/tips-gnu-debugger)
[#]: author: (Tim Waugh https://opensource.com/users/twaugh)
5 tips for GNU Debugger
======
Learn how to use some of the lesser-known features of gdb to inspect and
fix your code.
![Bug tracking magnifying glass on computer screen][1]
The [GNU Debugger][2] (gdb) is an invaluable tool for inspecting running processes and fixing problems while you're developing programs.
You can set breakpoints at specific locations (by function name, line number, and so on), enable and disable those breakpoints, display and alter variable values, and do all the standard things you would expect any debugger to do. But it has many other features you might not have experimented with. Here are five for you to try.
### Conditional breakpoints
Setting a breakpoint is one of the first things you'll learn to do with the GNU Debugger. The program stops when it reaches a breakpoint, and you can run gdb commands to inspect it or change variables before allowing the program to continue.
For example, you might know that an often-called function crashes sometimes, but only when it gets a certain parameter value. You could set a breakpoint at the start of that function and run the program. The function parameters are shown each time it hits the breakpoint, and if the parameter value that triggers the crash is not supplied, you can continue until the function is called again. When the troublesome parameter triggers a crash, you can step through the code to see what's wrong.
```
(gdb) break sometimes_crashes
Breakpoint 1 at 0x40110e: file prog.c, line 5.
(gdb) run
[...]
Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5
5      fprintf(stderr,
(gdb) continue
Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5
5      fprintf(stderr,
(gdb) continue
```
To make this more repeatable, you could count how many times the function is called before the specific call you are interested in, and set a counter on that breakpoint (for example, "continue 30" to make it ignore the next 29 times it reaches the breakpoint).
But where breakpoints get really powerful is in their ability to evaluate expressions at runtime, which allows you to automate this kind of testing. Enter: conditional breakpoints.
```
break [LOCATION] if CONDITION
(gdb) break sometimes_crashes if !f
Breakpoint 1 at 0x401132: file prog.c, line 5.
(gdb) run
[...]
Breakpoint 1, sometimes_crashes (f=0x0) at prog.c:5
5      fprintf(stderr,
(gdb)
```
Instead of having gdb ask what to do every time the function is called, a conditional breakpoint allows you to make gdb stop at that location only when a particular expression evaluates as true. If the execution reaches the conditional breakpoint location, but the expression evaluates as false, the
debugger automatically lets the program continue without asking the user what to do.
### Breakpoint commands
An even more sophisticated feature of breakpoints in the GNU Debugger is the ability to script a response to reaching a breakpoint. Breakpoint commands allow you to write a list of GNU Debugger commands to run whenever it reaches a breakpoint.
We can use this to work around the bug we already know about in the **sometimes_crashes** function and make it return from that function harmlessly when it provides a null pointer.
We can use **silent** as the first line to get more control over the output. Without this, the stack frame will be displayed each time the breakpoint is hit, even before our breakpoint commands run.
```
(gdb) break sometimes_crashes
Breakpoint 1 at 0x401132: file prog.c, line 5.
(gdb) commands 1
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
&gt;silent
&gt;if !f
 &gt;frame
 &gt;printf "Skipping call\n"
 &gt;return 0
 &gt;continue
 &gt;end
&gt;printf "Continuing\n"
&gt;continue
&gt;end
(gdb) run
Starting program: /home/twaugh/Documents/GDB/prog
warning: Loadable section ".note.gnu.property" outside of ELF segments
Continuing
Continuing
Continuing
#0  sometimes_crashes (f=0x0) at prog.c:5
5      fprintf(stderr,
Skipping call
[Inferior 1 (process 9373) exited normally]
(gdb)
```
### Dump binary memory
GNU Debugger has built-in support for examining memory using the **x** command in various formats, including octal, hexadecimal, and so on. But I like to see two formats side by side: hexadecimal bytes on the left, and ASCII characters represented by those same bytes on the right.
When I want to view the contents of a file byte-by-byte, I often use **hexdump -C** (hexdump comes from the [util-linux][3] package). Here is gdb's **x** command displaying hexadecimal bytes:
```
(gdb) x/33xb mydata
0x404040 &lt;mydata&gt;:    0x02    0x01    0x00    0x02    0x00    0x00    0x00    0x01
0x404048 &lt;mydata+8&gt;:    0x01    0x47    0x00    0x12    0x61    0x74    0x74    0x72
0x404050 &lt;mydata+16&gt;:    0x69    0x62    0x75    0x74    0x65    0x73    0x2d    0x63
0x404058 &lt;mydata+24&gt;:    0x68    0x61    0x72    0x73    0x65    0x75    0x00    0x05
0x404060 &lt;mydata+32&gt;:    0x00
```
What if you could teach gdb to display memory just like hexdump does? You can, and in fact, you can use this method for any format you prefer.
By combining the **dump** command to store the bytes in a file, the **shell** command to run hexdump on the file, and the **define** command, we can make our own new **hexdump** command to use hexdump to display the contents of memory.
```
(gdb) define hexdump
Type commands for definition of "hexdump".
End with a line saying just "end".
&gt;dump binary memory /tmp/dump.bin $arg0 $arg0+$arg1
&gt;shell hexdump -C /tmp/dump.bin
&gt;end
```
Those commands can even go in the **~/.gdbinit** file to define the hexdump command permanently. Here it is in action:
```
(gdb) hexdump mydata sizeof(mydata)
00000000  02 01 00 02 00 00 00 01  01 47 00 12 61 74 74 72  |.........G..attr|
00000010  69 62 75 74 65 73 2d 63  68 61 72 73 65 75 00 05  |ibutes-charseu..|
00000020  00                                                |.|
00000021
```
### Inline disassembly
Sometimes you want to understand more about what happened leading up to a crash, and the source code is not enough. You want to see what's going on at the CPU instruction level.
The **disassemble** command lets you see the CPU instructions that implement a function. But sometimes the output can be hard to follow. Usually, I want to see what instructions correspond to a certain section of source code in the function. To achieve this, use the **/s** modifier to include source code lines with the disassembly.
```
(gdb) disassemble/s main
Dump of assembler code for function main:
prog.c:
11    {
   0x0000000000401158 &lt;+0&gt;:    push   %rbp
   0x0000000000401159 &lt;+1&gt;:    mov      %rsp,%rbp
   0x000000000040115c &lt;+4&gt;:    sub      $0x10,%rsp
12      int n = 0;
   0x0000000000401160 &lt;+8&gt;:    movl   $0x0,-0x4(%rbp)
13      sometimes_crashes(&amp;n);
   0x0000000000401167 &lt;+15&gt;:    lea     -0x4(%rbp),%rax
   0x000000000040116b &lt;+19&gt;:    mov     %rax,%rdi
   0x000000000040116e &lt;+22&gt;:    callq  0x401126 &lt;sometimes_crashes&gt;
[...snipped...]
```
This, along with **info registers** to see the current values of all the CPU registers and commands like **stepi** to step one instruction at a time, allow you to have a much more detailed understanding of the program.
### Reverse debug
Sometimes you wish you could turn back time. Imagine you've hit a watchpoint on a variable. A watchpoint is like a breakpoint, but instead of being set at a location in the program, it is set on an expression (using the **watch** command). Whenever the value of the expression changes, execution stops, and the debugger takes control.
So imagine you've hit this watchpoint, and the memory used by a variable has changed value. This can turn out to be caused by something that occurred much earlier; for example, the memory was freed and is now being re-used. But when and why was it freed?
The GNU Debugger can solve even this problem because you can run your program in reverse!
It achieves this by carefully recording the state of the program at each step so that it can restore previously recorded states, giving the illusion of time flowing backward.
To enable this state recording, use the **target record-full** command. Then you can use impossible-sounding commands, such as:
* **reverse-step**, which rewinds to the previous source line
* **reverse-next**, which rewinds to the previous source line, stepping backward over function calls
* **reverse-finish**, which rewinds to the point when the current function was about to be called
* **reverse-continue**, which rewinds to the previous state in the program that would (now) trigger a breakpoint (or anything else that causes it to stop)
Here is an example of reverse debugging in action:
```
(gdb) b main
Breakpoint 1 at 0x401160: file prog.c, line 12.
(gdb) r
Starting program: /home/twaugh/Documents/GDB/prog
[...]
Breakpoint 1, main () at prog.c:12
12      int n = 0;
(gdb) target record-full
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000401154 in sometimes_crashes (f=0x0) at prog.c:7
7      return *f;
(gdb) reverse-finish
Run back to call of #0  0x0000000000401154 in sometimes_crashes (f=0x0)
        at prog.c:7
0x0000000000401190 in main () at prog.c:16
16      sometimes_crashes(0);
```
These are just a handful of useful things the GNU Debugger can do. There are many more to discover. Which hidden, little-known, or just plain amazing feature of gdb is your favorite? Please share it in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/9/tips-gnu-debugger
作者:[Tim Waugh][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/twaugh
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen)
[2]: https://www.gnu.org/software/gdb/
[3]: https://en.wikipedia.org/wiki/Util-linux

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,138 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (hello-wn)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Top 10 Vim plugins for programming in multiple languages)
[#]: via: (https://opensource.com/article/19/11/vim-plugins)
[#]: author: (Maxim Burgerhout https://opensource.com/users/wzzrd)
Top 10 Vim plugins for programming in multiple languages
======
Make your life as a programmer or sysadmin a little better with these 10
plugins for Vim.
![OpenStack source code \(Python\) in VIM][1]
I've been a user of the [Vim][2] text editor for about two decades. For a little while, I have been customizing my Vim configuration, only using plugins for the last couple of years.
Recently, when I was redoing my setup (as I do every so often), I decided it was a good opportunity to identify the best Vim plugins for programming in multiple languages and a way to combine those plugins for each language I program in.
I do use certain plugins for specific languages and profiles (e.g., I only install Rocannon in my Ansible profile), and I won't go into those here—that would be a _long_ list. But the 10 Vim plugins described below are my favorites, the ones I use in virtually every profile I have, no matter what programming language I'm using.
### 1\. Volt
My number one pick isn't even a plugin; rather, it replaces plugins like [Vundle][3], so I'm listing it here.
[Volt][4] is a Vim plugin manager that lives outside Vim. You can use it to install plugins and create combinations of plugins called "profiles." You can enable a new profile with a single command: **volt profile set myprofile**. That way, I can do things like enable the [indentpython][5] plugin for just my Python profile. Volt also offers a simple way to do per-plugin configurations. The configuration is shared between profiles, so you can install plugins once and use them in multiple profiles.
Volt is still relatively new and not perfect (e.g., you can have just one configuration file per plugin, no matter how many profiles you are using), but apart from that, I find it extremely handy, extremely fast, and extremely simple.
![Volt plugin][6]
### 2\. Vim-Rainbow
Except for Python, virtually all major programming languages use brackets. Round ones, square ones, and curly ones. Often, they use multiple pairs of brackets, with one pair embedded in another. Figuring out which closing bracket belongs to what opening bracket can become difficult and annoying. I often find myself counting round brackets—especially in complicated Bash scripts—to make sure I got everything right.
Here's the [vim-rainbow][7] plugin to the rescue! It gives every pair of brackets a unique color, so it's easy to identify which brackets belong to each other. It's very useful and very colorful, too.
![vim-rainbow plugin][8]
### 3\. lightline
There are a lot of plugins for Vim, such as [Powerline][9], that put a bar at the bottom of the screen to show you what file you are working on, where you are in the file, what type of file it is, etc. Each of these plugins has advantages and disadvantages, and after briefly weighing them, I chose [lightline][10]. It's relatively small, easy to set up, quite extensible if you are into that kind of thing, and doesn't require any other tooling or plugins.
![Lightline plugin][11]
### 4\. NERDTree
[NERDTree][12] is a classic. In large projects, it can be hard to find the exact name and location of the one file that includes the one line you need to edit. With a quick keystroke (**F7**, in my case, as I bound NERDTree to F7 in my .vimrc configuration file), an explorer window opens in a vertical split, and I can easily browse to the file I want and open it. It's a must for large bodies of code. Or for people that tend to forget filenames, like me.
![NERDTree vim plugin][13]
### 5\. NERD Commenter
All programmers, at some time, write code that introduces a hard-to-debug problem that leads them to decide to comment out or undo the code. This is where [NERD Commenter][14] comes in. Select the code, hit **Leader+cc**, and your code is commented. (The standard Vim Leader key is the **/** character.) Hit **Leader+cn,** and your code is uncommented. NERD Commenter should automatically use the right commenting character for most file types. For example, if you are editing a [BIND zone file][15] and set the file type to bind zone, Vim will correctly use the **;** (semicolon) character to comment lines out.
![NERD Commenter][16]
### 6\. Solarized
I love my Vim colors. Really, I love terminal colors in general. I've been using the [Solarized][17] color scheme for Vim for a long time, and I set up my terminal, dir_colors, and Vim to be consistent.
Every now and then, though, I toggle between light and dark modes, depending on what kind of environment I'm in, the amount of light falling on my screen, and whether I need to put something on a big screen for others to read.
Obviously, you can grab any ol' color scheme you like, but I like the fact that Solarized has light and dark modes, an easy way to switch between the two, and it's not too intrusive. My second choice is [Monokai][18]. The Volt plugin manager makes it easy for me to switch between the two, so I can use Monokai for Python programming and Solarized for Bash.
I'm not including an image for Solarized, because all the other images in this article use Solarized light or dark, so check them out.
### 7\. fzf
When you're looking for a file, sometimes you want a file explorer, and sometimes you just want to ram something on your keyboard that vaguely resembles the filename you are looking for, amirite?
The [fzf][19] (or "fuzzy finder") plugin gives you just that. Hit **:FZF** and start typing. An ever-shortening list will show you files that more or less match what you are looking for. I use this a lot, probably even more than NERDTree these days. A slight downside is that this plugin has an external dependency in the fzf binary, so you'll have to install that, too. It's available for Fedora, Debian and, Arch, but I don't think it exists for EPEL.
![fzf Vim plugin][20]
### 8\. ack
Every once in a while, you want to search for a file that contains a certain line or a certain word. I really like the [ack][21] plugin for this, preferably in combination with **ag**, a command known as "the [silver searcher][22]." This combination is phenomenally fast and covers the vast majority of things I would use **grep** or **vimgrep** for. The downside is you'll need to install either ack or ag for it to work. The good news is that both ag and ack are available for Fedora and EPEL7.
![ack vim plugin][23]
### 9\. gitgutter
The majority of IT folks have worked with [Git][24] and files in Git repositories. The [gitgutter][25] plugin adds a column near your line numbers that shows symbols for changed (**~**), added (**+**), and removed (**-**) lines. This is quite useful for keeping track of what you have changed, and it keeps you focused on the task at hand, like writing a patch to fix one key bug. This plugin has a slight performance gap, and it sometimes takes a quick second for the plugin to catch up with your changes, but it's still quite useful.
![gitgutter vim plugin][26]
### 10\. Tag List
If you are programming in a file of any significant size, it's easy to lose track of where you are, and you might find yourself scrolling up and down looking for a certain function. With the [Tag List][27] plugin, you can just type **:Tlist** and get a vertical split with variables, types, classes, and functions that you can easily jump to. This works for a host of languages, like Java, Python, and any other file type the **ctags** utility works with … which is a lot.
![Tag List vim plugin][28]
So there you are: the 10 plugins for Vim that have made my life as a sysadmin and part-time programmer a little easier and a little better. What Vim plugins you are using? Please share your favorites in the comments.
Vim offers great benefits to writers, regardless of whether they are technically minded or not.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/11/vim-plugins
作者:[Maxim Burgerhout][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/wzzrd
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm (OpenStack source code (Python) in VIM)
[2]: https://www.vim.org/
[3]: https://github.com/VundleVim/Vundle.vim
[4]: https://github.com/vim-volt/volt
[5]: https://github.com/vim-scripts/indentpython.vim
[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif (Volt plugin)
[7]: http://github.com/frazrepo/vim-rainbow
[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png (vim-rainbow plugin)
[9]: https://github.com/powerline/powerline
[10]: http://github.com/itchyny/lightline.vim
[11]: https://opensource.com/sites/default/files/uploads/lightline.png (Lightline plugin)
[12]: http://github.com/scrooloose/nerdtree
[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif (NERDTree vim plugin)
[14]: http://github.com/scrooloose/nerdcommenter
[15]: https://en.wikipedia.org/wiki/Zone_file#File_format
[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif (NERD Commenter)
[17]: https://github.com/altercation/vim-colors-solarized
[18]: https://github.com/sickill/vim-monokai
[19]: https://github.com/junegunn/fzf.vim
[20]: https://opensource.com/sites/default/files/uploads/fzf.gif (fzf Vim plugin)
[21]: https://github.com/mileszs/ack.vim
[22]: https://github.com/ggreer/the_silver_searcher
[23]: https://opensource.com/sites/default/files/uploads/ack.gif (ack vim plugin)
[24]: https://opensource.com/resources/what-is-git
[25]: https://github.com/airblade/vim-gitgutter
[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png (gitgutter vim plugin)
[27]: https://github.com/vim-scripts/taglist.vim
[28]: https://opensource.com/sites/default/files/uploads/taglist.gif (Tag List vim plugin)

View File

@ -1,275 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal)
[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
5 Commands to Find the IP Address of a Domain in the Linux Terminal
======
This tutorial shows you how to verify a domain names or computer name IP address from a Linux terminal.
This tutorial will allow you to check multiple domains at once.
You may have already used these commands to verify information.
However, we will teach you how to use these commands effectively to identify multiple domain IP address information from the Linux terminal.
This can be done using the following 5 commands.
* **dig Command:** dig is a flexible cli tool for interrogating DNS name servers.
* **host Command:** host is a simple utility for performing DNS lookups.
* **nslookup Command:** Nslookup command is used to query Internet domain name servers.
* **fping Command:** fping command is used to send ICMP ECHO_REQUEST packets to network hosts.
* **ping Command:** ping command is used to send ICMP ECHO_REQUEST packets to network hosts.
To test this, we created a file called “domains-list.txt” and added the below domains.
```
# vi /opt/scripts/domains-list.txt
2daygeek.com
magesh.co.in
linuxtechnews.com
```
### Method-1: How to Find a IP Address of the Domain Using the dig Command
**[dig command][1]** stands for “domain information groper” is a powerful and flexible command-line tool for querying DNS name servers.
It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried.
Most DNS administrators use dig command to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output.
It also has a batch mode functionality to read search requests from a file.
```
# dig 2daygeek.com | awk '{print $1,$5}'
2daygeek.com. 104.27.157.177
2daygeek.com. 104.27.156.177
```
Use the following bash script to find the multiple domains IP address.
```
# vi /opt/scripts/dig-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
dig $server +short
done | paste -d " " - - -
```
Once the above script is added to a file. Set the executable permission for the “dig-command.sh” file.
```
# chmod +x /opt/scripts/dig-command.sh
```
Finally run the bash script to get the output.
```
# sh /opt/scripts/dig-command.sh
2daygeek.com - 104.27.156.177 104.27.157.177
magesh.co.in - 104.18.35.52 104.18.34.52
linuxtechnews.com - 104.27.144.3 104.27.145.3
```
If you want to run the above script in one line, use the following script.
```
# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - -
```
Alternatively, you can use the following shell script to find the IP address of the multiple domain.
```
# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done
2daygeek.com. 104.27.157.177
2daygeek.com. 104.27.156.177
magesh.co.in. 104.18.34.52
magesh.co.in. 104.18.35.52
linuxtechnews.com. 104.27.144.3
linuxtechnews.com. 104.27.145.3
```
### Method-2: How to Find a Domains IP Address Using the host Command
**[Host Command][2]** is a simple CLI application to perform **[DNS lookup][3]**.
It is commonly used to convert names to IP addresses and vice versa.
When no arguments or options are given, host prints a short summary of its command line arguments and options.
You can view all types of records in the domain by adding a specific option or type of record in the host command.
```
# host 2daygeek.com | grep "has address" | sed 's/has address/-/g'
2daygeek.com - 104.27.157.177
2daygeek.com - 104.27.156.177
```
Use the following bash script to find the multiple domains IP address.
```
# vi /opt/scripts/host-command.sh
for server in `cat /opt/scripts/domains-list.txt`
do host $server | grep "has address" | sed 's/has address/-/g'
done
```
Once the above script is added to a file. Set the executable permission for the “host-command.sh” file.
```
# chmod +x /opt/scripts/host-command.sh
```
Finally run the bash script to get the output.
```
# sh /opt/scripts/host-command.sh
2daygeek.com - 104.27.156.177
2daygeek.com - 104.27.157.177
magesh.co.in - 104.18.35.52
magesh.co.in - 104.18.34.52
linuxtechnews.com - 104.27.144.3
linuxtechnews.com - 104.27.145.3
```
### Method-3: How to Find the IP Address of a Domain Using the nslookup Command
**[nslookup command][4]** is a program for querying Internet **[domain name servers (DNS)][5]**.
nslookup has two modes, which are interactive and interactive.
Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain.
Non-interactive mode is used to print just the name and requested information for a host or domain.
It is a network administration tool that helps diagnose and resolve DNS related issues.
```
# nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1
104.27.157.177
104.27.156.177
```
Use the following bash script to find the multiple domains IP address.
```
# vi /opt/scripts/nslookup-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - -
```
Once the above script is added to a file. Set the executable permission for the “nslookup-command.sh” file.
```
# chmod +x /opt/scripts/nslookup-command.sh
```
Finally run the bash script to get the output.
```
# sh /opt/scripts/nslookup-command.sh
2daygeek.com - 104.27.156.177 104.27.157.177
magesh.co.in - 104.18.35.52 104.18.34.52
linuxtechnews.com - 104.27.144.3 104.27.145.3
```
### Method-4: How to Find a Domains IP Address Using the fping Command
**[fping command][6]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding.
fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file.
fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds.
If a target host replies, it is noted as active and removed from the list of targets to check; if a target does not respond within a certain time limit and/or retry limit it is designated as unreachable.
```
# fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com
104.27.157.177 (104.27.157.177) is alive
104.18.35.52 (104.18.35.52) is alive
104.27.144.3 (104.27.144.3) is alive
```
### Method-5: How to Find the IP Address of the Domain Using the ping Command
**[ping command][6]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network.
Its verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply.
It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the min/avg/max times.
```
# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g'
104.27.157.177
```
Use the following bash script to find the multiple domains IP address.
```
# vi /opt/scripts/ping-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g'
done | paste -d " " - -
```
Once the above script is added to a file. Set the executable permission for the “dig-command.sh” file.
```
# chmod +x /opt/scripts/ping-command.sh
```
Finally run the bash script to get the output.
```
# sh /opt/scripts/ping-command.sh
2daygeek.com - 104.27.156.177
magesh.co.in - 104.18.35.52
linuxtechnews.com - 104.27.144.3
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/
作者:[Magesh Maruthamuthu][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.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/
[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/
[3]: https://www.2daygeek.com/category/dns-lookup/
[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/
[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/
[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/

View File

@ -0,0 +1,72 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Modernize your Linux desktop with Enlightenment)
[#]: via: (https://opensource.com/article/19/12/linux-enlightenment-desktop)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Modernize your Linux desktop with Enlightenment
======
This article is part of a special series of 24 days of Linux desktops.
Enlightenment offers a smooth, appealing, and modern Linux desktop
experience, even on older hardware.
![Light at the end of the tunnel][1]
One of Linux's many advantages is its ability to install and run on old computers. What Linux can't _technically_ do is make an old computer's hardware magically perform better. After all, the hardware is the same hardware as ever, and sometimes old hardware feels notably slow when processing modern software that tries to take advantage of new hardware features. This means that an old computer running Linux must run a rather basic desktop, because too many effects or animations might use up precious memory and graphics processing, resulting in sluggish performance.
The [Enlightenment][2] desktop wasn't designed to solve this exact problem, but in practice, that's exactly what it does. With its finely crafted foundation and custom libraries, Enlightenment provides an attractive and dynamic environment that runs smoothly on old computers and low-powered systems like the [Raspberry Pi][3]. You never have to feel like you're compromising your user experience (UX) just because you're running modest hardware. True to its name, it delivers on the promise of eco-friendly computing and is the first line of defense (or second, if Linux itself is the first) against planned obsolescence.
Of course, you don't have to run Enlightenment on an old computer. It works just as well on new computers.
Install Enlightenment from your distribution's software repository. Past versions of Enlightenment are still popular today (and some are still maintained as separate projects), and all of them are good, but the latest versions are the ones above 20. After installing it, log out of your current desktop session so you can log into your new Enlightenment desktop. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your default desktop, so you must override the default when logging in.
Here's how to override the default and switch to Enlightenment on GNOME Desktop Manager:
![Selecting the Enlightenment desktop in GDM][4]
And on KDM:
![Selecting the Enlightenment desktop in KDM][5]
The first time you log into Enlightenment, it asks for some basic preferences, such as your desired language setting, size of window title bars, and so on. It's OK to accept the defaults when you're unsure, and it's safe to ignore the warning about ConnMan not being available. Most distributions use [NetworkManager][6] instead of Enlightenment's own network manager, ConnMan.
### Enlightenment desktop
By default, the Enlightenment desktop provides desktop icons for common places, such as your home directory, the root directory, and a temporary directory. There's also a "shelf," a docking area at the bottom of the screen where major applications can go when minimized, where launchers can be created for quick access to common applications, and where applets (such as volume control, a clock, keyboard layout, and so on) run.
Anything configurable in Enlightenment is configurable with a right-click.
Here's what Enlightenment looks like on Fedora:
![Enlightenment running on Fedora][7]
### Features
To access an application menu, click anywhere on the desktop. Enlightenment is a desktop environment, but it's disguised as a window manager. Its primary task is to help you arrange and manage windows, but it also ships with a file manager (called Fileman) and has options to use a network manager called ConnMan and its own terminal called Terminology. It also has a global settings panel to help manage themes, keyboard shortcuts, screen resolution, and so on.
Because Enlightenment ships with just a few applications, your default application set can stay the same as what you were using before trying Enlightenment. All of your K apps or GNOME applications and third-party applications like Firefox or Blender or LibreOffice will function as usual.
Enlightenment is a smooth, appealing, and modern desktop experience. Settle in and become enlightened!
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/12/linux-enlightenment-desktop
作者:[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
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/light_tunnel_death.jpg?itok=ERLZDTfl (Light at the end of the tunnel)
[2]: https://www.enlightenment.org/
[3]: https://opensource.com/resources/raspberry-pi
[4]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-gdm.jpg (Selecting the Enlightenment desktop in GDM)
[5]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-kdm.jpg (Selecting the Enlightenment desktop in KDM)
[6]: https://en.wikipedia.org/wiki/NetworkManager
[7]: https://opensource.com/sites/default/files/uploads/advent-enlightenment.jpg (Enlightenment running on Fedora)

View File

@ -0,0 +1,220 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 tips for GNU Debugger)
[#]: via: (https://opensource.com/article/19/9/tips-gnu-debugger)
[#]: author: (Tim Waugh https://opensource.com/users/twaugh)
5 个鲜为人知 GNU 调试器GDB技巧
======
> 了解如何使用 gdb 的一些鲜为人知的功能来检查和修复代码。
![Bug tracking magnifying glass on computer screen][1]
[GNU 调试器][2]`gdb`)是一种宝贵的工具,可用于在开发程序时检查正在运行的进程并解决问题。
你可以在特定位置(按函数名称、行号等)设置断点、启用和禁用这些断点、显示和更改变量值,并执行所有调试器希望执行的所有标准操作。但是它还有许多其它你可能没有尝试过的功能。这里有五个你可以尝试一下。
### 条件断点
设置断点是学习使用 GNU 调试器的第一步。程序在达到断点时停止,你可以运行 `gdb` 的命令对其进行检查或更改变量,然后再允许该程序继续运行。
例如,你可能知道一个经常调用的函数有时会崩溃,但仅当它获得某个参数值时才会崩溃。你可以在该函数的开始处设置一个断点并运行程序。每次碰到该断点时都会显示函数参数,并且如果未提供触发崩溃的参数值,则可以继续操作,直到再次调用该函数为止。当这个惹了麻烦的参数触发崩溃时,你可以单步执行代码以查看问题所在。
```
(gdb) break sometimes_crashes
Breakpoint 1 at 0x40110e: file prog.c, line 5.
(gdb) run
[...]
Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5
5 fprintf(stderr,
(gdb) continue
Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5
5 fprintf(stderr,
(gdb) continue
```
为了使此方法更具可重复性,你可以在你感兴趣的特定调用之前计算该函数被调用的次数,并在该断点处设置一个计数器(例如,`continue 30` 以使其在接下来的 29 次到达该断点时忽略它)。
但是断点真正强大的地方在于它们在运行时评估表达式的能力,这使你可以自动化这种测试。
```
break [LOCATION] if CONDITION
(gdb) break sometimes_crashes if !f
Breakpoint 1 at 0x401132: file prog.c, line 5.
(gdb) run
[...]
Breakpoint 1, sometimes_crashes (f=0x0) at prog.c:5
5 fprintf(stderr,
(gdb)
```
条件断点使你不必让 `gdb` 每次调用该函数时都去问你要做什么,而是让条件断点仅在特定表达式的值为 `true` 时才使 `gdb` 停止在该位置。如果执行到达条件断点的位置,但表达式的计算结果为 `false` ,调试器会自动使程序继续运行,而无需询问用户该怎么做。
### 断点命令
GNU 调试器中断点的一个甚至更复杂的功能是能够编写对到达断点的响应的脚本。断点命令使你可以编写一系列 GNU 调试器命令,以在到达该断点时运行。
我们可以使用它来规避在 `sometimes_crashes` 函数中我们已知的错误,并在它提供空指针时使其无害地从该函数返回。
我们可以使用 `silent` 作为第一行,以更好地控制输出。否则,每次命中断点时,即使在运行断点命令之前,也会显示堆栈帧。
```
(gdb) break sometimes_crashes
Breakpoint 1 at 0x401132: file prog.c, line 5.
(gdb) commands 1
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>silent
>if !f
>frame
>printf "Skipping call\n"
>return 0
>continue
>end
>printf "Continuing\n"
>continue
>end
(gdb) run
Starting program: /home/twaugh/Documents/GDB/prog
warning: Loadable section ".note.gnu.property" outside of ELF segments
Continuing
Continuing
Continuing
#0 sometimes_crashes (f=0x0) at prog.c:5
5 fprintf(stderr,
Skipping call
[Inferior 1 (process 9373) exited normally]
(gdb)
```
### 转储二进制内存
GNU 调试器内置支持使用 `x` 命令以各种格式检查内存,包括八进制、十六进制等。但是我喜欢并排看到两种格式:左侧为十六进制字节,右侧为相同字节表示的 ASCII 字符。
当我想逐字节查看文件的内容时,经常使用 `hexdump -C``hexdump` 来自 [util-linux][3] 软件包)。这是 `gdb``x` 命令显示的十六进制字节:
```
(gdb) x/33xb mydata
0x404040 <mydata>: 0x02 0x01 0x00 0x02 0x00 0x00 0x00 0x01
0x404048 <mydata+8>: 0x01 0x47 0x00 0x12 0x61 0x74 0x74 0x72
0x404050 <mydata+16>: 0x69 0x62 0x75 0x74 0x65 0x73 0x2d 0x63
0x404058 <mydata+24>: 0x68 0x61 0x72 0x73 0x65 0x75 0x00 0x05
0x404060 <mydata+32>: 0x00
```
如果你想让 `gdb``hexdump` 一样显示内存怎么办?这是可以的, 实际上,你可以将这种方法用于你喜欢的任何格式。
通过使用 `dump` 命令以将字节存储在文件中,结合 `shell` 命令以在文件上运行 `hexdump` 以及`define` 命令,我们可以创建自己的新的 `hexdump` 命令来使用 `hexdump` 显示内存内容。
```
(gdb) define hexdump
Type commands for definition of "hexdump".
End with a line saying just "end".
>dump binary memory /tmp/dump.bin $arg0 $arg0+$arg1
>shell hexdump -C /tmp/dump.bin
>end
```
这些命令甚至可以放在 `~/.gdbinit` 文件中,以永久定义 `hexdump` 命令。以下是它运行的例子:
```
(gdb) hexdump mydata sizeof(mydata)
00000000 02 01 00 02 00 00 00 01 01 47 00 12 61 74 74 72 |.........G..attr|
00000010 69 62 75 74 65 73 2d 63 68 61 72 73 65 75 00 05 |ibutes-charseu..|
00000020 00 |.|
00000021
```
### 行内反汇编
有时你想更多地了解导致崩溃的原因,而源代码还不够。你想查看在 CPU 指令级别发生了什么。
`disassemble` 命令可让你查看实现函数的 CPU 指令。但是有时输出可能很难跟踪。通常,我想查看与该函数源代码的特定部分相对应的指令。为此,请使用 `/s` 修饰符在反汇编中包括源代码行。
```
(gdb) disassemble/s main
Dump of assembler code for function main:
prog.c:
11 {
0x0000000000401158 <+0>: push %rbp
0x0000000000401159 <+1>: mov %rsp,%rbp
0x000000000040115c <+4>: sub $0x10,%rsp
12 int n = 0;
0x0000000000401160 <+8>: movl $0x0,-0x4(%rbp)
13 sometimes_crashes(&n);
0x0000000000401167 <+15>: lea -0x4(%rbp),%rax
0x000000000040116b <+19>: mov %rax,%rdi
0x000000000040116e <+22>: callq 0x401126 <sometimes_crashes>
[...snipped...]
```
这里,用 `info` 寄存器查看所有 CPU 寄存器的当前值,以及用如 `stepi` 这样命令一次执行一条指令,可以使你对程序有了更详细的了解。
### 反向调试
有时,你希望自己可以逆转时间。想象一下,你已经达到了变量的监视点。监视点像是一个断点,但不是在程序中的某个位置设置,而是在表达式上设置(使用 `watch` 命令)。每当表达式的值更改时,执行就会停止,并且调试器将获得控制权。
想象一下你已经达到了这个监视点,并且由该变量使用的内存已更改了值。事实证明,这可能是由更早发生的事情引起的。例如,内存已释放,现在正在重新使用。但是是何时何地被释放的呢?
GNU 调试器甚至可以解决此问题,因为你可以反向运行程序!
它通过在每个步骤中仔细记录程序的状态来实现此目的,以便可以恢复以前记录的状态,从而产生时间倒流的错觉。
要启用此状态记录,请使用 `target record-full` 命令。然后,你可以使用一些听起来不太可行的命令,例如:
* `reverse-step`,倒退到上一个源代码行
* `*reverse-next`,它倒退到上一个源代码行,向后跳过函数调用
* `reverse-finish`,倒退到当前函数即将被调用的时刻
* `reverse-continue`,它返回到程序中的先前状态,该状态将(现在)触发断点(或其他导致断点停止的状态)
这是运行中的反向调试的示例:
```
(gdb) b main
Breakpoint 1 at 0x401160: file prog.c, line 12.
(gdb) r
Starting program: /home/twaugh/Documents/GDB/prog
[...]
Breakpoint 1, main () at prog.c:12
12 int n = 0;
(gdb) target record-full
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000401154 in sometimes_crashes (f=0x0) at prog.c:7
7 return *f;
(gdb) reverse-finish
Run back to call of #0 0x0000000000401154 in sometimes_crashes (f=0x0)
at prog.c:7
0x0000000000401190 in main () at prog.c:16
16 sometimes_crashes(0);
```
这些只是 GNU 调试器可以做的一些有用的事情。还有更多有待发现。你最喜欢 `gdb` 的哪个隐藏的、鲜为人知或令人吃惊的功能?请在评论中分享。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/9/tips-gnu-debugger
作者:[Tim Waugh][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://opensource.com/users/twaugh
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen)
[2]: https://www.gnu.org/software/gdb/
[3]: https://en.wikipedia.org/wiki/Util-linux

View File

@ -1,85 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Edit images on Fedora easily with GIMP)
[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/)
[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/)
在 Fedora 上使用 GIMP 简单地编辑图像
======
![][1]
GIMP ( GNU Image Manipulation Program 的缩写) 是自由和开源图像处理软件。有很多的功能,从简单地编辑图像,到复杂的滤镜,脚本,甚至是动画,它是一款很好的流行的商业选项的替代品。
继续阅读来学习如何在 Fedora 上安装和使用 GIMP 。这篇文章涉及基本的日常图像编辑。
### 安装 GIMP
GIMP 在官方 Fedora 存储库中可获得。为安装它,运行:
```
sudo dnf install gimp
```
### 单个窗口模式
在你打开应用程序后,它显示带有工具箱和主编辑区的暗色主题窗口。注意,它有两种窗口模式,你可以通过选择 _窗口_ -&gt; _单个窗口模式_ 在其中切换。通过选中这个选项,用户界面的所有组件将显示在单个窗口中。否则,它们将是分开的。
### 加载一个图像
![][2]
为加载一个图像,转到 _文件_ -&gt; _打开_ ,然后选择你的文件并选择你的图像文件。
### 重新调整一个图像的大小
为重新调整图像大小,你有以一对参数为基础的重新调整大小的选项,包括像素和百分比 — 在编辑图像时,这两个参数很方便。
让我们假使我们需要缩小 Fedora 30 背景图像到它当前大小的75%。为此,选择 _图像_ -&gt; _比例_ ,然后在比例对话框上,选择在单位下拉列表中的百分比。接下来,输入 _75_ 作为宽度或高度,然后按 **Tab** 键。默认情况下,为保持纵横比,其它尺寸将自动地与更改的尺寸对应来重新调整大小。现在,保存其它选项不变,并按比例。
![][3]
该图像缩小到其原始尺寸的75%。
### 旋转图像
旋转是一种变换操作,因此,你可以从主菜单下的 _图像_ -&gt; _变换_ 的下面找到它其中有图像旋转90°或180°的选项。在上述选项下也有垂直或水平翻转图像的选项。
让我们假使我们需要旋转图像90°。在应用一次90°顺时针旋转和水平翻转后我们的图像将看起来像这样
![Transforming an image with GIMP][4]
### 添加文本
添加文本非常简单。只需要从工具箱中选择 A 图标,然后,在你的图像上,单击你想要添加文本的位置上一点。如果工具箱不可见,从 窗口-&gt;新建工具箱 打开它。
当你编辑文本时,你可能注意到,文本对话框有字体自定义选项,包括字体系列,字体大小等等。
![Adding text to image in GIMP][5]
### 保存和导出
你可以从 _文件_ -&gt; _保存_ 或通过按 **Ctrl+S** 来保存你的编辑为一个带有 _xcf_ 扩展名的 GIMP 工程。或者,你可以导出你的图像,例如,以 PNG 或 JPEG 格式。为导出,转到 _文件_ -&gt; _导出为_ 或按 **Ctrl+Shift+E** ,接下来,在你面前将产生一个你可以选择输出图像和名称的对话框。
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/
作者:[Mehdi Haghgoo][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/powergame/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg
[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png
[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png
[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png
[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png

View File

@ -0,0 +1,139 @@
[#]: collector: "lujun9972"
[#]: translator: "hello-wn"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: subject: "Top 10 Vim plugins for programming in multiple languages"
[#]: via: "https://opensource.com/article/19/11/vim-plugins"
[#]: author: "Maxim Burgerhout https://opensource.com/users/wzzrd"
多语言编程必备的十大Vim插件
======
使用这 10 个 Vim 插件,可以让你在写代码或运维时,感觉更棒。
![OpenStack source code \(Python\) in VIM][1]
我使用 [Vim][2] 文本编辑器大约20年了。有一段时间我一直在定制我的Vim配置但在过去几年我会使用插件。
最近,当我重新安装 Vim 时(就像我经常做的那样),我决定把这次安装作为一次尝试,找到多种编程语言环境下的最佳 Vim 插件,以及如何将这些插件和每种语言结合起来。
有时,我会为特定的语言和配置使用特定的插件(例如,我只在 Ansible 配置中安装 Rocannon ),在此不细讲了。但是下面介绍的 10 个 Vim 插件是我的最爱,无论使用哪种编程语言,我几乎都会使用它们。
### 1\. Volt
我的首选并不是一个插件, 但是它可以替换类似于 [Vundle][3] 的插件,所以在此介绍。
[Volt][4] 是一个不依存于 Vim 的 Vim 插件管理器。 你可以用它安装插件,通过 `profiles` 组合使用不同的插件。你可以使用一个简单的命令 ```volt profile set myprofile``` 使得新 `profiles` 生效。 这样可以 因制宜地使用插件,比如,我在 Python 配置中单独使用 [indentpython][5] 插件。 Volt 还可以更方便地配置每个插件,这些配置会在 `profiles` 之间共享,因此只需要安装一次插件,就可以在多个 `profiles` 之间使用。
Volt 还是相对较新且不完美的(比如,无论使用多少 `profiles` ,每个插件只能有一个配置文件),但除此之外,我发现它非常方便、快速和简单。
![Volt plugin][6]
### 2\. Vim-Rainbow
除了 Python几乎所有的主流编程语言都使用括号 小括号,方括号和大括号)。 通常,它们会嵌套使用多对括号,因此很难搞清楚某个括号的开闭区间。我发现自己经常要数小括号,尤其是在复杂的 Bash 脚本中,以确保无误。
这时候就需要 [vim-rainbow][7] 插件! 它为每对括号设置不同的颜色,因此很容易识别出哪些括号是一对括号。 它非常有用而且五彩斑斓。
![vim-rainbow plugin][8]
### 3\. lightline
Vim 有很多插件,例如 [Powerline][9] ,它会在底部栏显示你正在处理的文件,光标所在的文件位置以及文件类型等信息。 这些插件各有利弊,在简单比较后,我选择了 [lightline][10]。 它相对较小,便于安装和扩展,并且不依赖于其他工具或插件。
![Lightline plugin][11]
### 4\. NERDTree
[NERDTree][12] 是一个很经典的插件。在大型项目中,你可能很难找到想要编辑的内容所在文件的确切名称和路径。使用快捷键(我使用的是 **F7** ,因为我在 `.vimrc` 中配置了这个快捷键),搜索窗会以垂直分屏的方式打开,就可以轻松找到所需文件并打开它。 对于大型项目,这是必备插件。 对于那些经常忘记文件名的人也很有用,比如我。
![NERDTree vim plugin][13]
### 5\. NERD Commenter
程序员们在写代码时,有时会遇到一些难以调试的问题,导致他们想要注释或不执行某段代码。 这时候就需要 [NERD Commenter][14] 出场了。选择代码段,按 **Leader键 + cc**,代码就会被注释掉。 (标准的 Vim Leader 键 是 **/** 字符。)按 **Leader键 + cn**,取消注释。 对于大多数文件类型NERD Commenter 会自动使用正确的注释符。 例如,如果你正在编辑 [BIND区域文件][15]并将文件类型设置为绑定区域Vim 会正确地使用 **;** (分号)字符进行注释。
![NERD Commenter][16]
### 6\. Solarized
我喜欢我的 Vim 主题配色。我也喜欢终端的主题色。我一直在 Vim 上使用 [Solarized][17] 配色,并且将我的终端、文件夹配色和 Vim 设为一致。
但是,有时我会根据周边环境,屏幕亮度以及是否需要分享投屏,切换明暗模式。
显然,你可以选择自己喜欢的任何配色方案,但我喜欢 `Solarized`,因为它有明暗模式功能,他可以简单快捷地切换两种模式。我的第二个选择是 [Monokai][18]。 Volt 插件管理器让我可以轻松地在两者之间切换因此我在Python编程时使用 Monokai Bash 编程时,使用 Solarized。
我没有给 Solarized 找相应的图片,因为本文中的所有其他图片都使用了 Solarized 中的浅色或深色效果,可以确认一下这些图片。
### 7\. fzf
当寻找一个文件时,有时你想要一个文件浏览器,有时你只想在键盘上敲打出与文件名类似的内容,对吗?
[fzf][19](全称 “模糊查找器”)插件提供了这一功能。打出 **:FZF** 并输入文件名内容。 不断缩短的列表将显示出与你输入的文件名内容相匹配的一些文件。我经常使用它,最近使用它的频率估计比使用 NERDTree 还多。缺点是这个插件依赖于 `fzf binary` ,因此也必须安装这个依赖包。它适用于 FedoraDebian 和 Arch据我所知并不适用于 EPEL。
![fzf Vim plugin][20]
### 8\. ack
有时,你需要搜索包含特定行或特定单词的文件。我真的很喜欢使用 [ack][21] 插件,最好与 **ag** 结合使用,他俩的组合又被称为 “[silver searcher][22]”。 这一组合的速度非常快,覆盖了 **grep****vimgrep** 的绝大多数使用场景。 缺点是您需要安装 ack 或 ag 才能正常运行。 好消息是 Fedora 和 EPEL7 都可以使用 ag 和 ack 。
![ack vim plugin][23]
### 9\. gitgutter
大多数 IT 人员都使用 [Git][24] 和 Git 仓库中的文件进行工作。[gitgutter][25] 插件在行号附近添加了一列,通过符号显示该行的状态为,已更改(**~**),已添加(**+**)或者已删除(**-**)。这有利于跟踪你所做的更改,并且可以使你专注于手头的任务,例如编写补丁来修复一个关键 bug。
![gitgutter vim plugin][26]
### 10\. Tag List
如果你在一个很大的文件中编写代码,会很容易忘记当前所在的位置,你可能需要上下滚动来查找某个功能。使用 [Tag List][27] 插件,只需要输入 **:Tlist** ,就能垂直分屏显示出 包含变量、类型、类和函数的代码,你可以轻松跳转到这些变量、类型、类和函数。这个功能对于多语言同样适用,例如 Java 、Python 以及任何能够使用 **ctags** 功能的文件类型。
![Tag List vim plugin][28]
以上介绍的 10 个 Vim 插件使我作为系统管理员和兼职程序员的生活变得更轻松。你正在使用哪些Vim插件请在评论中分享你最爱的插件。
Vim 为写作者提供了很多便利,无论他们是否了解技术。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/11/vim-plugins
作者:[Maxim Burgerhout][a]
选题:[lujun9972][b]
译者:[hello-wn][c]
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/wzzrd
[b]: https://github.com/lujun9972
[c]: https://github.com/hello-wn
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm "OpenStack source code (Python) in VIM"
[2]: https://www.vim.org/
[3]: https://github.com/VundleVim/Vundle.vim
[4]: https://github.com/vim-volt/volt
[5]: https://github.com/vim-scripts/indentpython.vim
[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif "Volt plugin"
[7]: http://github.com/frazrepo/vim-rainbow
[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png "vim-rainbow plugin"
[9]: https://github.com/powerline/powerline
[10]: http://github.com/itchyny/lightline.vim
[11]: https://opensource.com/sites/default/files/uploads/lightline.png "Lightline plugin"
[12]: http://github.com/scrooloose/nerdtree
[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif "NERDTree vim plugin"
[14]: http://github.com/scrooloose/nerdcommenter
[15]: https://en.wikipedia.org/wiki/Zone_file#File_format
[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif "NERD Commenter"
[17]: https://github.com/altercation/vim-colors-solarized
[18]: https://github.com/sickill/vim-monokai
[19]: https://github.com/junegunn/fzf.vim
[20]: https://opensource.com/sites/default/files/uploads/fzf.gif "fzf Vim plugin"
[21]: https://github.com/mileszs/ack.vim
[22]: https://github.com/ggreer/the_silver_searcher
[23]: https://opensource.com/sites/default/files/uploads/ack.gif "ack vim plugin"
[24]: https://opensource.com/resources/what-is-git
[25]: https://github.com/airblade/vim-gitgutter
[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png "gitgutter vim plugin"
[27]: https://github.com/vim-scripts/taglist.vim
[28]: https://opensource.com/sites/default/files/uploads/taglist.gif "Tag List vim plugin) ) ) "

View File

@ -1,210 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8)
[#]: via: (https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
如何在 CentOS 8/RHEL 8 上安装 Ansible自动化工具
======
**Ansible** 是给 Linux 系统管理员使用的出色自动化工具。它是一种开源配置工具,能让系统管理员可以从一个中心节点(即 **Ansible 服务器**)管理数百台服务器。将 Ansible 与 **Puppet**、**Chef** 和 **Salt**等类似工具进行比较时,它是首选的配置工具,因为它不需要任何代理,并且可以工作在 SSH 和 python 上。
[![Install-Ansible-CentOS8-RHEL8][1]][2]
在本教程中,我们将学习如何在 CentOS 8 和 RHEL 8 系统上安装和使用 Ansble
Ansible 实验环境信息:
* Minimal CentOS 8 / RHEL 8 服务器192.168.1.10),且有互联网连接
* 两个 Ansible 节点 - Ubuntu 18.04 LTS 192.168.1.20 和 CentOS 7 192.168.1.30
### CentOS 8 上的 Ansible 安装步骤
Ansible 包不在 CentOS 8 默认的软件包仓库中。因此,我们需要执行以下命令启用 [EPEL 仓库][3]
```
[root@linuxtechi ~]$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
```
启用 epel 仓库后,执行以下 dnf 命令安装 Ansble。
```
[root@linuxtechi ~]$ sudo dnf install ansible
```
上面命令的输出:
![dnf-install-ansible-centos8][1]
成功安装 ansible 后,运行以下命令验证它的版本。
```
[root@linuxtechi ~]$ sudo ansible --version
```
![Ansible-version-CentOS8][1]
上面的输出确认在 CentOS 8 上安装完成。
让我们看下 RHEL 8 系统。
### RHEL 8 上的 Ansible 安装步骤
如果你有有效的 RHEL 8 订阅,请使用以下订阅管理器命令启用 Ansble 仓库,
```
[root@linuxtechi ~]$ sudo subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms
```
启用仓库后,执行以下 dnf 命令安装 Ansible
```
[root@linuxtechi ~]$ sudo dnf install ansible -y
```
安装 ansible 及其依赖包后,执行以下命令来验证它的版本,
```
[root@linuxtechi ~]$ sudo ansible --version
```
### 在 CentOS 8 / RHEL 8 上通过 pip3 安装 Ansible 的可选方法
如果你希望使用 **pip**python 的包管理器)安装 Ansible请首先使用以下命令安装 pyhton3 和 python3-pip 包,
```
[root@linuxtechi ~]$ sudo dnf install python3 python3-pip -y
```
安装 python3 后,运行以下命令来验证它的版本。
```
[root@linuxtechi ~]$ python3 -V
Python 3.6.8
[root@linuxtechi ~]$
```
命令下面的 pip3 命令安装 Ansible
```
[root@linuxtechi ~]$ pip3 install ansible --user
```
输出,
![Ansible-Install-pip3-centos8][1]
上面的输出确认 Ansible 已成功使用 pip3 安装。让我们看下如何使用 Ansible。
### 如何使用 Ansible 自动化工具?
当我们使用 yum 或 dnf 命令安装 Ansible 时,它的配置文件、清单文件和角色目录会自动在 /etc/ansible 文件夹下创建。
让我们添加一个名称为 “**labservers**” 的组,并在 **/etc/ansible/hosts** 文件中给该组添加 Ubuntu 18.04 和 CentOS 7 的系统 IP 地址。
```
[root@linuxtechi ~]$ sudo vi /etc/ansible/hosts
[labservers]
192.168.1.20
192.168.1.30
```
保存并退出文件。
更新清单文件(/etc/ansible/hosts将用户的 ssh 公钥与作为 “labservers” 组一部分的远程系统交换。
让我们首先使用 ssh-keygen 命令生成本地用户的公钥和私钥,
```
[root@linuxtechi ~]$ ssh-keygen
```
现在使用以下命令在 ansible 服务器及其客户端之间交换公钥,
```
[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi
[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi
```
现在,让我们尝试几个 Ansible 命令,首先使用 ping 模块验证 Ansible 服务器与客户端的连接,
```
[root@linuxtechi ~]$ ansible -m ping "labservers"
```
**注意:** 如果我们没有在上面的命令中指定清单文件,那么它将引用默认主机文件(即 /etc/ansible/hosts
输出:
![ansible-ping-module-centos8][1]
让我们使用 Ansible shell 命令检查每个客户端的内核版本,
```
[root@linuxtechi ~]$ ansible -m command -a "uname -r" "labservers"
192.168.1.30 | CHANGED | rc=0 >>
4.15.0-20-generic
192.168.1.20 | CHANGED | rc=0 >>
3.10.0-327.el7.x86_64
[root@linuxtechi ~]$
```
使用以下命令列出清单文件中的所有主机,
```
[root@linuxtechi ~]$ ansible all -i /etc/ansible/hosts --list-hosts
hosts (4):
192.168.100.1
192.168.100.10
192.168.1.20
192.168.1.30
[root@linuxtechi ~]$
```
使用以下 ansible 命令仅列出 “labservers” 组中的主机。
```
root@linuxtechi ~]$ ansible labservers -i /etc/ansible/hosts --list-hosts
hosts (2):
192.168.1.20
192.168.1.30
[root@linuxtechi ~]$
```
本文就是这些了,我们成功演示了如何在 CentOS 8 和 RHEL 8 系统中安装和使用 Ansible。请分享你的反馈和意见。
* [Facebook][4]
* [Twitter][5]
* [LinkedIn][6]
* [Reddit][7]
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/
作者:[Pradeep Kumar][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.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Ansible-CentOS8-RHEL8.png
[3]: http://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/
[4]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&t=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208
[5]: http://twitter.com/share?text=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&via=Linuxtechi
[6]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&title=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208
[7]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&title=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208

View File

@ -0,0 +1,275 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal)
[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
5 个用于在 Linux 终端中查找域 IP 地址的命令
======
本教程介绍了如何在 Linux 终端验证域名或计算机名的 IP 地址。
本教程将允许你一次检查多个域。
你可能已经使用过这些命令来验证信息。
但是,我们将教你如何有效使用这些命令在 Linux 终端中识别多个域的 IP 地址信息。
可以使用以下5个命令来完成此操作。
* **dig 命令:** dig 是用于查询 DNS名称服务器的灵活命令行工具。
  * **host 命令:** host 是用于执行 DNS 查询的简单程序。
  * **nslookup 命令:** nslookup 命令用于查询互联网域名服务器。
  * **fping 命令:** fping 命令用于将 ICMP ECHO_REQUEST 数据包发送到网络主机。
  * **ping 命令:** ping 命令用于向网络主机发送 ICMP ECHO_REQUEST 数据包。
为了测试,我们创建了一个名为 “domains-list.txt” 的文件,并添加了以下域。
```
# vi /opt/scripts/domains-list.txt
2daygeek.com
magesh.co.in
linuxtechnews.com
```
### 方法 1如何使用 dig 命令查找域的 IP 地址
**[dig 命令][1]**代表 “domain information groper”它是一个功能强大且灵活的命令行工具用于查询 DNS 名称服务器。
它执行 DNS 查询,并显示来自查询的名称服务器的返回信息。
大多数 DNS 管理员使用 dig 命令来解决 DNS 问题,因为它灵活、易用且输出清晰。
它还有批处理模式,可以从文件读取搜索请求。
```
# dig 2daygeek.com | awk '{print $1,$5}'
2daygeek.com. 104.27.157.177
2daygeek.com. 104.27.156.177
```
使用以下 bash 脚本查找多个域的 IP 地址。
```
# vi /opt/scripts/dig-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
dig $server +short
done | paste -d " " - - -
```
添加以上脚本后,给 “dig-command.sh” 文件设置可执行权限。
```
# chmod +x /opt/scripts/dig-command.sh
```
最后运行 bash 脚本获得输出。
```
# sh /opt/scripts/dig-command.sh
2daygeek.com - 104.27.156.177 104.27.157.177
magesh.co.in - 104.18.35.52 104.18.34.52
linuxtechnews.com - 104.27.144.3 104.27.145.3
```
如果要在一行中运行上面的脚本,请使用以下脚本。
```
# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - -
```
或者,你可以使用以下 Shell 脚本查找多个域的 IP 地址。
```
# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done
2daygeek.com. 104.27.157.177
2daygeek.com. 104.27.156.177
magesh.co.in. 104.18.34.52
magesh.co.in. 104.18.35.52
linuxtechnews.com. 104.27.144.3
linuxtechnews.com. 104.27.145.3
```
### 方法 2如何使用 host 命令查找域的 IP 地址
**[host 命令][2]**是一个简单的命令行程序,用于执行 **[DNS 查询][3]**。
它通常用于将名称转换为 IP 地址,反之亦然。
如果未提供任何参数或选项host 将打印它的命令行参数和选项摘要。
你可以在 host 命令中添加特定选项或记录类型来查看域中的所有记录类型。
```
# host 2daygeek.com | grep "has address" | sed 's/has address/-/g'
2daygeek.com - 104.27.157.177
2daygeek.com - 104.27.156.177
```
使用以下 bash 脚本查找多个域的 IP 地址。
```
# vi /opt/scripts/host-command.sh
for server in `cat /opt/scripts/domains-list.txt`
do host $server | grep "has address" | sed 's/has address/-/g'
done
```
添加以上脚本后,给 “host-command.sh” 文件设置可执行权限。
```
# chmod +x /opt/scripts/host-command.sh
```
最后运行 bash 脚本获得输出。
```
# sh /opt/scripts/host-command.sh
2daygeek.com - 104.27.156.177
2daygeek.com - 104.27.157.177
magesh.co.in - 104.18.35.52
magesh.co.in - 104.18.34.52
linuxtechnews.com - 104.27.144.3
linuxtechnews.com - 104.27.145.3
```
### 方法 3如何使用 nslookup 命令查找域的 IP 地址
**[nslookup 命令][4]**是用于查询互联网**[域名服务器DNS] [5]**的程序。
nslookup 有两种模式,分别是交互式和非交互式。
交互模式允许用户查询名称服务器以获取有关各种主机和域的信息,或打印域中的主机列表。
非交互模式用于仅打印主机或域的名称和请求的信息。
它是一个网络管理工具,可以帮助诊断和解决 DNS 相关问题。
```
# nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1
104.27.157.177
104.27.156.177
```
使用以下 bash 脚本查找多个域的 IP 地址。
```
# vi /opt/scripts/nslookup-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - -
```
添加以上脚本后,给 “nslookup-command.sh” 文件设置可执行权限。
```
# chmod +x /opt/scripts/nslookup-command.sh
```
最后运行 bash 脚本获得输出。
```
# sh /opt/scripts/nslookup-command.sh
2daygeek.com - 104.27.156.177 104.27.157.177
magesh.co.in - 104.18.35.52 104.18.34.52
linuxtechnews.com - 104.27.144.3 104.27.145.3
```
### 方法 4如何使用 fping 命令查找域的 IP 地址
**[fping 命令][6]**是类似 ping 之类的程序它使用互联网控制消息协议ICMPecho 请求来确定目标主机是否响应。
fping 与 ping 不同,因为它允许用户并行 ping 任意数量的主机。另外,它可以从文本文件输入主机。
fping 发送 ICMP echo 请求,并以循环方式移到下一个目标,并且不等到目标主机做出响应。
如果目标主机答复,那么将其标记为活动主机并从要检查的目标列表中删除;如果目标在特定时间限制和/或重试限制内未响应,那么将其指定为不可访问。
```
# fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com
104.27.157.177 (104.27.157.177) is alive
104.18.35.52 (104.18.35.52) is alive
104.27.144.3 (104.27.144.3) is alive
```
### 方法 5如何使用 ping 命令查找域的 IP 地址
**[pingPacket Internet Groper命令][6]**是一个网络程序,用于测试 Internet 协议IP网络上主机的可用性/连接性。
通过向目标主机发送互联网控制消息协议ICMPEcho 请求数据包并等待 ICMP Echo 应答来验证主机的可用性。
它基于发送的数据包、接收的数据包、丢失的数据包,通常包含最小/平均/最大时间来汇总统计结果。
```
# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g'
104.27.157.177
```
使用以下 bash 脚本查找多个域的 IP 地址。
```
# vi /opt/scripts/ping-command.sh
#!/bin/bash
for server in `cat /opt/scripts/domains-list.txt`
do echo $server "-"
ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g'
done | paste -d " " - -
```
添加以上脚本后,给 “ping-command.sh” 文件设置可执行权限。
```
# chmod +x /opt/scripts/ping-command.sh
```
最后运行 bash 脚本获得输出。
```
# sh /opt/scripts/ping-command.sh
2daygeek.com - 104.27.156.177
magesh.co.in - 104.18.35.52
linuxtechnews.com - 104.27.144.3
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/
作者:[Magesh Maruthamuthu][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.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/
[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/
[3]: https://www.2daygeek.com/category/dns-lookup/
[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/
[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/
[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/