黑马《linux基础编程》学习笔记(从11到15)

十一. mv命令

//改名
[root@VM_0_15_centos test]# ls
a  hello.txt  son  son2  target

//改名情况一:
//mv file(存在) file1(不存在) 为file改名
[root@VM_0_15_centos test]# mv hello.txt bye.txt
[root@VM_0_15_centos test]# ls
a  bye.txt  son2  son3  target

//改名情况二:
//mv dir(存在) dir1(不存在) 为dir改名
[root@VM_0_15_centos test]# mv son son3
[root@VM_0_15_centos test]# ls
a  hello.txt  son2  son3  target

//移动

//移动情况一
//mv file(存在) dir(存在)
//结果:文件file移动至dir中
[root@VM_0_15_centos test]# ls
a  bye.txt  son2  son3  target
[root@VM_0_15_centos test]# tree a
a
`-- hello.txt

0 directories, 1 file
[root@VM_0_15_centos test]# mv bye.txt a
[root@VM_0_15_centos test]# ls
a  son2  son3  target
[root@VM_0_15_centos test]# tree a
a
|-- bye.txt
`-- hello.txt

0 directories, 2 files

//移动情况二
//mv dir(存在) dir1(存在)
//结果:dir移动到dir1中
[root@VM_0_15_centos test]# ls
a  son2  son3  target
[root@VM_0_15_centos test]# mv a son2
[root@VM_0_15_centos test]# ls
son2  son3  target
[root@VM_0_15_centos test]# tree son2
son2
|-- a
|   |-- bye.txt
|   `-- hello.txt
`-- son
    `-- hello.txt

2 directories, 3 files


//移动情况三
//mv file(存在) file1(存在)
//结果:file文件覆盖掉file1文件,file文件会被删除掉


 十二. 查看文件的内容相关的命令

 十三. 软硬链接

[root@VM_0_15_centos home]# ln -s ./home/test/target Pointer
[root@VM_0_15_centos home]# ls -l
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem

//这里的18是这个链接的./home/test/target的长度
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

 接下来是硬链接的实验

//首先通过ll,观察到orange.txt的硬链接只有一个

-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

//这里给orange.txt加了一个硬链接
[root@VM_0_15_centos home]# ln orange.txt HardLink


//这里我们再观察,orange.txt的硬链接变成了2个
[root@VM_0_15_centos home]# ll
total 13996
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rw-r--r-- 2 root  police        11 Sep  2 19:44 HardLink
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 2 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

//然后我们删掉orange.txt的HardLink的这个硬链接
[root@VM_0_15_centos home]# rm HardLink

//这里orange.txt对应的硬链接变成1
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

 十四. chmod修改文件权限

练习题

//新建一个file.c文件,并给满权限。
[root@VM_0_15_centos home]# touch file.c
[root@VM_0_15_centos home]# chmod 777 file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rwxrwxrwx 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf


[root@VM_0_15_centos home]# chmod uo-rw file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---xrwx--x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf


[root@VM_0_15_centos home]# chmod u+r,g-x file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-r-xrw---x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

 接下来是数字设定法

 

题目一解答 

[root@VM_0_15_centos home]# chmod 331 file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
--wx-wx--x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

 题目二解答

[root@VM_0_15_centos home]# chmod 777 file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
-rwxrwxrwx 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

[root@VM_0_15_centos home]# chmod -440 file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
--wx-wxrwx 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf
[root@VM_0_15_centos home]# chmod -w file.c
chmod: file.c: new permissions are --x-wxrwx, not --x--xr-x
[root@VM_0_15_centos home]# chmod a-w file.c
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---x--xr-x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

十五. chown和chgrp命令

例子:修改文件的所有者

[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---x--xr-x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf
[root@VM_0_15_centos home]# chown root zf
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---x--xr-x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 root  zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

修改文件的所有者:新的组

[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---x--xr-x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 zf    zf          4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf
[root@VM_0_15_centos home]# chown root:root zf
[root@VM_0_15_centos home]# ll
total 13992
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a1.txt
-rw-r--r-- 1 root  root           0 Sep  2 03:07 a2.txt
-rw-r--r-- 1 tom   root           0 Sep  2 04:48 apple.txt
-rw-r--r-- 1 root  root         117 Sep  2 03:09 a.tar.gz
-rw-r--r-- 1 root  root         747 Sep  1 07:34 a.txt
drwx------ 4 gouzi gouzi       4096 Aug 30 05:32 cjz
-rw-r--r-- 1 root  root        1781 Sep  1 07:35 c.txt
-rw-r--r-- 1 root  root          29 Sep  1 07:47 date.txt
---x--xr-x 1 root  root           0 Oct 27 06:23 file.c
-rw-r--r-- 1 root  root         243 Oct 24 18:49 hello.txt
-rw-r--r-- 1 root  root         198 Sep  2 02:58 hello.zip
lrwxrwxrwx 1 root  root           5 Sep  1 08:02 LinkToRoot -> /root
-rw-r--r-- 1 root  root         150 Sep  1 07:36 mycal
-rw-r--r-- 1 root  root    14260181 Sep  2 03:11 myhome.tar.gz
-rw-r--r-- 1 root  police        11 Sep  2 19:44 orange.txt
drwxr-xr-x 3 root  root        4096 Oct 27 05:45 poem
lrwxrwxrwx 1 root  root          18 Oct 27 06:01 Pointer -> ./home/test/target
drwxr-xr-x 4 root  root        4096 Oct 27 05:40 test
drwxr-xr-x 3 root  root        4096 Sep  7 18:48 TestDjango
drwx------ 4 tom   police      4096 Sep  2 03:31 tom
drwxr-xr-x 5 root  root        4096 Sep  1 03:28 virtualenvs
drwx------ 4 root  root        4096 Aug 30 05:44 zf
drwx------ 2 zwj   shaolin     4096 Aug 30 05:53 zsf

猜你喜欢

转载自blog.csdn.net/garrulousabyss/article/details/83434089