属主属组其他人对文件的rwx权限

1.userdel删东西不全,会有残留,

彻底删除[root@localhost ~]# userdel -r tom
单个删除[root@localhost ~]# rm -rf /var/spool/mail/tom
分别对应的数字值  r=4 w=2  x=1,则rwx=7

 

#1创建目录, 
[root@localhost ~]# cd /tmp/ 
查看权限
[root@localhost tmp]# ll -d /tmp/
drwxrwxrwt. 70 root root 8192 10月 29 13:41 /tmp/
创建文件
[root@localhost tmp]# mkdir /test
查看权限
[root@localhost tmp]# ll -dl /test
drwxrwxrwx 4 root root 43 10月 29 12:37 /test
[root@localhost tmp]# cd /test
[root@localhost test]# touch a.txt
[root@localhost test]# ll a.txt
-rw-r--r-- 1 root root 0 10月 29 13:47 a.txt
创建普通用户
[root@localhost test]# useradd tom
[root@localhost test]# su - tom
上一次登录:日 10月 29 13:18:49 CST 2017pts/0 上
[tom@localhost ~]$ cd /test
查看文件
[tom@localhost test]$ ls
a.txt  test1  tom
#4
[tom@localhost test]$ cat a.txt        #(无内容)
#6
[tom@localhost test]$ cat a.txt    (可读)
[tom@localhost test]$ echo 'tom' >> a.txt    (可写)
#8
[tom@localhost test]$ cat a.txt
-bash: ./a.txt: 权限不够
#11
[tom@localhost test]$ ./a.txt    (可执行)

 

#2超级用户
[wushang@localhost ~]$ su - root
密码:
上一次登录:日 10月 29 13:00:00 CST 2017pts/1 上
[root@localhost ~]# echo 'root11111' > a.txt
[root@localhost ~]# chmod o=- a.txt         (其他人权限为0) 
[root@localhost ~]# ll a.txt
-rwxr----- 1 root root 10 10月 29 13:49 a.txt
#5.
[root@localhost ~]# chmod o=r a.txt
#7
[root@localhost ~]# chmod o=w a.txt
#9
[root@localhost ~]# cat a.txt
root11111
#10
[root@localhost ~]# chmod o=rx a.txt
#12
[root@localhost ~]# vim a.txt       (加了ls passwd) 
[root@localhost ~]# ./a.txt
anaconda-ks.cfg  a.txt    initial-setup-ks.cfg  jack.txt
更改用户 root 的密码 。
新的 密码:
无效的密码: 密码未提供
重新输入新的 密码:
密码未提供

passwd: 鉴定令牌操作错误
[root@localhost ~]# 
[root@localhost ~]# 

 

 

 

 

 

usermod -G 目标组名 用户名 ----------将此用户添加至目标组之中

权限可加减eg:chmod u-r a.txt

   u-  g  -o

r u-r     g-r

x

w

 属主属组对目录的rwx权限

 

#1创建用户
[root@localhost ~]# useradd alex
#3
exit
[root@localhost ~]# su - alex
[root@localhost alex]# ls /test/test1/
jack1.txt  jack2.txt
#5
[root@localhost alex]# cd /test/test1/
[root@localhost test1]# cd /test/test1
[root@localhost test1]# pwd
/test/test1
7
[root@localhost test1]# ls
jack1.txt  jack2.txt
9
[root@localhost test1]# exit
登出
[tom@localhost test]$ su - alex
[tom@localhost test]$ cd /test/test1
11
[tom@localhost test]$ rm -rf /test/test1/jack1.txt
13
[tom@localhost test]$ ls /test/test1
jack1.txt  jack2.txt
[tom@localhost test]$ touch /test/test/tom.txt
15
[tom@localhost test1]$cd/test/test1
[tom@localhost test1]$ ls
[tom@localhost test1]$ touch /test/test1

17
[tom@localhost test1]$ exit
[root@localhost test]# cd /test/test1
[root@localhost test1]# touch /test/test1
[root@localhost test1]# ls
jack1.txt  jack2.txt
[root@localhost test1]# rm -rf jack2.txt
[root@localhost test1]# ll a.txt

 

 

2
[jack@localhost ~]$ mkdir /test/test1
[jack@localhost ~]$ touch /test/test1/jack1.txt
[jack@localhost ~]$ touch /test/test1/jack2.txt
[jack@localhost ~]$ exit
[root@localhost ~]# ll -d /text/text1/
[root@localhost ~]# chmod o-x /test/test1/

4[root@localhost ~]# chmod o-x /test/test1/
6[root@localhost ~]# chmod o=rx /test/test1/
8[root@localhost ~]# chmod o=r /test/test1/
10
[root@localhost ~]# cd /test/test1
[root@localhost test1]# ll
[root@localhost test1]# chmod 777 *
[root@localhost test1]# ll
总用量 0
-rwxrwxrwx 1 jack jack 0 10月 29 14:39 jack1.txt
-rwxrwxrwx 1 jack jack 0 10月 29 14:39 jack2.txt
[root@localhost test1]# ll-d /test/test1/
bash: ll-d: 未找到命令...
[root@localhost test1]# ll
总用量 0
-rwxrwxrwx 1 jack jack 0 10月 29 14:39 jack1.txt
-rwxrwxrwx 1 jack jack 0 10月 29 14:39 jack2.txt
[root@localhost test1]# ll -d /test/test1
drwxrwxr-- 2 jack jack 40 10月 29 14:39 /test/test1
[root@localhost test1]# chmod o+x /test/test1
12
[root@localhost test1]# ls
jack1.txt  jack2.txt
14
[root@localhost test1]# ls
jack1.txt  jack2.txt
[root@localhost test1]# ll.tom.txt
[root@localhost test1]# 
[root@localhost test1]# ll -d /test/test1
drwxrwxr-x 2 jack jack 23 10月 29 15:08 /test/test1
[root@localhost test1]# chmod o=- /test/test1
[root@localhost test1]# ll -d /test/test1
drwxrwx--- 2 jack jack 23 10月 29 15:08 /test/test1
16
[root@localhost test1]# usermod -G jack alex
[root@localhost test1]# id jack
\uid=1206(jack) gid=1206(jack) 组=1206(jack)

 

对于用户的目录下的文件的权限例子

/test/a.txt   分析分为三个模块文件,目录,根目录,可以倒着分析

mkdir目录touch文件

 

#1 
[root@localhost test1]# mkdir /test                            创建目录    
[root@localhost test1]# touch /a.txt                           创建文件
[root@localhost test1]# touch /test/a.txt    
查看文件权限                
[root@localhost test1]# ll -l /test/a.txt
-rw-r--r-- 1 root root 0 10月 29 16:20 /test/a.txt
对文件权限修改
[root@localhost test1]# chmod o=- /test/a.txt
修改后文件的权限
[root@localhost test1]# ll /test/a.txt
-rw-r----- 1 root root 0 10月 29 16:20 /test/a.txt
查看目录的权限
[root@localhost test1]# ll -d /test
drwxr-x--- 2 root root 19 10月 29 16:20 /test.
查看根目录权限
[root@localhost test1]# ll -d /
dr-xr-xr-x. 18 root root 256 10月 29 16:19 /
创建新用户
[root@localhost test1]# useradd sb
[root@localhost test1]# su - sb
[sb@localhost ~]$ echo 1111 > /test/a.txt
-bash: /test/a.txt: 权限不够
#3在文件内写信息
[sb@localhost ~]$ echo 1111 > /test/a.txt
-bash: /test/a.txt: 权限不够
#5
[sb@localhost ~]$ echo 1111>> /test/a.txt
-bash: /test/a.txt: 权限不够
[sb@localhost ~]$ echo 1111 > /test/a.txt
-bash: /test/a.txt: 权限不够
[sb@localhost ~]$ echo 1111 > /test/a.txt
-bash: /test/a.txt: 权限不够
[sb@localhost ~]$ 
#2
[root@localhost test1]# ll /test/a.txt
-rw-r----- 1 root root 0 10月 29 16:20 /test/a.txt
[root@localhost test1]# ll -d /test/
drwxr-x--- 2 root root 19 10月 29 16:20 /test/
[root@localhost test1]# chmod o=x /test
#4
[root@localhost test1]# cat a.txt
[root@localhost test]# ll -d /test
drwxr-xr-x 2 root root 19 10月 29 16:39 /test
[root@localhost test]# ll -d /
dr-xr-xr-x. 18 root root 256 10月 29 16:33 /
[root@localhost test]# chmod o=x /
6
[root@localhost test]# !cat
cat a.txt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

补充:

4-r  读 cat cd

2-w 写echo

1-x 执行./

cat看文件内容

chmod -w -------------给予其他组用户写入文件的权限

chmod o=- -----------删除其他组用户的读取权限

chmod o=r -------------给予其他组用户的读取权限

echo 添加文件内容

./啊,txt  表示   执行文件的命令参数(必须有x权限)

 

eg:chomd o=rx a.txt

 

posted on 2017-10-29 15:24  余生请多指教-无伤  阅读(168)  评论(0编辑  收藏  举报