linux文件权限【基本权限ugo】
来源:互联网 发布:吉他软件手机版 编辑:程序博客网 时间:2024/06/05 00:19
1*基本权限 U G O
1.文件权限设置: 可以赋于某个用户或组 能够以何种方式 访问某个文件
权限对象:
属主: u
属组: g
其他人: o
基本权限类型:
读:r 4
写:w 2
执行: x 1
如上图
d:表示文件类型(后续内容会讲到)
rwx:表示属主u的权限
r-x:表示属组g的权限
r-x:表示其他人的权限
==设置权限
【更改文件的属主和属组】
1.chown:
[root@w_hat ~]#chown alice.hr file1
[root@w_hat ~]#chown alice file1 //更改属主
[root@w_hat ~]#chown .hr file //更改属组
[root@w_hat ~]#chown -R wp.hr dir1 //dir1下的所有文件的属主和属组均改变
2.chgrp:
[root@w_hat ~]#chgrp it file1 //更改文件属组
[root@w_hat ~]#chgrp -R it dir1 //递归更改属组
【更改权限】
1.chmod(使用字符更改)
[root@w_hat ~]#chmod u+x file1 //对属主增加执行的权限
[root@w_hat ~]#chmod a=rwx file1 //对所有人的权限都设置为读写执行
[root@w_hat ~]#chmod a=- file1 //所有人都没有权限
[root@w_hat ~]# chmod ug=rw,o=r file1 //属主和属组读写权限,其他人只读
2.chmod(使用数字更改)
[root@w_hat ~]#chmod 644 file1 //属主读写权限,属组和其他人只读
2*权限设置案例
==设置权限案例
1.针对hr部门的访问目录/home/hr设置权限,要求如下:
(1)root用户和hr组的员工可以读、写、执行
(2)其他用户没有任何权限
[root@w_hat ~]#groupadd hr
[root@w_hat ~]#useradd hr01 -G hr
[root@w_hat ~]#useradd hr02 -G hr
[root@w_hat ~]#mkdir /home/hr
[root@w_hat ~]#chgrp hr /home/hr
[root@w_hat ~]#chmod 770 /home/hr
重要*rwx权限对于文件和目录的意义
1.rwx对文件的影响
在home下创建一个文件写入date
[root@w_hat ~]# ll /home/file1
-rw-r–r– /home/file1
[root@w_hat ~]# chmod o+x /home/file1
[root@w_hat ~]# chmod o+w /home/file1
[root@w_hat ~]# su - alice
[alice@w_hat ~]$ cat /home/file1 //测试读[alice@w_hat ~]$ /home/file1 //测试执行-bash: /home/file1: 权限不够[alice@w_hat ~]$ /home/file1
2017年 08月 1日 星期二 19:52:29 CST
[alice@w_hat ~]$ vim /home/file1 //测试写
==rwx对目录的影响==
实战案例2:对目录没有w,对文件有rwx
[root@w_hat ~]# mkdir /dir10
[root@w_hat ~]# touch /dir10/file1
[root@w_hat ~]# chmod 777 /dir10/file1
[root@w_hat ~]# ll -d /dir10/
drwxr-xr-x. /dir10
[root@w_hat ~]# ll /dir10/file1
-rwxrwxrwx. /dir10/file1
[alice@w_hat ~]$ cat /dir10/file1 [alice@w_hat ~]$ rm -rf /dir10/file1 rm: 无法删除"/dir10/file1": 权限不够
实战案例3:对目录有w,对文件没有任何权限
[root@w_hat ~]# chmod 777 /dir10/
[root@w_hat ~]# chmod 000 /dir10/file1
[root@w_hat ~]# ll -d /dir10/
drwxrwxrwx. 2 root root 4096 3月 11 18:37 /dir10/
[root@w_hat ~]# ll /dir10/file1
———-. /dir10/file1
[alice@w_hat ~]$ cat /dir10/file1 cat: /dir10/file1: 权限不够[alice@w_hat ~]$ rm -rf /dir10/file1 [alice@w_hat ~]$ touch /dir10/file2
- linux文件权限【基本权限ugo】
- 文件基本权限-UGO
- 基本权限 UGO
- UGO权限问题
- Linux/Ubuntu下UGO及ACL权限管理
- Linux文件基本权限
- Linux文件权限基本配置
- linux基本权限--权限对文件,目录作用说明
- Linux权限管理(基本权限、默认权限、
- Linux权限管理(基本权限、默认权限、
- linux 文件权限的基本命令
- linux系统基本命令之文件权限
- linux基本命令chmod修改文件权限
- linux基本操作---用户以及文件权限
- linux基本权限 --基本权限修改
- 文件基本权限
- 文件基本权限-ACL
- linux基本权限
- 中国剩余定理
- 西邮导航
- 查找一个字符串中第一个只出现两次的字符。比如:“abcdefabcdefabc”中第一个只出现两次为‘d’,要求时间复杂度为O(N),空间复杂度为O(1)
- c/c++ 面试笔试知识点----牛客网(1)
- hpuoj 【1212】该死的密码【字符串】
- linux文件权限【基本权限ugo】
- 232. Implement Queue using Stacks(java)
- Spring框架中的Quartz使用(详解)
- 杭电acm—1306 String Matching
- Redis学习笔记(三)Redis源码解读
- 进程间通信---Messenger
- hdu 2509 Be the Winner
- 多文本显示省略号
- 初学Hibernate学习1 基础知识掌握