歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> Linux文件管理命令詳解,linux命令詳解

Linux文件管理命令詳解,linux命令詳解

日期:2017/3/6 9:21:35   编辑:學習Linux

Linux文件管理命令詳解,linux命令詳解


Linux文件管理命令詳解,linux命令詳解


復制和移動文件

cp:copy

cp SRC DEST

cp file1 file2 file3 //file1,file2為源文件,file3為目標

復制一個文件到一個文件

復制多個文件到一個目錄,目錄必須存在

cp /etc/passwd /tmp/ 復制到/tmp/下,文件名為passwd

若目標是一個目錄,且存在,將源文件放在目錄下,並保持原來的名字

cp /etc/passwd /tmp/test

若test不存在,復制到/tmp目錄下,並重命名為test

若test存在,判斷是文件還是目錄

若test是文件,則提示是否覆蓋掉

若test是目錄,放在/tmp/test/目錄下,保持原來的文件名

cp /etc/passwd /etc/issue /etc/inittab /tmp/abc

cp /etc/init.d/ /tmp/ 不能復制目錄

  -r,R: --recursive,遞歸復制

cp -r /etc/init.d/ /tmp/hello(目錄) 復制/etc/init.d/到/tmp/hello目錄下,並重命名為hello

cp -r /etc/init.d/ /tmp/hello(文件)

  -f:force,強制,覆蓋不提示,直接覆蓋

  -i:interactive,交互式

命令別名:

cp is aliased to 'cp -i'

  -p:--preserve,保留,保存,屬性列表

mode,ownership,timestamp,

權限, 屬主,屬組, 時間戳,,保留新復制文件的屬組,屬主

  -a:-dR, --preserve ,archive,存檔,保留源文件所有屬性

    歸檔存放,常用於備份

  -d:-P,保持鏈接自身

  -L:廢棄,總是跟隨符號鏈接,鏈接指向的文件

  -P:保持鏈接自身

符號鏈接:快捷方式,文件並不存在,只是指向另外一個文件的路徑

cp /etc/rc(鏈接)/tmp 復制的是鏈接指向的文件

cp -L /etc/rc(鏈接) /tmp/rc.2(文件)復制的是鏈接指向的文件

cp -P /etc/rc(鏈接) /tmp/rc.3(文件)復制的是鏈接

cp /etc/{passwd,inittab,rc.d/rc.sysinit} /tmp 復制3個文件

mv(mv -i):move

移動文件

mv SRC DEST

mv /tmp/root.inittab /var/tmp 剪切,並保留原來的名稱

mv hello new 路徑一致,hello重命名為new

  -i:interactive,交互式

  -f:強制,強制覆蓋

  -t:mv -t DEST SRC

install

復制文件並指定屬性

install SRC DIR

  -d:DIR,創建目錄

  -m:mode,指定權限

  -o:指定所有者

  -t:install -t DIR SRC

install -d /tmp/{install.1,install.2} 在/tmp下創建兩個目錄,install.1,install.2

install /ect/passwd /var/tmp/install.file1 復制文件,並賦予執行權限

http://xxxxxx/Linuxjc/1152909.html TechArticle

Copyright © Linux教程網 All Rights Reserved