Linux 用戶,組,權限小練習

1.新建一個沒有家目錄的用戶openstackbash


2.複製/etc/skel爲/home/openstackide


3.改變/home/openstack及其內部的文件的屬主,屬組均爲openstackui


4./home/openstack及其內部的文件,屬組和其餘用戶沒有任何訪問權限it



[root@localhost ~]# useradd -M openstack
[root@localhost ~]# ls -l /home/openstack
ls: /home/openstack: No such file or directory
[root@localhost ~]# tail -1 /etc/passwd
openstack:x:4005:4005::/home/openstack:/bin/bash
[root@localhost ~]# id openstack
uid=4005(openstack) gid=4005(openstack) groups=4005(openstack) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# finger openstack
Login: openstack                Name: (null)
Directory: /home/openstack              Shell: /bin/bash
Never logged in.
No mail.
No Plan.
[root@localhost ~]# cp -rv /etc/skel /home/openstack
`/etc/skel' -> `/home/openstack'
`/etc/skel/.bashrc' -> `/home/openstack/.bashrc'
`/etc/skel/.bash_logout' -> `/home/openstack/.bash_logout'
`/etc/skel/.bash_profile' -> `/home/openstack/.bash_profile'
[root@localhost ~]# ls -la /home/openstack
total 40
drwxr-xr-x  2 root root 4096 May 16 16:14 .
drwxr-xr-x 28 root root 4096 May 16 16:14 ..
-rw-r--r--  1 root root   24 May 16 16:14 .bash_logout
-rw-r--r--  1 root root  176 May 16 16:14 .bash_profile
-rw-r--r--  1 root root  124 May 16 16:14 .bashrc
[root@localhost ~]# cd /home/openstack
[root@localhost openstack]# ls -la
total 40
drwxr-xr-x  2 root root 4096 May 16 16:14 .
drwxr-xr-x 28 root root 4096 May 16 16:14 ..
-rw-r--r--  1 root root   24 May 16 16:14 .bash_logout
-rw-r--r--  1 root root  176 May 16 16:14 .bash_profile
-rw-r--r--  1 root root  124 May 16 16:14 .bashrc
[root@localhost openstack]# chown -R openstack:openstack .
[root@localhost openstack]# ls -la
total 40
drwxr-xr-x  2 openstack openstack 4096 May 16 16:14 .
drwxr-xr-x 28 root      root      4096 May 16 16:14 ..
-rw-r--r--  1 openstack openstack   24 May 16 16:14 .bash_logout
-rw-r--r--  1 openstack openstack  176 May 16 16:14 .bash_profile
-rw-r--r--  1 openstack openstack  124 May 16 16:14 .bashrc
[root@localhost openstack]# chmod go= .
[root@localhost openstack]# ls -la
total 40
drwx------  2 openstack openstack 4096 May 16 16:14 .
drwxr-xr-x 28 root      root      4096 May 16 16:14 ..
-rw-r--r--  1 openstack openstack   24 May 16 16:14 .bash_logout
-rw-r--r--  1 openstack openstack  176 May 16 16:14 .bash_profile
-rw-r--r--  1 openstack openstack  124 May 16 16:14 .bashrc
[root@localhost openstack]# chmod -R go= .
[root@localhost openstack]# ls -la
total 40
drwx------  2 openstack openstack 4096 May 16 16:14 .
drwxr-xr-x 28 root      root      4096 May 16 16:14 ..
-rw-------  1 openstack openstack   24 May 16 16:14 .bash_logout
-rw-------  1 openstack openstack  176 May 16 16:14 .bash_profile
-rw-------  1 openstack openstack  124 May 16 16:14 .bashrc
[root@localhost openstack]#


結果:table


[root@localhost openstack]# su - openstack
[openstack@localhost ~]$ id
uid=4005(openstack) gid=4005(openstack) groups=4005(openstack) context=root:system_r:unconfined_t:SystemLow-SystemHigh

其實上面的過程也揭示了用戶建立的過程。class


(每個命令執行完畢後,都應該想辦法去驗證它!)file

相關文章
相關標籤/搜索