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
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章