Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux 常見錯誤訊息中英對照與排查思路

看懂的錯誤訊息,比十個指令更有用。以下是最常遇到的十種:

1. command not found              找不到命令
2. No such file or directory      沒有這個檔案或目錄
3. Permission denied              權限不足
4. No space left on device        磁碟沒有剩餘空間
5. File exists                    檔案已經存在
6. Is a directory                 這是一個目錄
7. Not a directory                這不是一個目錄
8. Warning: Changing a readonly file   警告:正在修改唯讀檔案
9. Found a swap file by the name ".1.swp"   vim 遇到異常關閉留下的暫存檔
10. unrecognized option '--aaa'   未知參數,請查說明文件

排查思路

command not found:先 which 指令 確認有沒有裝,再 echo $PATH 看是不是路徑沒設。切換身分時忘了 su - 是最常見的成因。

No such file or directory:注意它也可能出現在「檔案存在但直譯器不存在」時,例如執行一個 32 位元程式卻缺 glibc.i686。

Permission denied:ls -l 看權限、namei -l /path/to/file 逐層檢查路徑上每個目錄的 x 位,同時別忘了 SELinux(getenforce、ausearch -m avc -ts recent)。

No space left on device:不一定沒空間了。df -h 看容量、df -i 看 inode 是否用盡,兩者任一為 100% 都會報這個錯。若刪檔後空間沒釋放,多半是有行程還握著已刪除的檔案,用 lsof | grep deleted 找出來重啟該服務。

Is a directory / Not a directory:把檔案與目錄搞混了,通常是路徑多打或少打一層。

Changing a readonly file:vim 中想強制存檔可用 :w !sudo tee %,或直接 :wq!(僅在檔案權限允許時有效)。

Found a swap file:vim 偵測到 .swp 存在,代表上次異常結束。按 D 刪除暫存即可;若該檔案確實正被另一個人編輯,則選 O 以唯讀開啟。

unrecognized option:指令 --help 或 man 指令 查正確參數,別急著猜。

Copyright © Linux教程網 All Rights Reserved