建立目錄:
mkdir directory
mkdir [-m] [-p] 目錄
-m 指定屬性,也可以事後用chmod命令修改屬性
-p 指定目錄,預設是在目前的目錄想建立新的目錄
rm 刪除檔案或目錄( 可以使用Regex )
用法:rm [選項]... 檔案... -f, --force強制移除。忽略不存在的檔案,不提示確認 -i在刪除前需要確認 -I在刪除超過三個檔案或者遞迴刪除前要求確認。此選項比-i 提示內容更少,但同樣可以阻止大多數錯誤發生 -r, -R, --recursive遞迴刪除目錄及其內容 //刪除目錄時需要 -v, --verbose詳細顯示進行的步驟
如:
刪除目前的目錄所有檔案,強制移除,不提示
rm -f *.*
刪除剛才建立的目錄
rm -rf code
mv 移動檔案或目錄
如子目錄下將父目錄的兄弟目錄移到目前的目錄:
mv ../instruction .
mv 還可以用來重新命名檔案或目錄
mv gzip.txt tar.txt
cp 複製
cp - copy files and directories
SYNOPSIS
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
-a, --archive
same as -dR --preserve=all
--backup[=CONTROL]
make a backup of each existing destination file
-b like --backup but does not accept an argument
--copy-contents
copy contents of special files when recursive
-d same as --no-dereference --preserve=links
-f, --force
if an existing destination file cannot be opened, remove it and try again (redundant if the -n option is used)
-i, --interactive
prompt before overwrite (overrides a previous -n option)
-l, --link
link files instead of copying
-L, --dereference
always follow symbolic links in SOURCE
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)
-P, --no-dereference
never follow symbolic links in SOURCE
常用:
-a :相當於-pdr的意思
-i :提示
-f :強制複製(替換)
-r :遞迴複製,適用於目錄