自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

十個(gè)鮮為人知的 Linux 命令 - Part 3

系統(tǒng) Linux
我們繼續(xù)“10個(gè)鮮為人知Linux命令系列”的第三部分?;蛟S你已經(jīng)知道了這些命令,那你無疑是一個(gè)有經(jīng)驗(yàn)而喜歡探索的Linux用戶。

我們繼續(xù)“10個(gè)鮮為人知Linux命令系列”的第三部分?;蛟S你已經(jīng)知道了這些命令,那你無疑是一個(gè)有經(jīng)驗(yàn)而喜歡探索的Linux用戶。


22. ^foo^bar 命令

在一個(gè)實(shí)例中運(yùn)行修改后的最后一個(gè)命令。假設(shè)我需要運(yùn)行一個(gè)命令'ls -l'來詳細(xì)列出‘Desktop’目錄下的內(nèi)容。意外地,你打了'lls -l'。所以你需要重新打整個(gè)命令或者使用導(dǎo)航鍵編輯前面的命令。當(dāng)你的命令很長(zhǎng)時(shí)這個(gè)很痛苦。

  1. avi@localhost:~/Desktop$ lls -l  
  2. bash: lls: command not found 
  3.  
  4. avi@localhost:~/Desktop$ ^lls^ls  
  5.  
  6. ls -l  
  7. total 7489440  
  8.  
  9. drwxr-xr-x 2 avi  avi       36864 Nov 13  2012 101MSDCF  
  10. -rw-r--r-- 1 avi  avi      206833 Nov  5 15:27 1.jpg  
  11. -rw-r--r-- 1 avi  avi      158951 Nov  5 15:27 2.jpg  
  12. -rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc 

注意:在上面的替換中我們使用“typo(被替換的)original_command(原始命令)”。警告!這個(gè)命令可能會(huì)非常危險(xiǎn)!如果你有意或者無意地打錯(cuò)了系統(tǒng)命令或者任何像rm -rf那樣的風(fēng)險(xiǎn)命令的話!


23. > file.txt 命令

這個(gè)命令會(huì)刷新文件的內(nèi)容而不需刪除然后創(chuàng)建相同的文件。當(dāng)我們需要反復(fù)輸出,或者在相同的文件上記錄日志時(shí),這個(gè)命令就非常有用。

我有一個(gè)有很多文字的‘test.txt’文件在我的‘Desktop‘上。

  1. avi@localhost:~/Desktop$ cat test.txt  
  2.  
  3. Linux  
  4. GNU  
  5. Debian  
  6. Fedora  
  7. kali  
  8. ubuntu  
  9. git  
  10. Linus  
  11. Torvalds 
  12.  
  13.  
  14. avi@localhost:~/Desktop$ > test.txt  
  15. avi@localhost:~/Desktop$ cat test.txt 

注意:再說一次,這個(gè)命令可能很危險(xiǎn)!永遠(yuǎn)不要嘗試刷新系統(tǒng)文件或者某篇日志文件的內(nèi)容。如果你這么做了,你可能會(huì)遭遇嚴(yán)重的問題!


24. at 命令

‘at‘命令與cron 命令相似也可用于安排一個(gè)任務(wù)或者在某個(gè)特定時(shí)刻執(zhí)行命令。

  1. avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012 

  1. avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM 

示例輸出

  1. -rw-r--r-- 1 avi  avi      220492 Nov  1 13:49 Screenshot-1.png  
  2. -rw-r--r-- 1 root root        358 Oct 17 10:11 sources.list  
  3. -rw-r--r-- 1 avi  avi  4695982080 Oct 10 20:29 squeeze.iso  
  4. .. 
  5. .. 
  6. -rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc  
  7. -rw-r--r-- 1 avi  avi       96206 Nov  5 12:56 Untitled 1.odt  
  8. -rw-r--r-- 1 avi  avi        9405 Nov 12 23:22 Untitled.png 

注意:echo “ls -l”的意思是,將這串命令(這里是 ls -l)輸出在標(biāo)準(zhǔn)終端上。你可以用你需要或者選擇的命令替代‘ls -l‘。

> :重定向輸出

/dev/pts/0:這是輸出設(shè)備和/或文件,輸出到指定的地方,這里輸出在終端(/dev/pts/0)。

就我而言,此時(shí)我的tty在/dev/pts/0。你可以用tty命令檢查你的tty。

  1. avi@localhost:~/Desktop$ tty  
  2.  
  3. /dev/pts/0 

注意:‘at‘會(huì)在系統(tǒng)時(shí)間匹配到特定時(shí)間時(shí)會(huì)盡快執(zhí)行。


25. du -h –max-depth=1 命令

下面的命令以人類可讀的形式輸出當(dāng)前目錄的子目錄的大小。

  1. avi@localhost:/home/avi/Desktop# du -h --max-depth=1  
  2.  
  3. 38M     ./test  
  4. 1.1G    ./shivji  
  5. 42M     ./drupal  
  6. 6.9G    ./101MSDCF  
  7. 16G . 

注意:上面的命令在檢查系統(tǒng)使用率是非常有用。


26. expr 命令

‘expr‘不是那么鮮為人知的命令。這個(gè)命令在終端中計(jì)算簡(jiǎn)單的算數(shù)時(shí)非常有用。

  1. avi@localhost:/home/avi/Desktop# expr 2 + 3  
  2.  
  3. avi@localhost:/home/avi/Desktop# expr 6 – 3  
  4.  
  5. avi@localhost:/home/avi/Desktop# expr 12 / 3  
  6.  
  7. avi@localhost:/home/avi/Desktop# expr 2 \* 9  
  8. 18 

27. look 命令

在終端上從英文字典上查單詞以防混淆。比如說,我記不清了是該拼成carrier還是carieer。

 

  1. avi@localhost:/home/avi/Documents# look car 
  1. Cara  
  2. Cara's  
  3. … 
  4. ...  
  5. carps  
  6. carpus  
  7. carpus's  
  8. carrel  
  9. carrel's  
  10. carrels  
  11. carriage  
  12. carriage's  
  13. carriages  
  14. carriageway  
  15. carriageway's  
  16. carried  
  17. carrier  
  18. carrier's  
  19. carriers  
  20. carries  
  21. … 
  22. ...  
  23. caryatids 

上面的命令會(huì)顯示字典上所有以'car'開頭的單詞。我得到了我想找的。


28. yes 命令

另外一個(gè)命令在通常基礎(chǔ)上并不會(huì)經(jīng)常使用,但是在腳本語(yǔ)言和系統(tǒng)管理時(shí)非常有用。

這個(gè)命令會(huì)持續(xù)地輸出給定的字符串,直到由你的中斷命令打斷。

  1. avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to"  
  2.  
  3. Tecmint is one of the best site dedicated to Linux, how to  
  4. Tecmint is one of the best site dedicated to Linux, how to  
  5. Tecmint is one of the best site dedicated to Linux, how to  
  6. Tecmint is one of the best site dedicated to Linux, how to  
  7. … 
  8. … 
  9. ... 
  10. Tecmint is one of the best site dedicated to Linux, how to  
  11. Tecmint is one of the best site dedicated to Linux, how to  
  12. Tecmint is one of the best site dedicated to Linux, how to 

29. factor 命令

factor實(shí)際是一個(gè)源于數(shù)學(xué)的命令。這個(gè)命令會(huì)輸出所有給定數(shù)字的因數(shù)。

  1. avi@localhost:~/Desktop$ factor 22  
  2. 22: 2 11 
  3.  
  4. avi@localhost:~/Desktop$ factor 21  
  5. 21: 3 7 
  6.  
  7. avi@localhost:~/Desktop$ factor 11  
  8. 11: 11 

30. ping -i 60 -a IP_address

我們都用ping命令檢測(cè)服務(wù)器是否連通。我通常ping google,來檢測(cè)我是否連接到了因特網(wǎng)。

當(dāng)你等待或者持續(xù)盯著你的終端等待命令的回應(yīng)或者等待服務(wù)器的連接時(shí),有時(shí)是很氣人的。

一旦服務(wù)器連通就有一個(gè)聲音如何(譯注:下面命令是等60秒PING一次)?

  1. avi@localhost:~/Desktop$ ping -i 60 -a www.google.com  
  2.  
  3. PING www.google.com (74.125.200.103) 56(84) bytes of data.  
  4. 64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms  
  5. 64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms 

注意:當(dāng)你發(fā)現(xiàn)命令不會(huì)返回聲音時(shí)。請(qǐng)確保你的系統(tǒng)不是靜音的,聲音已經(jīng)在‘sound preferences(聲音選項(xiàng))‘ 中啟用并確保勾選了‘Enable window and window sound‘。


31. tac 命令

這個(gè)命令很有趣,他會(huì)以倒序輸出文本文件的內(nèi)容。也就是從最后一行到第一行。

在home目錄下,我的Documents目錄下有一個(gè)35.txt文件。用cat 命令檢查內(nèi)容。

  1. avi@localhost:~/Documents$ cat 35.txt 

示例輸出

  1. Linux is built with certain powerful tools, which are unavailable in windows.
  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
  3. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.

現(xiàn)在用tac命令反轉(zhuǎn)文件內(nèi)容(譯注:當(dāng)然,我們知道cat反轉(zhuǎn)過來就是tac)。

  1. <code>avi@localhost:~/Documents$ tac 35.txt </code> 

示例輸出

  1. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.
  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
  3. Linux is built with certain powerful tools, which are unavailable in windows.

 

 


現(xiàn)在結(jié)束了。如果你還知道其他一些Linux鮮為人知的命令,你可以在下面評(píng)論,那么我們你可以在以后的文章中包含進(jìn)來。

不要忘了給我們有價(jià)值的評(píng)論。我很快會(huì)發(fā)另外有趣的文章。別走開繼續(xù)關(guān)注 Tecmint。

via: http://www.tecmint.com/10-lesser-known-commands-for-linux-part-3/

 

責(zé)任編輯:奔跑的冰淇淋 來源: Linux中國(guó)
相關(guān)推薦

2013-12-23 15:25:15

命令Linux命令

2013-11-19 11:59:49

Linux命令Shell腳本

2024-03-04 16:32:02

JavaScript運(yùn)算符

2017-11-08 14:55:16

Linux命令sudo

2014-07-29 14:25:43

Unix命令

2010-12-28 10:12:18

Linux命令

2013-07-15 09:14:00

2010-09-06 14:19:54

CSS

2009-09-14 09:45:20

Chrome谷歌操作系統(tǒng)

2019-10-08 16:24:33

Chrome瀏覽器

2023-04-23 15:11:26

2010-01-07 10:05:51

IT顧問特質(zhì)

2024-01-15 18:02:09

docker系統(tǒng)文件格式

2019-12-12 20:49:05

JavaScript語(yǔ)言運(yùn)算符

2022-07-19 08:46:15

NeofetchLinux

2011-05-03 13:13:52

編程PHPJava

2022-02-14 10:48:31

Python開發(fā)

2014-04-22 16:38:12

GitHubGitHub 使用技巧

2018-12-10 19:30:45

2024-09-10 08:35:57

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)