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
[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
- linux练习题5
- Linux练习题5
- Linux基础练习题(5)
- Linux练习题
- Linux练习题
- Linux练习题
- linux 练习题
- linux练习题
- linux练习题
- Linux练习题
- linux 练习题
- Linux练习题
- linux练习题
- linux学习5-6练习题及答案
- 练习题5
- Linux网络管理练习题
- linux网络练习题
- Linux远程访问练习题
- 05-树7 堆中的路径【建堆】
- HDU 5122 K.Bro Sorting
- Java常量池详解之抓狂的面试题
- Android引导页的实现
- HDU
- linux练习题5
- A-No response
- PCIe学习笔记(17)--- Power Management (2)
- scikit-learn Linear models
- HDU 2089 不要62
- qt信号signal和槽slot机制
- linux内核简介
- ABCDE五人每句话一半是对的,判断最后排名
- B-简单时间转换