美文网首页
linux作业5

linux作业5

作者: 绊倒铁盒_ddbb | 来源:发表于2019-12-25 12:58 被阅读0次

1、查找/etc目录下大于1M且类型为普通文件的所有文件

[root@localhost ~]# find /etc/ -type f  -size +1M
/etc/selinux/targeted/active/policy.kern
/etc/selinux/targeted/contexts/files/file_contexts.bin
/etc/selinux/targeted/policy/policy.31
/etc/udev/hwdb.bin
/etc/brltty/zh-tw.ctb
[root@localhost ~]# ll /etc/udev/hwdb.bin 
-r--r--r--. 1 root root 7916435 Dec 18 21:35 /etc/udev/hwdb.bin

2、打包/etc/目录下面所有conf结尾的文件,压缩包名称为当天的时间,并拷贝到/usr/local/src目录备份。

[root@localhost data]# ll
total 100
-rw-r--r--. 1 root root 101977 Dec 25 20:42 2019-12-25.tar.gz
[root@localhost data]# tar -czvf `date +%F`.tar.gz /etc/*.conf
[root@localhost data]# cp 2019-12-25.tar.gz /usr/local/src/
[root@localhost data]# ls /usr/local/src/
2019-12-25.tar.gz
[root@localhost data]# 

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@localhost data]# ifconfig | sed -rn 's/^[[:space:]]+inet[[:space:]]([0-9.]+).*$/\1/p'
192.168.80.11
127.0.0.1
192.168.122.1


4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@localhost data]# sed -r 's/^#[[:space:]]+(.*)$/\1/' /etc/fstab 

#
/etc/fstab
Created by anaconda on Wed Dec 18 21:09:21 2019
#
Accessible filesystems, by reference, are maintained under '/dev/disk'
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=a44aa5cc-a3af-43d4-9c7d-c403035d4ea9 /                       xfs     defaults        0 0
UUID=2998e3c4-91ec-4f14-b19e-52e1640f2780 /boot                   xfs     defaults        0 0
UUID=ad28f936-2450-4a37-8660-e97ca35380a1 /data                   xfs     defaults        0 0
UUID=eba4d637-f817-4e13-918d-f9f812022472 swap                    swap    defaults     

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@localhost data]# echo /etc/fstab | sed -r 's@^(/[[:alpha:]]+/)(.*)$@\1@'
/etc/
[root@localhost data]# echo /etc/fstab | sed -r 's@^(/[[:alpha:]]+/)(.*)$@\2@'
fstab
[root@localhost data]# 

相关文章

  • linux作业5

    1、查找/etc目录下大于1M且类型为普通文件的所有文件 2、打包/etc/目录下面所有conf结尾的文件,压缩包...

  • Linux019 生信人的linux考试题

    参考来源 生信人的linux考试linux作业 在任意文件夹下面创建形如 1/2/3/4/5/6/7/8/9 格式...

  • linux命令4-linux的应用

    linux的实战作业: 这个是linux分享课上的作业: 从git仓库https://github.com/ist...

  • 实战和解忧

    linux的实战作业: 这个是linux分享课上的作业: 从git仓库https://github.com/ist...

  • 【kernel exploit】CVE-2017-5123 nu

    影响版本:小于Linux v4.14-rc5。Linux v4.14-rc5 和 Linux v4.14.1已修补...

  • shell第4章进程和服务

    Linux中的进程: ps命令 ps -aux参数解释: Linux中的会话和作业: 中断进程: Linux中的日...

  • Linux 相关问题解答

    linux 相关问题 一 Linux 哲学思想 1.Linux 是怎样诞生的? linus 的大学作业 2.Lin...

  • Linux作业

    实验截图

  • Linux的cron程序

    文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Linux定时作业 在Linux...

  • 原创|Linux|Inst Mysql

    一、背景系统:CentOS7 Linux 64位目的:结束Linux 安装 Mysql 作业指导乱象版本:mysq...

网友评论

      本文标题:linux作业5

      本文链接:https://www.haomeiwen.com/subject/rvxcoctx.html