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

cp: omitting directory 錯誤解析:-r 遞歸複製與 -R 遞歸刪除/權限

編輯:Linux 教學

Linux 複製目錄時出現 cp: omitting directory 'bbs',因預設 cp 不處理目錄,需加 -r (或 -R) 遞歸參數。

解決複製錯誤


cp -r bbs ../backup/bbs
  • -r / -R:遞歸複製目錄及其所有子目錄/檔案
  • -a:歸檔模式 = -dR --preserve=all (保留屬性、連結、時間),備份首選

舉一反三:刪除目錄


rm -r bbs
# 或
rm -rf bbs   # -f 強制不提示

舉一反三:遞歸權限變更


chmod -R 755 bbs   # 注意大寫 -R
chown -R user:group bbs
  • chmod 遞歸參數為大寫 -R (cp/rm 兩種大小寫皆可)

常見參數速查

指令遞歸參數備註
cp-r / -R同義
rm-r / -R同義
chmod-R僅大寫
chown-R僅大寫
ls-R遞歸列出
find(預設遞歸)無需參數

遇到 omitting directory,記住加遞歸參數即可。

Copyright © Windows教程網 All Rights Reserved