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

Unix/Linux 基礎指令完全手冊:登入、目錄、檔案操作篇

編輯:Linux 教學

帳號管理

登入與登出

Login: username
Password: ******
$ logout   # 或 exit, Ctrl+D

修改密碼

$ passwd
Old Password: ******
New Password: ******
Retype New Password: ******

目錄操作指令

指令功能常用範例
pwd顯示目前工作目錄完整路徑pwd
mkdir建立目錄mkdir -p dir/subdir
cd切換目錄cd .. (上層)、cd / (根目錄)、cd (家目錄)
rmdir刪除空目錄rmdir dir

檔案操作指令

列出檔案 ls

ls -la        # 詳細資訊含隱藏檔
ls -lt        # 依時間排序
ls -lh        # 人類可讀取大小
ls -R         # 遞迴列出子目錄

檢視檔案內容

指令特色適用場景
cat一次顯示全部小檔案、配合管線
more分頁向下,空白鍵翻頁中型檔案
less雙向捲動、搜尋、不載入全部大檔案、日誌分析
head顯示前幾行 (預設 10)快速查看檔案開頭
tail顯示後幾行,-f 即時追蹤監控日誌檔
view唯讀模式開啟防止誤修改
pg分頁顯示,支援向前搜尋System V 風格

檔案搜尋與處理

grep "pattern" file      # 字串搜尋
grep -r "pattern" dir    # 遞迴搜尋目錄
find /path -name "*.log" # 檔名搜尋
find /path -mtime -7     # 7天內修改過的檔案

實用技巧

  • Ctrl+S 暫停輸出,Ctrl+Q 繼續
  • Tab 自動完成指令與路徑
  • !! 重複執行上一條指令
  • !$ 取得上一條指令的最後一個參數
  • 善用管線 | 與重導向 >, >> 組合指令

權限與擁有者

chmod 755 file      # 數字模式
chmod u+x file      # 符號模式
chown user:group file
chgrp group file

掌握這些基礎指令,是 Unix/Linux 系統操作的入門關鍵,建議多實作練習形成肌肉記憶。

Copyright © Windows教程網 All Rights Reserved