天天看点

LINUX文件权限

[root@Freedom1991 test1]# cp /root/test/file  test1  复制文件到

[root@Freedom1991 test1]# ls

file.ln  test1

 

[root@Freedom1991 ~]# cp -ax test test1   复制所有的目录及包含的目录

[root@Freedom1991 ~]# ls

anaconda-ks.cfg  install.log  install.log.syslog  linux  test  test1  公共的  模板  视频  图片  文档  下载  音乐  桌面

[root@Freedom1991 ~]# mv test/file  test1/lover  将文件移动并重命名

[root@Freedom1991 ~]# 

文件权限: 四种

读 r  4

写  w  2 

执行 x  1

无     0

chmod修改文件权限:

drwxr-xr-x    2 root root  4096 9月  30 13:57 linux 

[root@Freedom1991 /]# chmod -R 777 /linux  

[root@Freedom1991 /]# ls -l

drwxrwxrwx    2 root root  4096 9月  30 13:57 linux

[root@Freedom1991 /]# chmod -R 000 /linux

d---------    2 root root  4096 9月  30 13:57 linux

[root@Freedom1991 /]# chmod -R u+w,g+r,o+x /linux

d-w-r----x    2 root root  4096 9月  30 13:57 linux

[root@Freedom1991 /]# chmod -R u+rwx,g-w,o-x /linux

drwxr-----    2 root root  4096 9月  30 13:57 linux

如果文件中还有其他子目录要使用 -R

chown 改变文件所者

[root@Freedom1991 /]# chown root.dn123456  /linux

drwxr-----    2 root dn123456  4096 9月  30 13:57 linux

[root@Freedom1991 /]# chown dn123456.dn123456  /linux

drwxr-----    2 dn123456 dn123456  4096 9月  30 13:57 linux

继续阅读