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