1. 复制/bin目录到当前目录下,并将文件打包成bin.tar(用gzip压缩)
[root@redhat-9 ~]# cp -r /bin .
[root@redhat-9 ~]# tar -cvf bin.tar bin
bin
[root@redhat-9 ~]# gzip bin.tar
2. 删除当前目录下胡bin子目录,将bin.tar文件解压至当前目录下
[root@redhat-9 ~]# rm -rf 胡bin
[root@redhat-9 ~]# tar -xvf bin.tar -C .
[root@redhat-9 ~]#
3. 创建用户win1,UID、GID等均按默认
[root@redhat-9 ~]# useradd win1
[root@redhat-9 ~]# ls /home
fox redhat temp1 temp2 test2 test4 win1
[root@redhat-9 ~]# id win1
uid=3005(win1) gid=3006(win1) groups=3006(win1)
4. 创建用户win2,默认主目录为/think,其余默认
[root@redhat-9 ~]# useradd -d /think win2
5. 将目录dir1设定成任何人皆有读取及执行的权利,但只有拥有者可作写修改
[root@redhat-9 think]# ll
total 0
-rw-rw-r--. 1 win1 root 0 Nov 12 17:06 book.txt
6. 将win2用户名改为tin,UID改为700,密码改为1330855
[root@redhat-9 ~]# usermod -l tin -u 1200 -p 1330855 win2
查看结果:
[root@redhat-9 ~]# tail -1 /etc/passwd
tin:x:1200:3007::/think:/bin/bash
[root@redhat-9 ~]# tail -2 /etc/shadow
win1:!!:20039:0:99999:7:::
tin:$6$L/BJo8awKAvpgKe5$awsUtnAXFTxaAdmc4ifrRN3ZlQ437EZkABzOVdHgHGXr/c3Fi7S6pQIze5x.8uSn88SbA3qXzMHc3Wv/h0A9Q/:20039:0:99999:7:::
7. 删除用户testuser
[root@redhat-9 ~]# useradd testuser
[root@redhat-9 ~]# userdel testuser
8. 连同主目录一起删除tin用户
[root@redhat-9 ~]# userdel -r tin
9. 创建一个名为goup的用户组,GID为5000
[root@redhat-9 ~]# groupadd -g 5000 group
[root@redhat-9 ~]# tail -1 /etc/group
group:x:5000:
10. 试将win1添加到goup中,明文查看win1所属组
[root@redhat-9 ~]# gpasswd -a win1 group
Adding user win1 to group group
[root@redhat-9 ~]# id win1
uid=3005(win1) gid=3006(win1) groups=3006(win1),5000(group)
11. 建立source文件的符号链接,命名为target2
[root@redhat-9 ~]# ln -s source target2
12. 在/think/下建立文件book.txt,将文件所属用户变为win1,对于book.txt,给属组用户添 加写权限,取消其他用户的读写权限
[root@redhat-9 ~]# ln -s source target2
[root@redhat-9 ~]# cd /
[root@redhat-9 /]# ls
afs bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
[root@redhat-9 /]# mkdir think
[root@redhat-9 /]# cd think/
[root@redhat-9 think]# touch book.txt
[root@redhat-9 think]# shown -R win1 book.txt
bash: shown: command not found...
Similar command is: 'chown'
[root@redhat-9 think]# chown -R win1 book.txt
[root@redhat-9 think]# chomd g+w book.txt
bash: chomd: command not found...
Similar command is: 'chmod'
[root@redhat-9 think]# chmod g m book.txt
chmod: invalid mode: ‘g’
Try 'chmod --help' for more information.
[root@redhat-9 think]# chmod o- rw book.txt
chmod: cannot access 'rw': No such file or directory
[root@redhat-9 think]# ll
total 0
-rw-r--r--. 1 win1 root 0 Nov 12 17:06 book.txt
[root@redhat-9 think]#
这里有点小错误,但基本语法是对的
13. 修改book.txt的权限为属组可读可写,同组可读,其他用户不可读不可写
[root@redhat-9 think]# chmod 660 book.txt
[root@redhat-9 think]# ll
total 0
-rw-rw----. 1 win1 root 0 Nov 12 17:06 book.txt
[root@redhat-9 think]#