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

简介: 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
    
目录
相关文章
|
19天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
42 0
|
19天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
60 0
|
21天前
|
Ubuntu Linux 编译器
【Linux】4. 开发工具的使用(yum/vim)
【Linux】4. 开发工具的使用(yum/vim)
44 2
|
1月前
|
存储 算法 Shell
【Shell 命令集合 备份压缩 】⭐⭐⭐Linux 解压缩gz工具 gzip命令 使用指南
【Shell 命令集合 备份压缩 】⭐⭐⭐Linux 解压缩gz工具 gzip命令 使用指南
34 0
|
5天前
|
人工智能 数据可视化 Linux
【linux基础(五)】Linux中的开发工具(上)---yum和vim
【linux基础(五)】Linux中的开发工具(上)---yum和vim
|
19天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
75 0
|
1月前
|
Linux
Linux: yum查看、安装、删除软件包
Linux: yum查看、安装、删除软件包
32 0
|
1月前
|
存储 算法 Shell
【Shell 命令集合 备份压缩 】⭐⭐⭐Linux 解压缩 tar命令 使用指南
【Shell 命令集合 备份压缩 】⭐⭐⭐Linux 解压缩 tar命令 使用指南
29 0
|
2月前
|
Linux Shell
Linux:centos yum安装指令指南
Linux:centos yum安装指令指南
174 0
Linux:centos yum安装指令指南
|
4月前
|
Java Linux Docker
Linux【上手 01】MobaXterm+系统版本查看+hostname修改+hosts修改+yum源配置+jdk安装+docker部署使用(不断完善)
Linux【上手 01】MobaXterm+系统版本查看+hostname修改+hosts修改+yum源配置+jdk安装+docker部署使用(不断完善)
60 0