改变文件的属主和属组
1. Chown----解释:改变文件的属主(只有管理员有这个权限)
选项: -R:修改目录及其内部文件的属性
--reference=/path/to/somefile file,....: 参考,将文件的属主和属组改为指定 属主和属组
属主:
例:
[root@ns1 ~]# useradd zbx------------------------创建用户
[root@ns1 ~]# cd /tmp/---------------------------进入tmp
[root@ns1 tmp]# touch abc----------------------创建文件
[root@ns1 tmp]# ls
显示结果:abc yum.log
[root@ns1 tmp]# ls -l /tmp/abc-----------------长格式显示abc文件
显示结果:-rw-r--r-- 1 root root 0 3月 29 19:05 /tmp/abc
[root@ns1 tmp]# chown zbx /tmp/abc---------更改文件属主
[root@ns1 tmp]# ll /tmp/abc ---------------------再次查看文件
显示结果:-rw-r--r-- 1 zbx root 0 3月 29 19:05 /tmp/abc
[root@ns1 tmp]# mkdir /tmp/mulu
[root@ns1 tmp]# ll /tmp/mulu
总用量 0
[root@ns1 tmp]# ls -ld /tmp/mulu
drwxr-xr-x 2 root root 4096 3月 29 19:19 /tmp/mulu
[root@ns1 tmp]# chown zbx /tmp/mulu
[root@ns1 tmp]# ls -ld /tmp/mulu
drwxr-xr-x 2 zbx root 4096 3月 29 19:19 /tmp/mulu
[root@ns1 tmp]# cp /etc/* /tmp/mulu
cp: 略过目录"/etc/abrt"
cp: 略过目录"/etc/acpi"
[root@ns1 tmp]# ls -l /tmp/mulu
总用量 1452
-rw-r--r-- 1 root root 45 3月 29 19:26 adjtime
-rw-r--r-- 1 root root 1512 3月 29 19:26 aliases
[root@ns1 tmp]# chown -R zbx /tmp/mulu
[root@ns1 tmp]# ls -ld /tmp/mulu/
drwxr-xr-x 2 zbx root 4096 3月 29 19:26 /tmp/mulu/
[root@ns1 tmp]# ls -l /tmp/mulu/
总用量 1452
-rw-r--r-- 1 zbx root 45 3月 29 19:26 adjtime
-rw-r--r-- 1 zbx root 1512 3月 29 19:26 aliases
批量修改:
属组:
例:
批量修改: