Demo entry 6363771

b

   

Submitted by anonymous on May 14, 2017 at 18:59
Language: Bash. Code size: 696 Bytes.

# 新建一个用户
root@vv55:~# groupadd group1
root@vv55:~# useradd -g group1 user1

#创建一个目录,取清其它用户的写权限(-w),并在目录里面新建一个文件。
root@vv55:~# mkdir dir
root@vv55:~# ls -ld dir
drwxr-xr-x 2 root root 4096 May 13 20:48 dir
root@vv55:~# cd dir
root@vv55:~/dir# ls
root@vv55:~/dir# echo aaa > aaa
root@vv55:~/dir# ls -la
total 12
drwxr-xr-x 2 root root 4096 May 13 20:56 .
drwx------ 8 root root 4096 May 13 20:55 ..
-rw-r--r-- 1 root root 4 May 13 20:56 aaa

#测试用户user1是否可以读、写、删文件
root@vv55:/# su - user1
No directory, logging in with HOME=/
$ cd dir
$ pwd
/dir
$ ls
aaa
$ cat aaa
aaa
$ echo bbb >> aaa
-su: aaa: Permission denied
$ rm -f aaa
rm: cannot remove 'aaa': Permission denied

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).