问题
1
、创建
group2
组
2
、创建
xiaoxiao
用户并指定
group2
作为它的基本组
3
、给
xiaoxiao
用户设置密码为
123
4
、删除
xiaoxiao
用户的同时删除与之相关的文件和目录
5、root用户在/tmp
下创建一个
1.txt
的文件,写入
123
的内容并查看,修改
1.txt文件的其他人的权限为读写。
6、
root
用户在
/tmp
下创建
root.txt
文件,写入
“
这是
root”
内容。修改其他人的权限为
-
。创建一个
xiaohong
和
xiaoming
两个用户,并设置密码
xh
和
xm
,让
xiaohong
可以对
root.txt
有读写的权限,让
xiaoming
可以对
root.txt
有读的权限。
7、
xiaoming
用户在/t
mp
下创建一个
xiaoming.txt
的文件,修改
xiaoming.txt
的属者和属组为
xiaohong
。
答案:
1.创建group2组
[root@xiaoming ~]# groupadd group2
2.
创建
xiaoxiao
用户并指定
group2
作为它的基本组
[root@xiaoming ~]# useradd xiaoxiao
[root@xiaoming ~]# usermod -g group2 xiaoxiao
[root@xiaoming ~]# usermod -g group2 xiaoxiao
3.
给
xiaoxiao
用户设置密码为
123
[root@xiaoming ~]# gpasswd group2
Changing the password for group group2
New Password:
Re-enter new password:
4. 删除 xiaoxiao 用户的同时删除与之相关的文件和目录
Changing the password for group group2
New Password:
Re-enter new password:
4. 删除 xiaoxiao 用户的同时删除与之相关的文件和目录
[root@xiaoming ~]# userdel -r xiaoxiao
5.
root用户在/tmp
下创建一个
1.txt
的文件,写入
123
的内容并查看,修改
1.txt文件的其他人的权限为读写。
[root@xiaoming ~]# cd
[root@xiaoming ~]# pwd
/root
[root@xiaoming ~]# pwd
/root
[root@xiaoming ~]# cd /tmp
[root@xiaoming tmp]# touch 1.txt
[root@xiaoming tmp]# touch 1.txt
[root@xiaoming tmp]# cd
[root@xiaoming ~]# vim 1.txt
[root@xiaoming ~]# chmod o=rw /tmp/1.txt
6.
root
用户在
/tmp
下创建
root.txt
文件,写入
“
这是
root”
内容。修改其他人的权限为
-
。创建一个
xiaohong
和
xiaoming
两个用户,并设置密码
xh
和
xm
,让
xiaohong
可以对
root.txt
有读写的权限,让
xiaoming
可以对
root.txt
有读的权限。
[root@xiaoming ~]# cd
[root@xiaoming ~]# pwd
/root
[root@xiaoming ~]# cd /tmp
[root@xiaoming tmp]# touch root.txt
[root@xiaoming tmp]# cd
[root@xiaoming ~]# vim root.txt
[root@xiaoming ~]# chmod o=- /tmp/root.txt
[root@xiaoming ~]# pwd
/root
[root@xiaoming ~]# cd /tmp
[root@xiaoming tmp]# touch root.txt
[root@xiaoming tmp]# cd
[root@xiaoming ~]# vim root.txt
[root@xiaoming ~]# chmod o=- /tmp/root.txt
[root@xiaoming ~]# useradd xiaohong
[root@xiaoming ~]# useradd xiaoming
[root@xiaoming ~]# passwd xiaohong
Changing the password for group xiaohong
New Password:
Re-enter new password:
[root@xiaoming ~]# passwd xiaoming
Changing the password for group xiaoming
New Password:
Re-enter new password:
[root@xiaoming ~]# echo this is xiaohong > /tmp/root.txt
[root@xiaoming ~]# chmod u=rw /tmp/root.txt
[root@xiaoming ~]# echo this is xiaoming > /tmp/root.txt
[root@xiaoming ~]# chmod u=r /tmp/root.txt
[root@xiaoming ~]# useradd xiaoming
[root@xiaoming ~]# passwd xiaohong
Changing the password for group xiaohong
New Password:
Re-enter new password:
[root@xiaoming ~]# passwd xiaoming
Changing the password for group xiaoming
New Password:
Re-enter new password:
[root@xiaoming ~]# echo this is xiaohong > /tmp/root.txt
[root@xiaoming ~]# chmod u=rw /tmp/root.txt
[root@xiaoming ~]# echo this is xiaoming > /tmp/root.txt
[root@xiaoming ~]# chmod u=r /tmp/root.txt
7.
xiaoming
用户在/t
mp
下创建一个
xiaoming.txt
的文件,修改
xiaoming.txt
的属者和属组为
xiaohong
。
[root@xiaoming ~]# su xiaoming
[xiaoming@xiaoming ~]$ cd /tmp
[xiaoming@xiaoming tmp]$ touch xiaoming.txt
[xiaoming@xiaoming tmp]$ su root
Password:
[root@xiaoming tmp]# chown xiaohong:xiaohong xiaoming.txt
[xiaoming@xiaoming ~]$ cd /tmp
[xiaoming@xiaoming tmp]$ touch xiaoming.txt
[xiaoming@xiaoming tmp]$ su root
Password:
[root@xiaoming tmp]# chown xiaohong:xiaohong xiaoming.txt