Linux基础命令目录管理002

    之前讲述了目录的创建和删除,现在讲一下目录的移动修改。

操作系统:

CentOS Stream 9

操作命令:

mv

移动,重命名

选项

-v显示移动过程

[root@localhost ~]# mkdir 12
[root@localhost ~]# ll
总用量 1220
drwxr-xr-x  2 root root        6  6月  1 00:04 12
-rw-------. 1 root root     1231  5月  8 15:09 anaconda-ks.cfg
drwxr-xr-x  9  502 games     186  5月 25 20:12 nginx-1.26.0
-rw-r--r--  1 root root  1244118  4月 23 22:58 nginx-1.26.0.tar.gz
[root@localhost ~]# pwd
/root
[root@localhost ~]# mv -v 12 /top/12
已重命名 '12' -> '/top/12'
[root@localhost ~]# 
[root@localhost ~]# cd /top
[root@localhost top]# ll
总用量 0
drwxr-xr-x 2 root root 6  6月  1 00:04 12
[root@localhost top]# 

操作命令:

pwd

显示当前工作目录的绝对路径

[root@localhost ~]# cd /usr/local/nginx
[root@localhost nginx]# pwd
/usr/local/nginx
[root@localhost nginx]# cd sbin
[root@localhost sbin]# pwd
/usr/local/nginx/sbin
[root@localhost sbin]# cd ..
[root@localhost nginx]# cd ..
[root@localhost local]# pwd
/usr/local
[root@localhost local]# 

操作命令:

cp

复制备份

将文件复制到目录

[root@localhost ~]# cp 1.txt /top/1.txt
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cd /top/
[root@localhost top]# ll
总用量 0
-rw-r--r-- 1 root root 0  6月  1 00:41 1.txt

 复制单个文件

[root@localhost ~]# ll
总用量 1220
-rw-r--r--  1 root root        0  6月  1 00:41 1.txt
-rw-------. 1 root root     1231  5月  8 15:09 anaconda-ks.cfg
drwxr-xr-x  9  502 games     186  5月 25 20:12 nginx-1.26.0
-rw-r--r--  1 root root  1244118  4月 23 22:58 nginx-1.26.0.tar.gz
[root@localhost ~]# cp 1.txt 2.txt
[root@localhost ~]# ll
总用量 1220
-rw-r--r--  1 root root        0  6月  1 00:41 1.txt
-rw-r--r--  1 root root        0  6月  1 00:44 2.txt
-rw-------. 1 root root     1231  5月  8 15:09 anaconda-ks.cfg
drwxr-xr-x  9  502 games     186  5月 25 20:12 nginx-1.26.0
-rw-r--r--  1 root root  1244118  4月 23 22:58 nginx-1.26.0.tar.gz
[root@localhost ~]# 

 复制目录

选项

  • -v:显示详细的操作过程。
  • -a:等同于 -dpR,保留原有文件的全部属性(包括权限、时间戳、链接等),递归复制目录。
[root@localhost ~]# cp -av /etc/passwd /top/passwd
'/etc/passwd' -> '/top/passwd'
[root@localhost ~]# 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值