linux檔案管理相關命令mv mkdir cp rm

來源:互聯網
上載者:User

建立目錄:

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 :遞迴複製,適用於目錄

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.