本文中文部分參考:http://www.oschina.net/translate/11-lesser-known-useful-linux-commands
本文英文部分參考:http://www.tecmint.com/11-lesser-known-useful-linux-commands/
1. sudo !!命令
沒有特定輸入sudo命令而運行,將給出沒有權限的錯誤。那麼,你不需要重寫整個命令,僅僅輸入’!!’就可以抓取最後的命令。
sudo !! command
Running the command without specifying sudo command will give you permission denied error. So, you don’t need to rewrite the whole command again just put ‘!!‘ will grab the last command.
$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ sudo !!
sudo apt-get update
[sudo] password for server:
…
..
Fetched 474 kB in 16s (28.0 kB/s)
Reading package lists... Done
server@localhost:~$
2. python命令
下面的命令生產一個通過HTTP顯示文件夾結構樹的簡單網頁,可以通過瀏覽器在端口8000訪問,直到發出中斷信號。
python command
The below command generates a simple web page over HTTP for the directory structure tree and can be accessed at port 8000 in browser till interrupt signal is sent.
python -m SimpleHTTPServer
3.ss命令
“ss”表示socket統計。這個命令調查socket,顯示類似netstat命令的信息。它可以比其他工具顯示更多的TCP和狀態信息。
ss Command
The “ss” stands for socket statistics. The command investigates the socket and shows information similar to netstat command. It can display more TCP and state informations than other tools.
4.last命令
“last”命令顯示的是上次登錄用戶的歷史信息。這個命令通過搜索文件“/var/log/wtmp”,顯示logged-in和logged-out及其tty‘s的用戶列表。
last Command
The “last” command show the history of last logged in users. This command searches through the file “/var/log/wtmp” and shows a list of logged-in and logged-out users along with tty’s.
5.pstree命令
這個命令顯示當前運行的所有進程及其相關的子進程,輸出的是類似‘tree’命令的樹狀格式。
pstree
This commands shows all the processes running currently along with associated child process, in a tree like format similar to ‘tree‘ command output.
6. tree命令
以樹式的格式得到當前文件夾的結構。
tree command
Get the current directory structure in tree like format.
7. nl命令
“nl命令”添加文件的行數。一個叫做’one.txt’的文件,其每行的內容是(Fedora、Debian、Arch、Slack和Suse),給每行添加行號。首先使用cat命令顯示“one.txt”的文件內容。
nl Command
The “nl command” number the lines of a file. Number the lines of a file say ‘one.txt‘ with lines say (Fedora, Debian, Arch, Slack and Suse). First list the content of a file “text.txt” using cat command.