400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

2.3文件管理类命令

4、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。

成都创新互联公司专业为企业提供德兴网站建设、德兴做网站、德兴网站设计、德兴网站制作等企业网站建设、网页设计与制作、德兴企业网站模板建站服务,十余年德兴做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

1cp命令

(1)cp命令的简单认识

[root@CentOS7 data]#whatis cp

cp (1)               - copy files and directories

cp (1p)              - copy files

[root@CentOS7 data]#which cp

alias cp='cp -i'

/usr/bin/cp

[root@CentOS7 data]#whereis cp

cp: /usr/bin/cp /usr/share/man/man1/cp.1.gz /usr/share/man/man1p/cp.1p.gz

[root@CentOS7 data]#type cp

cp is aliased to `cp -i'

(2)选项

-i 覆盖前提示,输入y 回车。直接回车管不管用?

-n 不覆盖,注意文件顺序

-r/R 递归复制目录及内部的全部内容

-a 归档,相当于 -dr --preserv = all

-d --no-dereference --preserv=links 不复制原文件,只复制链接名   如果不加-d  复制的是链接的文件(软链接时)

                --preserv[=ATTR_LIST] (preserve保护、维持)

                mode 权限

                ownership 属主属组

                timestamp 时间戳

                links 复制符号链接本身

                xattr 扩展属性

                context 安全标签

                all

-p 等同 --preserv=mode,ownership,timestamp

-v --verbose    explain what is being done  

-f --force 删除后建立

 if  an  existing  destination  file  cannot  be opened, remove it and try again (this option is ignored when the -n option is also used)

-u --update 只复制源比目标修改时间(Modification Time)更新文件或目标不存在的文件

-b 目标存在,覆盖前先备份,形式为filename~

只能备份上一次文件。如果第二次复制不同的文件为上一次的文件名则还是命名为 name~

--backup=numbered,t 目标存在,覆盖前先备份加数字后缀

经典组合是  cp -av  file/directory  

(3)用法:

cp ~wang/.bashrc bashrc.bak

ll !*

ll ~wang/.bashrc bashrc.bak

-rw-r--r--  1 root root 231 Oct 22 09:17 bashrc.bak

-rw-r--r--. 1 wang wang 231 Aug  8 20:06 /home/wang/.bashrc

##加入-p命令时,属性不变

cp -p ~wang/.bashrc bashrc.bak1

ll !*

ll -p ~wang/.bashrc bashrc.bak1

-rw-r--r--  1 wang wang 231 Aug  8 20:06 bashrc.bak1

-rw-r--r--. 1 wang wang 231 Aug  8 20:06 /home/wang/.bashrc

[root@CentOS7 data]# ll /etc/redhat-release

lrwxrwxrwx. 1 root root 14 Oct 14 08:52 /etc/redhat-release -> centos-release

[root@CentOS7 data]# ll redhat

-rw-r--r-- 1 root root 37 Oct 22 13:18 redhat

[root@CentOS7 data]# cp /boot/grub2 /data/gb.bak

cp: omitting directory ‘/boot/grub2’

[root@CentOS7 data]# cp -r /boot/grub2 /data/gb.bak

[root@CentOS7 data]# ls

gb.bak

[root@CentOS7 data]# cp /root/Downloads/ /data/d -r

[root@CentOS7 data]# ll /data/d

total 0

[root@CentOS7 data]# ls /data/d

[root@CentOS7 data]# cp /root/Downloads/ /data/d -r

[root@CentOS7 data]# ls /data/d

Downloads

 2mv命令

-i      

-f    

-b    

-v

-u  

3rm命令

    -r    递归操作

    -f    强制执行,不交互。

    -v    显示运行过程


分享名称:2.3文件管理类命令
网站网址:http://mbwzsj.com/article/pspjps.html

其他资讯

让你的专属顾问为你服务