touch /opt/passwd
cat /etc/passwd >> /opt/passwd
head -6 /opt/passwd |tail-1
2.在/etc及其子目录中,查找host开头的文件(使用find指令)
find /etc -name -depth "host*"
/etc/host.conf
/etc/hosts
/etc/avahi/hosts
/etc/nvme/hostnqn
/etc/nvme/hostid
/etc/hostname
3、查找文件 /usr/share/rhel.xml 中包含字符串 re 的所有行。将所有这些行的信息放在文件/root/files 中(使用grep指令和重定向符号>)
[root@localhost ~]# grep re /usr/share/rhel.xml > /root/files
[root@localhost ~]# cat /root/files
# avahi is free software; you can redistribute it and/or modify it
# published by the Free Software Foundation; either version 2 of the
# License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with avahi; if not, write to the Free Software
# This file contains static ip address <-> host name mappings. These
# device. Please bear in mind that host names are expected to be
# See avahi.hosts(5) for more information on this configuration file!
4、将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz(使用tar指令)
tar czf /back/etcback.tar.gz /etc
5、设置权限,要求如下:创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt(使用chown修改所属者和所属组)
[root@localhost ~]# su redhat
[redhat@localhost root]$ sudo groupadd g1
[redhat@localhost root]$ sudo touch redhat.txt
[redhat@localhost root]$ sudo chown redhat:g1 redhat.txt
[redhat@localhost root]$ sudo ls -lh redhat.txt
-rw-r--r--. 1 redhat g1 0 Apr 11 22:03 redhat.txt