Linux 习题练习-02(grep、find命令、yum源配置)

简介: Linux 习题练习-02(grep、find命令、yum源配置)

Liunx 习题练习02

  1. 返回initial-setup-ks.cfg文件中包含字符串 'boot' 的行数

    [root@localhost ~]# grep 'boot' /root/initial-setup-ks.cfg | wc -l
    [root@localhost ~]# grep -c 'boot' /root/initial-setup-ks.cfg 
    
  2. 返回initial-setup-ks.cfg文件中包含字符串 'boot' 的行与行号

    [root@localhost ~]# grep -n 'boot' /root/initial-setup-ks.cfg 
    
  3. 执行ps -aux命令,将文件内容保存到 /root/ps.log 中,查找该文件中包含1774或1775字符串的行

    [root@localhost ~]# ps -aux > /root/ps.log 
    [root@localhost ~]# grep '177[45]' ps.log 
    
  4. 在上述文件中查找包含一串包含四位数的字符串,并且这个字符串最后一个数字为2

    [root@localhost ~]# grep '[0-9][0-9][0-9]2' /root/ps.log 
    
    [root@localhost ~]# grep '[0-9][0-9][0-9]...2' /root/ps.log 
    
    [root@localhost ~]# grep '[0-9][0-9][0-9]...[Ss]' /root/ps.log 
    
  5. 在当前目录下查找除目录以外的所有类型的文件

    [root@localhost ~]# find . ! -type d
    
  6. 找出所有用户ruochen 拥有的文件,并且把它们拷贝到/root/finder怒骂中

    [root@localhost yum.repos.d]# find / -user harry -type f -exec cp {} /root/finder \; 2> /dev/null
    
  7. 查找文件更改时间比文件a.txt 新但比b.txt 文件旧的文件

    • -newr
    • find / - newer a.txt ! -newer b.txt

      [root@localhost ~]# find / -newer initial-setup-ks.cfg ! -newer ps.log -exec ls -lh {} \;

  8. 统计当前系统中一共有多少账户

    • /etc/passwd
    • wc -l /etc/passwd

      [root@localhost ~]# wc -l /etc/passwd
      39 /etc/passwd

  9. 配置本机yum 环境

    [root@localhost Desktop]# mkdir /mnt/cdrom
    [root@localhost Desktop]# mount /dev/sr0 /mnt/cdrom 
    [root@localhost yum]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# ls
    [root@localhost yum.repos.d]# rm -rf *
    [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
目录
相关文章
|
18天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
41 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
|
4天前
|
人工智能 数据可视化 Linux
【linux基础(五)】Linux中的开发工具(上)---yum和vim
【linux基础(五)】Linux中的开发工具(上)---yum和vim
|
15天前
|
Linux
Linux 指令|date|cal|find|grep|热键
Linux 指令|date|cal|find|grep|热键
|
18天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
75 0
|
1月前
|
Linux
Linux: yum查看、安装、删除软件包
Linux: yum查看、安装、删除软件包
32 0
|
7天前
|
机器学习/深度学习 缓存 监控
linux查看CPU、内存、网络、磁盘IO命令
`Linux`系统中,使用`top`命令查看CPU状态,要查看CPU详细信息,可利用`cat /proc/cpuinfo`相关命令。`free`命令用于查看内存使用情况。网络相关命令包括`ifconfig`(查看网卡状态)、`ifdown/ifup`(禁用/启用网卡)、`netstat`(列出网络连接,如`-tuln`组合)以及`nslookup`、`ping`、`telnet`、`traceroute`等。磁盘IO方面,`iostat`(如`-k -p ALL`)显示磁盘IO统计,`iotop`(如`-o -d 1`)则用于查看磁盘IO瓶颈。
|
1天前
|
Linux
【Linux】深入理解ls命令
【Linux】深入理解ls命令