Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 系統管理員必學五大命令列進階技巧

編輯:Linux 教學

1. 以 less 取代 more

alias more=less

寫入 .bashrc 或 .bash_profile 永久生效。less 支援雙向捲動(Space/f 向下、b 向上),載入僅讀取所需部分,比 more 輕快。cat 姊妹指令 tac 反向顯示檔案,適合看日誌尾部。shuf 亂序輸出,趣味用途。

2. 單一 SSH 會話多視窗:screen / tmux

開多個 SSH 連線浪費資源且難管理。安裝 screen(yum install screen):

  • screen 進入,Ctrl-a c 新增視窗,Ctrl-a p 上一個,Ctrl-a n 下一個,Ctrl-a 0-9 跳轉編號視窗。
  • Ctrl-a d 脫離保留會話,斷線重連後 screen -r 恢復所有視窗。

tmux 功能更強、支援多用戶共享視窗(遠端結對編程)。

3. 秒架 HTTP 伺服器傳檔案

# Ruby (port 3125)
ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 3125, :DocumentRoot => Dir.pwd).start'

# Python (port 8000)
python -m SimpleHTTPServer

當前目錄即成檔案下載站,記得防火牆開埠,勿洩露敏感檔案。

4. pgrep 取代 ps + grep

pgrep -l ruby           # 列出 ruby 進程 PID 與名稱
pgrep -u root           # root 的所有進程
pgrep -lv `whoami`      # 非當前用戶的進程(-v 反向)

比管道 ps -A | grep 更簡潔高效。

5. 命令列拼寫檢查

aspell -c 檔案.txt      # 互動式檢查並修正
look 前綴字             # 查詢以該字串開頭的單詞(如 look vendo)
Copyright © Windows教程網 All Rights Reserved