1、创建mygroup组群,再创建myuser用户,并且此用户属于mygroup组群,接着以myuser身份登录,创建ex和hv两个文件于/home/myuser目录,并使hv文件的同组用户是root。请依次写出相应执行的命令。
首先创建mygroup组群------指令:groupadd my group
创建用户并属于mygroup组群-----指令:useradd -g mygroup myuser
查看用户属性-----指令:id myuser
以myuser身份登录----指令:su - myuser
[root@localhost ~]# groupadd mygroup
[root@localhost ~]# useradd -g mygroup myuser
[root@localhost ~]# id myuser
uid=1005(myuser) gid=4445(mygroup) groups=4445(mygroup)
[root@localhost ~]# su - myuser
[myuser@localhost ~]$ usermod -G mygroup root
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
[myuser@localhost ~]$ usermod -G mygroup root
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
[myuser@localhost ~]$ groups root
root : root
[myuser@localhost ~]$ usermod -G mygroup root
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
[myuser@localhost ~]$ usermod -G mygroup root
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
[myuser@localhost ~]$ /root
-bash: /root: Is a directory
[myuser@localhost ~]$ cd /root
-bash: cd: /root: Permission denied
[myuser@localhost ~]$ cd /root
-bash: cd: /root: Permission denied
[myuser@localhost ~]$ su -root
su: invalid option -- 'r'
Try 'su --help' for more information.
[myuser@localhost ~]$ su - root
Password:
[root@localhost ~]# usermod -G mygroup root
[root@localhost ~]# groups root
root : root mygroup
[root@localhost ~]# ^C
创建文件与目录分别使用指令:touch、mkdir(可看之前操作)
使文件的同组用户为root----指令:usermod -G mygroup root
查看所属----:groups root
2、现需添加一新用户helen并设置其用户主目录/helen,密码为空。还需添加新组群temp,指定其GID为600,并将temp组群作为用户helen的附加组群。请依次写出相应执行的命令。
[root@localhost ~]# groupad temp
bash: groupad: command not found...
[root@localhost ~]# groupadd temp
[root@localhost ~]# groupadd -g 600 temp
groupadd: group 'temp' already exists
[root@localhost ~]# useradd helen -d /helen -G temp
[root@localhost ~]# ll helen -d
ls: cannot access 'helen': No such file or directory
[root@localhost ~]# ll/ helen -d
-bash: ll/: No such file or directory
[root@localhost ~]# ll /helen -d
drwx------. 3 helen helen 78 Oct 3 15:16 /helen
[root@localhost ~]# id helen
uid=1006(helen) gid=1006(helen) groups=1006(helen),4446(temp)
首先创建temp组群---指令:groupadd temp
然后将tempGID设定为600---指令groupmod -g 600 temp
最后创建新用户helen并设置主目录---指令:useradd helen -d /helen -G tem
3、创建用户user,并设置其口令为“a1b2c3”,并加入group组群(假设group组群已经存在)。请依次写出相应执行的命令。
[root@localhost ~]# grep group /etc/group
mygroup:x:4445:root
[root@localhost ~]# groupadd group
[root@localhost ~]# useradd -g group user
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
[root@localhost ~]# echo a1b2c3 |passwd --stdin user
Changing password for user user.
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
4、新建一个名为adminuser的组,组id为40000
5、新建一个名为natasha的用户,并将adminuser作为其附属组
6、新建一个名为harry的用户,并将adminuser作为其附属组
7、新建一个名为sarah的用户,其不属于adminuser组,并将其shell设置为不可登陆shell
[root@localhost ~]# groupadd -g 40000 adminuser
groupadd: group 'adminuser' already exists
[root@localhost ~]#
[root@localhost ~]# useradd -G adminuser natasha
[root@localhost ~]# useradd -G adminuser harry
[root@localhost ~]# useradd sarah -s /sbin/nologin
[root@localhost ~]# su - sarah
8、添加用户maomao,修改它的家目录为/maomao,要求切换maomao时命令提示 显示正常。
[root@localhost ~]# useradd -d /maomao maomao
[root@localhost ~]# echo redhat |passwd --stdin maomao
Changing password for user maomao.
passwd: all authentication tokens updated successfully.
9、创建std1 ,std2两个组,要求std1组中有三个用户,{1 2 3}
10、natasha、harry和sarah三个用户的密码均设置为glegunge创建用户
11、请名为alex的用户,并满足以下要求:用户id为3456,描述名为alian密码为glegunge
12、创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt