第二次作业

touch /opt/passwd
cat /etc/passwd >> /opt/passwd
head -6 /opt/passwd |tail-1

2.在/etc及其子目录中,查找host开头的文件(使用find指令)

find /etc  -name -depth "host*"

  1. /etc/host.conf

  2. /etc/hosts

  3. /etc/avahi/hosts

  4. /etc/nvme/hostnqn

  5. /etc/nvme/hostid

  6. /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
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值