1.文件查看:查看/opt/passwd文件的第6行(使用head和tail指令)
[root@localhost ~]# tail -6 /usr/bin/passwd
[root@localhost ~]# head -6 /usr/bin/passwd
2.在/etc及其子目录中,查找host开头的文件(使用find指令)
[root@localhost ~]# find /etc/ -name "*host*" -print
3.查找文件 /usr/share/rhel.xml 中包含字符串 re 的所有行。将所有这些行的信息放在文件/root/files 中(使用grep指令和重定向符号>)
[root@localhost ~]# grep re /usr/share/rhel/secrets/redhat.repo > /root/files
[root@localhost ~]# cat /root/files
4.将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz(使用tar指令)
[root@localhost ~]# mkdir /back
[root@localhost ~]# cd /
[root@localhost /]# tar -czf /back/backetc.tar.gz etc
[root@localhost /]# ll /back/backetc.tar.gz
-rw-r--r--. 1 root root 6338225 4月 13 12:24 /back/backetc.tar.gz
5.设置权限,要求如下:创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt(使用chown修改所属者和所属组)
[root@localhost /]# groupadd g1
[root@localhost /]# useradd redhat
[root@localhost /]# touch redhat.txt
[root@localhost /]# ll redhat.txt
-rw-r--r--. 1 root root 0 4月 13 12:27 redhat.txt
[root@localhost /]# chown redhat:g1 redhat.txt
[root@localhost /]# ll redhat.txt
-rw-r--r--. 1 redhat g1 0 4月 13 12:27 redhat.txt