1、新建几个普通用户wukong,wuneng,wujing,他们都属于xiyouji组的成员,其中wujing没有和系统交互的shell。
[root@localhost ~]# groupadd xiyouji
[root@localhost ~]# useradd -g xiyouji wukong
[root@localhost ~]# useradd -g xiyouji wuneng
[root@localhost ~]# useradd -g xiyouji wujing
[root@localhost ~]# vim /etc/passwd
wukong:x:1001:1001::/home/wukong:/bin/bash
wuneng:x:1002:1001::/home/wuneng:/bin/bash
wujing:x:1003:1001::/home/wujing:
2、wukong和wuneng的密码都为redhat。
[root@localhost ~]# passwd wukong
Changing password for user wukong.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd wuneng
Changing password for user wuneng.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
3、通过sudo使得wukong可以使用wuneng和wujing的权限在他们的家目录下创建普通文件file。
[wukong@localhost ~]$ sudo - wujing touch /home/wujing/file
[sudo] password for wukong:
wukong is not in the sudoers file. This incident will be reported.
[root@localhost ~]# vim /etc/sudoers 编辑sudoers这个文件,将wukong添加进去
[wukong@localhost ~]$ sudo -u wuneng touch /home/wuneng/file
[sudo] password for wukong:
[wukong@localhost ~]$ sudo -u wujing touch /home/wujing/file
[wukong@localhost ~]$ exit
logout
[root@localhost ~]# ll /home/wuneng
total 0
-rw-r--r--. 1 wuneng xiyouji 0 May 17 18:12 file
[root@localhost ~]# ll /home/wujing
total 0
-rw-r--r--. 1 wujing xiyouji 0 May 17 18:13 file
4、通过sudo使得wukong可以将密码配置文件中自己的密码信息相关内容保存至自己家目录下的mima文件。
[wukong@localhost ~]$ sudo -u root grep wukong /etc/shadow | tee mima
wukong:$6$XOL/TRFjsyp2jzzu$O2s60CGH9SJlKvEZ0WCY5FuUem8vp6dr2rx0NVb9CscIn4gIdTwteBEHvtsqhnGlTtV.xK0WOF9HQEmu9a9k/1:18764:0:99999:7:::
[wukong@localhost ~]$ ll
total 4
-rw-r--r--. 1 wukong xiyouji 133 May 17 18:36 mima
[wukong@localhost ~]$ cat mima
wukong:$6$XOL/TRFjsyp2jzzu$O2s60CGH9SJlKvEZ0WCY5FuUem8vp6dr2rx0NVb9CscIn4gIdTwteBEHvtsqhnGlTtV.xK0WOF9HQEmu9a9k/1:18764:0:99999:7:::
5、创建用户和组,新建一个名为adminuser的组,组id为3333;新建一个名为xiaoming的用户,将adminuser作为其附属组,且其uid为2003;新建一个名为xiaohong的用户,将adminuser作为其附属组;新建一个名为xiaohei的用户,其不属于adminuser组,其在系统中没有任何可交互的shell;三个用户的密码都是redhat。
[root@localhost ~]# groupadd -g 3333 adminuser
[root@localhost ~]# useradd -G adminuser -u 2003 xiaoming
[root@localhost ~]# usdradd -G adminuser xiaohong
bash: usdradd: command not found...
[root@localhost ~]# useradd -G adminuser xiaohong
[root@localhost ~]# useradd xiaohei
[root@localhost ~]# vim /etc/passwd
[root@localhost ~]# passwd xiaoming
Changing password for user xiaoming.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd xiaohong
Changing password for user xiaohong.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd xiaohei
Changing password for user xiaohei.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#