標籤:linux 許可權 建立使用者的過程
1.建立一個沒有家目錄的使用者openstack
2.複製/etc/skel為/home/openstack
3.改變/home/openstack及其內部的檔案的屬主,屬組均為openstack
4./home/openstack及其內部的檔案,屬組和其他使用者沒有任何存取權限
[[email protected] ~]# useradd -M openstack[[email protected] ~]# ls -l /home/openstackls: /home/openstack: No such file or directory[[email protected] ~]# tail -1 /etc/passwdopenstack:x:4005:4005::/home/openstack:/bin/bash[[email protected] ~]# id openstackuid=4005(openstack) gid=4005(openstack) groups=4005(openstack) context=root:system_r:unconfined_t:SystemLow-SystemHigh[[email protected] ~]# finger openstackLogin: openstack Name: (null)Directory: /home/openstack Shell: /bin/bashNever logged in.No mail.No Plan.[[email protected] ~]# 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‘[[email protected] ~]# ls -la /home/openstacktotal 40drwxr-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[[email protected] ~]# cd /home/openstack[[email protected] openstack]# ls -latotal 40drwxr-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[[email protected] openstack]# chown -R openstack:openstack .[[email protected] openstack]# ls -latotal 40drwxr-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[[email protected] openstack]# chmod go= .[[email protected] openstack]# ls -latotal 40drwx------ 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[[email protected] openstack]# chmod -R go= .[[email protected] openstack]# ls -latotal 40drwx------ 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[[email protected] openstack]# |
結果:
[[email protected] openstack]# su - openstack[[email protected] ~]$ iduid=4005(openstack) gid=4005(openstack) groups=4005(openstack) context=root:system_r:unconfined_t:SystemLow-SystemHigh |
其實上面的過程也揭示了使用者建立的過程。
(每一個命令執行完畢後,都應該想辦法去驗證它!)
本文出自 “我想超越自我” 部落格,請務必保留此出處http://zhangfengzhe.blog.51cto.com/8855103/1412919