Linux习题练习-03(users & group、tar、gzip、yum源配置)

习题练习03

  1. 修改 tom 的家目录为 /home/tomcat,且其基本组为 mail,uid号为 1111,密码为 ‘123456’

     [root@localhost home]# mkdir /home/tomcat
     [root@localhost ~]# useradd tom
     [root@localhost ~]# id tom
     uid=1001(tom) gid=1001(tom) groups=1001(tom)
     [root@localhost ~]# usermod -g mail -d /home/tomcat -u 1111 tom
     [root@localhost ~]# id tom
     uid=1111(tom) gid=12(mail) groups=12(mail)
     [root@localhost tomcat]# echo '123456' | passwd --stdin tom
     Changing password for user tom.
     passwd: all authentication tokens updated successfully.
    
  2. 创建系统账号名称为 admin,全名为 administrator,账户的家目录为 /home/admin, 账户的有效时间为 2022年12月24日,账户基本组为root,附加组为 bin,adm,mail

     [root@localhost tomcat]# useradd -c administrator -d /home/admin -e 2022-12-24 -g root -G bin,adm,mail admin
     [root@localhost tomcat]# id admin
     uid=1112(admin) gid=0(root) groups=0(root),1(bin),4(adm),12(mail)
    
  3. 压缩系统的 /home 目录,使用zip格式压缩,并且命名为student.tar.gz, 此文件要放在 /tmp/rhel7 目录下

     [root@localhost tomcat]# mkdir /tmp/rhel7
     [root@localhost tomcat]# tar -czvf /tmp/rhel7/student.tar.gz /home/
    
    gzip 与 bzip2 压缩与解压缩(-d) 
    这两个指令压缩文件,不能压缩目录
    
     [root@localhost rhel7]# touch aa.txt
     [root@localhost rhel7]# gzip aa.txt 
     [root@localhost rhel7]# ls
     aa.txt.gz  student.tar
     [root@localhost rhel7]# gzip -d aa.txt.gz 
     [root@localhost rhel7]# ls
     aa.txt  student.tar
     [root@localhost rhel7]# bzip2 aa.txt 
     [root@localhost rhel7]# ls
     aa.txt.bz2  home  student.tar.gz
     [root@localhost rhel7]# tar -xjvf aa.txt.bz2 
     [root@localhost rhel7]# ls
     aa.txt.bz2  home  student.tar.gz
     [root@localhost rhel7]# bzip2 -d aa.txt.bz2 
     [root@localhost rhel7]# ls
     aa.txt  home  student.tar.gz
    
  4. 查看 init* 文件末尾2KB 的内容

     [root@localhost ~]# tail -c 2K /root/initial-setup-ks.cfg 
    
  5. 创建以下几个目录(teach,office,finance,admin,market)

     [root@localhost ~]# mkdir -p /share/{teach,office,finance,admin,market}
     [root@localhost ~]# cd /share/
     [root@localhost share]# ls
     admin  finance  market  office  teach
    
  6. 配置 yum 源

     [root@localhost share]# mkdir /mnt/cdrom
     [root@localhost share]# mount /dev/cdrom /mnt/cdrom/
     [root@localhost share]# cd /etc/yum.repos.d/
     [root@localhost yum.repos.d]# vim dvd.repo 
     [dvd]
     name = dvd
     baseurl = file:///mnt/cdrom
     gpgcheck = 0
     enabled = 1
     [root@localhost yum.repos.d]# yum clean all
     [root@localhost yum.repos.d]# yum repolist all
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

若尘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值