已翻译 by Luox

This commit is contained in:
Luoxcat 2013-12-27 22:28:15 +08:00
parent 2ca86d067b
commit b26abb1466

View File

@ -1,187 +1,252 @@
翻译中 Luox
十个鲜为人知的Linux命令 - Part 5
10 Lesser Known Useful Linux Commands- Part V
================================================================================
After four highly appreciated and such a successful series of Articles on “**Lesser Known Linux Commands**” we are here presenting you the last article on this series, obviously not the least. The previous articles are:
在以前四篇文章受到高度赞赏之后,我们将为如此成功的系列文章“**鲜为人知的Linux命令**”呈上最后一篇好文,好吧,显然是骗你得了。上几篇文章:
![](http://www.tecmint.com/wp-content/uploads/2013/12/10-Lesser-Known-Useful-Commands-V.png)
- [11 Lesser Known Useful Linux Commands Part I][1]
- [10 Lesser Known Linux Commands Part II][2]
- [10 Lesser Known Commands for Linux Part III][3]
- [10 Lesser Known Effective Linux Commands Part IV][4]
### 42. lsb_release ###
The command lsb_release print distribution-specific information. If **lsb_release** is not installed, you can apt **lsb-core** on Debian or yum **redhat-lsb** on **Red Hat** the package.
lsb_release 命令会打印特殊发行版的信息。如果**lsb_release**还没安装你可以在基于Debain的发行版中用命令apt-get install **lsb-core**安装,或者在基于**Red Hat**系统下用yum install**redhat-lsb**‘来安装包。
# lsb_release -a
LSB Version: :base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:
Distributor ID: CentOS
Description: CentOS release 6.3 (Final)
Release: 6.3
Codename: Final
**Note:** Option **-a**, shows all the available information in respect of **version, id, description, release** and **codename**.
**注意:**选项‘**-a**‘,会显示有关**版本ID详情发行号**和**研发代号**的可用信息。
### 43. nc -zv localhost 80 ###
Check if port **80** is open or not. We can replace **80** with any other port number to check if it is opened or closed.
检查**80**端口是否被打开。我们可以用任何其他端口号替换‘**80**‘来检查端口是否被打开或关闭。
$ nc -zv localhost 80
Connection to localhost 80 port [tcp/http] succeeded!
Connection to localhost 80 port [tcp/http] succeeded![译注出现该信息表示80端口已被打开。]
Check if port **8080** is open or not.
检查**8080**端口是否启用
$ nc -zv localhost 8080
nc: connect to localhost port 8080 (tcp) failed: Connection refused
nc: connect to localhost port 8080 (tcp) failed: Connection refused[译注该信息显示了8080端口并未打开。]
### 44. curl ipinfo.io ###
### 44. curl inpinfo.io ###
The below command will output the **Geographical Location** of the **IP address**, provided.
该命令会输出并提供**IP 地址**的‘**地理位置**‘。
$ curl ipinfo.io
"ip": "xx.xx.xx.xx",
"ip": "xx.xx.xx.xx",
"hostname": "triband-del-aa.bbb.cc.ddd.bol.net.in",
"city": null,
"region": null,
"city": "null",
"region": "null",
"country": "IN",
"loc": "20,77",
"org": "AS17813 Mahanagar Telephone Nigam Ltd."
"org": "AS17813 Mahanagar Telephone Nigam Ltd".
### 45. find . -user root ###
The below command output the files with respect of the user (**root**) owned files. All the files owned by user root in the current directory.
该命令会输出(**root**)用户所拥有的文件,[译注即owner为root]。下面是在当前目录下列出的所有 root用户拥有的文件。
# find . -user root
./.recently-used.xbel
./.mysql_history
./.aptitude
./.aptitude/config
./.aptitude/cache
./.bluefish
./.bluefish/session-2.0
./.bluefish/autosave
./.bash_history
All the files owned by user **avi** in the current directory.
在当前路径下列出所有‘**avi**‘用户拥有的文件
# find . -user avi
./.cache/chromium/Cache/f_002b66
./.cache/chromium/Cache/f_001719
./.cache/chromium/Cache/f_001262
./.cache/chromium/Cache/f_000544
./.cache/chromium/Cache/f_002e40
./.cache/chromium/Cache/f_00119a
./.cache/chromium/Cache/f_0014fc
./.cache/chromium/Cache/f_001b52
./.cache/chromium/Cache/f_00198d
./.cache/chromium/Cache/f_003680
### 46. sudo apt-get build-dep ffmpeg ###
The below command will build the dependency, automatically during the corresponding package installation. Hence the process of package installation is very much fluent and easy.
该命令会在相应的包安装时自动构建依赖关系。因此包安装的过程是非常流畅和容易的。
# apt-get build-dep ffmpeg
libxinerama-dev libxml-namespacesupport-perl libxml-sax-expat-perl
libxml-sax-perl libxml-simple-perl libxrandr-dev libxrender-dev
x11proto-render-dev x11proto-xinerama-dev xulrunner-dev
The following packages will be upgraded:
libpixman-1-0
1 upgraded, 143 newly installed, 0 to remove and 6 not upgraded.
Need to get 205 MB of archives.
After this operation, 448 MB of additional disk space will be used.
Do you want to continue [Y/n]?
### 47. lsof -iTCP:80 -sTCP:LISTEN ###
The below command outputs, name of **process/service** using a specific port **80**. To better understand run the following command on port **80**, it will list all **services/processes** running on port.
该命令会输出所用正在使用**80**端口的**进程/服务**的名称。为了更好的理解,在**80**端口运行下列命令在,它会列出所用运行在该端口的**进程/服务**。
root@localhost:/home/avi# lsof -iTCP:80 -sTCP:LISTEN
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 1566 root 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1664 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1665 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1666 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1667 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1668 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
Same way, you can also check the running services/processes of port **22**.
同样,你可以检查运行在端口**22**的进程/服务。
root@localhost:/home/avi# lsof -iTCP:22 -sTCP:LISTEN
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 2261 root 3u IPv4 8366 0t0 TCP *:ssh (LISTEN)
sshd 2261 root 4u IPv6 8369 0t0 TCP *:ssh (LISTEN)
### 48. find -size +100M ###
The find command lists all the files in the current directory above the specified size (here **100 MB**), recursively.
这条find命令会在当前目录下列出所有超过指定大小的文件(这里指定为**100 MB**),递归查询。
# find -size +100M
./.local/share/Trash/files/linuxmint-15-cinnamon-dvd-32bit.iso
./Downloads/Fedora-Live-Desktop-i686-19-1.iso
./Downloads/Ant Videos/shakira 2.avi
./Downloads/Deewar.avi
./Desktop/101MSDCF/MOV02224.AVI
./Desktop/101MSDCF/MOV02020.AVI
./Desktop/101MSDCF/MOV00406.MP4
./Desktop/squeeze.iso
Listing all the files whose size if more than **1000 MB**, within current directory, recursively.
在当前目录递归的列出所用大于**1000 MB**的文件。
root@localhost:/home/avi# find -size +1000M
./Downloads/The Dark Knight 2008 hindi BRRip 720p/The Dark Knight.mkv.part
./Downloads/Saudagar - (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR]/Saudagar
- (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR].mkv
./Downloads/Deewar.avi
./Desktop/squeeze.iso
### 49. pdftk ###
The **pdftk** command merges several pdf files into one. You must have installed **pdftk** program. If not, do apt or yum to get the required package.
**pdftk**命令用来合并几个pdf文件。你必须安装有**pdftk**程序。如果还没有请用apt或yum来获取相应的包。
$ pdftk 1.pdf 2.pdf 3.pdf …. 10.pdf cat output merged.pdf
### 50. ps -LF -u user_name ###
The below command outputs processes and threads of a user. The option “**L**” (list threads) and “-F” (Full Format Listing).
该命令会输出一个用户的进程和线程。选项“**L**”(列出线程),选项“-F”完整格式化
$ ps -LF -u avi
avi 21645 3717 21766 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 21645 3717 21768 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 22314 3717 22314 0 2 42797 50332 0 19:00 ? 00:00:40 /usr/
avi 22314 3717 22316 0 2 42797 50332 1 19:00 ? 00:00:00 /usr/
avi 22678 24621 22678 0 1 969 1060 1 21:05 pts/1 00:00:00 ps -L
avi 23051 3717 23051 0 2 37583 45444 1 19:03 ? 00:00:52 /usr/
avi 23051 3717 23053 0 2 37583 45444 0 19:03 ? 00:00:03 /usr/
avi 23652 1 23652 0 2 22092 12520 0 19:06 ? 00:00:22 gnome
avi 23652 1 23655 0 2 22092 12520 0 19:06 ? 00:00:00 gnome
### 51. Startx — :1 ###
Sharing **X** session, means frequently logging in and out, this is where the **Startx** command comes to rescue. The command creates a new session thus no need to login and logout frequently from a session. In order to switch between the two X session, we need to switch between **ctrl+Alt+F7** and **ctrl+Alt+F8**.
分享**X**会话,意味着需要频繁的登入或登出,这就需要**startx**来救场。这个命令建立了一个新的会话从而避免了在一个会话中反复的登入和登出。为了在X会话间进行交换我们可以通过**ctrl+Alt+F7**‘和‘**ctrl+Alt+F8**‘的组合键。
**Note**: The keys “**ctrl+Alt+F1**“, “**ctrl+Alt+F6**” is for console session, and “**ctrl+Alt+F7**“, “**ctrl+Alt+F12**” is for X session. Hence **6** console session and **6** X session, without frequent logging-in and out. The above sequence works on most of the distro, however different distro may have implemented it differently. I have checked it on Debian, and it works perfectly fine.
**注意**:快捷键“**ctrl+Alt+F1F6**“是为了控制台会话准备的,而“**ctrl+Alt+FF12**“则为X会话服务。因此我们有**6**个控制台会话和**6**个X会话不需要频繁的登入登出。上面的顺序适用于大多数的发行版然而不同发行版可能会有不同的实现。我在Debian中尝试过运行的很好。
Thats all for now. We will be keep coming up with other lesser know commands and one liner script as required, in future articles. Do not forget to give your valueable feedback about our article and series **Lesser Known Linux Commands**. I am coming with my next article very soon, till then, stay healthy, tuned and connected to **Tecmint**.
以上就是今天的所有内容。我们如有需要会在以后的文章中继续发布“鲜为人知的命令”,不要忘记留下你对我们文章和‘**鲜为人知的Linux命令**‘系列的宝贵意见。我会很快带来我的新文章,直到那时,要保持健康,链接到**Tecmint**哦。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/10-lesser-known-useful-linux-commands-part-v/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
译者:[Luoxcat](https://github.com/Luoxcat) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出