改变文件的属主和属组Linux改变文件的属主和属组

1. Chown----解释:改变文件的属主(只有管理员有这个权限)

选项: -R:修改目录及其内部文件的属性

--reference=/path/to/somefile file,....: 参考,将文件的属主和属组改为指定 属主和属组

属主:

例:

[[email protected] ~]# useradd zbx------------------------创建用户

[[email protected] ~]# cd /tmp/---------------------------进入tmp

[[email protected] tmp]# touch abc----------------------创建文件

[[email protected] tmp]# ls

显示结果:abc  yum.log

[[email protected] tmp]# ls -l /tmp/abc-----------------长格式显示abc文件

显示结果:-rw-r--r-- 1 root root 0 3月  29 19:05 /tmp/abc

[[email protected] tmp]# chown zbx /tmp/abc---------更改文件属主

[[email protected] tmp]# ll /tmp/abc ---------------------再次查看文件

显示结果:-rw-r--r-- 1 zbx root 0 3月  29 19:05 /tmp/abc

 

 

[[email protected] tmp]# mkdir /tmp/mulu

[[email protected] tmp]# ll /tmp/mulu

总用量 0

[[email protected] tmp]# ls -ld /tmp/mulu

drwxr-xr-x 2 root root 4096 3月  29 19:19 /tmp/mulu

[[email protected] tmp]# chown zbx /tmp/mulu

[[email protected] tmp]# ls -ld /tmp/mulu

drwxr-xr-x 2 zbx root 4096 3月  29 19:19 /tmp/mulu

[[email protected] tmp]# cp /etc/* /tmp/mulu

cp: 略过目录"/etc/abrt"

cp: 略过目录"/etc/acpi"

[[email protected] 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

[[email protected] tmp]# chown -R zbx /tmp/mulu

[[email protected] tmp]# ls -ld /tmp/mulu/

drwxr-xr-x 2 zbx root 4096 3月  29 19:26 /tmp/mulu/

[[email protected] 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

批量修改:

 Linux改变文件的属主和属组

属组:

例:

 Linux改变文件的属主和属组

批量修改:

 Linux改变文件的属主和属组

 

相关文章: