linux练习题5

来源:互联网 发布:数据通信与网络第四版 编辑:程序博客网 时间:2024/06/08 12:18
1.新建用户组,shengchan , caiwu,jishu
 [root@localhost Desktop]#  groupadd  shengchan
 [root@localhost Desktop]#groupadd  caiwu
 [root@localhost Desktop]# groupadd  jishu
2.新建用户要求如下:
                   1)tom是shengchan组的附加用户
[root@localhost Desktop]# useradd -G shengchan tom
                   2)harry是caiwu组的附加用户
[root@localhost Desktop]# useradd -G caiwu harry
                   3)leo是jishu组的附加用户
[root@localhost Desktop]#useradd -G jishu leo
                   4)新建admin用户此用户不属于以上提到的三个部门
         useradd admin
3.新建目录如下:
               1)/pub为公共存储目录对所有用户读,写,执行,但用户只能删除属于自己的文件
[root@localhost Desktop]# mkdir /pub
[root@localhost Desktop]#chmod 1777 /pub/
              2)/sc目录为生产部存储目录只能对生产部人员可以写入,并且生产部人员所建立的文件都自动归属于shengchan组中
[root@localhost Desktop]#mkdir /sc
[root@localhost Desktop]# chgrp shengchan /sc
[root@localhost Desktop]#  chmod 2770 /sc
              3)/cw目录为财务部存储目录只能由财务部人员可以写入,并且财务部人员所建立的文件都自动归属到caiwu组中
[root@localhost Desktop]# mkdir /cw
[root@localhost Desktop]#chgrp caiwu /cw
[root@localhost Desktop]#  chmod 2770 /cw
               4)admin用户能用touch工具在/sc目录和/cw目录中任意建立文件,但不能删除文件。
 [root@localhost Desktop]# visudo
在空行位置输入:admin localhost =(root)NOPASSWD: /usr/bin/touch
[Esc]   :wq
[root@localhost Desktop]# su admin
[admin@localhost Desktop]$ sudo /usr/bin/touch /sc/file
或者 [root@localhost Desktop]#  chmod  u+s /usr/bin/touch
4.设定普通用户新建文件权限为“r--r-----”
[root@localhost Desktop]# vim /etc/bashrc
进去把普通用户由002改为226
[root@localhost Desktop]# vim /etc/profile
和上一步一样
[root@localhost Desktop]# source /etc/bashrc
[root@localhost Desktop]# source /ec/profile
[root@localhost Desktop]# su admin
[admin@localhost Desktop]$ cd
[admin@localhost ~]$ touch file
5.设定admin用户可以通过sudo自由建立新用户
[root@localhost Desktop]#  visudo
在空行位置输入:admin localhost=(root)  NOPASSWD: /usr/sbin/useradd
[Esc] :wq
[root@localhost Desktop]#su admin
[admin@localhost Desktop]$ sudo /usr/sbin/useradd 新用户名 

              
        
1 0
原创粉丝点击