最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux shell下30個有趣的命令和提示(推薦)

 更新時間:2017年10月08日 08:44:03   作者:盡信書不如無書  
這些是我收集了多年的Linux shell的30個有趣的命令和提示。特此分享到腳本之家平臺,供大家參考

這些是我收集了多年的Linux shell的30個有趣的命令和提示。

1. 監(jiān)控命令(每2秒運行一次)

watch "ls -larth"

2. 使用一個端口殺死程序

sudo fuser -k 8000/tcp

3. 限制以下命令的內(nèi)存使用

ulimit -Sv 1000    # 1000 KBs = 1 MB
ulimit -Sv unlimited # Remove limit

4. 使用正則表達式重命名所選文件

rename 's/\.bak$/.txt/' *.bak

5. 獲得完整的文件路徑

readlink -f file.txt

6. 列出tar.gz文件的內(nèi)容,并只提取一個文件

tar tf file.tgz
tar xf file.tgz filename

7. 按照文件大小列出文件

ls -lS

8. 跟蹤路由

mtr google.com

9. 查找文件的提示

find . -size 20c       # By file size (20 bytes)
find . -name "*.gz" -delete # Delete files
find . -exec echo {} \;   # One file by line
./file1
./file2
./file3
find . -exec echo {} \+   # All in the same line
./file1 ./file2 ./file3

10. 打印無限循環(huán)的文本

yes
yes hello

11. 當前登錄用戶

w

12. 輸出結果前置行號

ls | nl

13. Grep使用Perl風格的語法(允許像\t這樣的字符)

grep -P "\t"

14. Cat命令反向輸出(從末端開始)

tac file

15. 檢查每個目錄中的文件的的權限

檢測權限錯誤是很有用的,例如在配置web服務器時。

namei -l /path/to/file.txt

16. 每次修改文件時都會執(zhí)行命令

while inotifywait -e close_write document.tex
do
  make
done

17. 復制到剪貼板

cat file.txt | xclip -selection clipboard

18. Latex的拼寫和語法檢查

detex file.tex | diction -bs

你可能需要安裝以下內(nèi)容:sudo apt-get install diction texlive-extra-utils。

19. 檢查資源的使用情況

/usr/bin/time -v ls

20. 文件的隨機行

cat file.txt | sort -R
cat file.txt | sort -R | head # Pick a random sambple
# Even better (suggested by xearl in Hacker news):
shuf file.txt

21. 在離開SSH會話后保持程序運行

如果程序不需要任何交互:

nohup ./script.sh &

如果你需要手動輸入一些內(nèi)容,然后離開:

./script.sh
<Type any input you want>
<Ctrl-Z>     # send process to sleep
jobs -l      # find out the job id
disown -h jobid  # disown job
bg        # continue running in the background

當然,也可以使用screen或tmux來完成此目的。

22. 在有限的時間內(nèi)運行命令

timeout 10s ./script.sh
# Restart every 30 minutes
while true; do timeout 30m ./script.sh; done

23. 從兩個排序文件中合并行

comm file1 file2

打印這三列:

1.行file1獨有。
2.行file2獨有。
3.在行file1和行file2中都有。

使用選項-1、-2、-3,可以刪除這些列。

24. 在文件中分割長文件,使用相同數(shù)量的行

split -l LINES -d file.txt output_prefix

25. 刷新交換分區(qū)

如果一個程序消耗了太多的內(nèi)存,交換分區(qū)就會被剩余的內(nèi)存填滿,當你回到正常的時候,一切都是緩慢的。只需重新啟動交換分區(qū)來修復它:

sudo swapoff -a
sudo swapon -a

26. 修復ext4文件系統(tǒng)的superblock問題

sudo fsck.ext4 -f -y /dev/sda1
sudo fsck.ext4 -v /dev/sda1
sudo mke2fs -n /dev/sda1
sudo e2fsck -n <first block number of previous list> /dev/sda1

27. 創(chuàng)建給定大小的空文件

fallocate -l 1G test.img

28. 從命令行操作PDF文件

與join,shuffle,select等命令相比,pdftk是個更好用的命令:

pdftk *.pdf cat output all.pdf    # Join PDFs together
pdftk A=in.pdf cat A5 output out.pdf # Extract page from PDF

還可以使用cpdf操作內(nèi)容:

cpdf -draft in.pdf -o out.pdf   # Remove images
cpdf -blacktext in.pdf -o out.pdf # Convert all text to black color

29. 根據(jù)生成的輸出監(jiān)視進度

# Write random data, encode it in base64 and monitor how fast it
# is being sent to /dev/null
cat /dev/urandom | base64 | pv -lbri2 > /dev/null
# pv options:
#  -l, lines
#  -b, total counter
#  -r, show rate

30. 在Ubuntu中找到一個文件的包

apt-file update
apt-file search dir/file.h

總結

以上所述是小編給大家介紹的Linux shell下30個有趣的命令和提示,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

相關文章

最新評論

松江区| 宁安市| 夏河县| 凤城市| 芦溪县| 自治县| 麻栗坡县| 双桥区| 大安市| 黑龙江省| 宁波市| 合阳县| 石首市| 兴城市| 壤塘县| 静安区| 扶风县| 崇义县| 肥乡县| 垦利县| 隆子县| 张北县| 湖州市| 荣昌县| 马边| 乐陵市| 龙江县| 崇州市| 固原市| 南皮县| 舒城县| 句容市| 三门县| 启东市| 襄汾县| 宁津县| 咸丰县| 铜梁县| 诸城市| 新巴尔虎右旗| 元谋县|