Linux 使用者,組,許可權小練習

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.