N27网络班第6周作业

1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#;
:%s@^[[:space:]]\+@#&@g
2、复制/boot/grub/grub.conf 至/tmp目录中,删除/tmp/grub.conf文件中的行首的空白字符
:%s@^[[:space:]]\+@@g
3、删除/tmp/rc.sysinit文件中的以#开头,且后面跟了至少一个空白的行行的#和空白字符
%s@^#[[:space:]]\+@@g
4、为/tmp/grub.conf文件中前三行首加#号
:1,3s@^.*@#&@
5、将/etc/yum.repos.d/Centos-Media.repo文件中所有的enabled=0或gpgcheck=0的最后的0修改为1
:%s@\(enabled\|gpgcheck\)=0@\1=1@g
6、每4小时执行一次对/etc目录的备份,备份至/backup目录中,保存的目录名为形如etc-201504020202
mkdir /backup
crontab -e创建任务
        -l 列出任务
        -r 移除所有任务
在crontab -e 中必须打绝对路径
[root@localhost ~]# which cp
0 */4 * * * /bin/cp -a /etc/ /backup/etc-`date +%Y%m%d%H%M`
7、每周2,4,6备份/var/log/message文件/backup/messages_logs/目录中,保存的问价名形如messages-20150402
mkdir /backup/message_logs/
0 0 * * 2,4,6 /bin/cp -a /var/log/messages/ /backup/message_logs/messages-`date +%Y%m%d`
8、每天每两个小时取当前系统/proc/meminfo文件中所有以S开头的信息至/status/memory.txt文件中
0 */2 * * * /bin/grep '^S' /proc/meminfo > /stats/memory.txt
9、工作日的工作时间内,每两小时执行一次echo “howdy”
0 8-16/2 * * 1-5 /bin/echo "howdy"
10、创建目录/tmp/testdir-当前日期时间
[root@localhost ~]# vim testdir.sh
[root@localhost ~]# bash testdir.sh 
[root@localhost ~]# echo $?
0
[root@localhost ~]# ls /tmp/testdir-201709021117/
脚本
#!/bin/bash
mkdir /tmp/testdir-`date +%Y%m%d%H%M`
11、在此目录创建100个空文件:file1-100
[root@localhost tmp]# mkdir test
[root@localhost tmp]# cd test
[root@localhost test]# vim filecreate.sh
[root@localhost test]# bash filecreate.sh 
[root@localhost test]# ll


脚本

#!/bin/bash
#
for i in {1..100};do
        touch file$i
done
12、显示/etc/passwd文件中位于第偶数行的用户的用户名
[root@localhost test]# vim abc.sh
[root@localhost test]# bash abc.sh
脚本
#!/bin/bash
#
sed -n 'n;p' /etc/passwd | cut -d':' -f1

原创文章,作者:N27_flypig,如若转载,请注明出处:http://www.178linux.com/86159

(0)
N27_flypigN27_flypig
上一篇 2017-09-03 21:11
下一篇 2017-09-03 22:24

相关推荐

  • 定制SecureCRT配色

    定制SecureCRT配色 SecureCRT默认的配色方案不怎么喜欢,结合网上其他人的总结+自己的探索,总结怎样定制自己的配色。配出自己喜欢的界面,还是会很有成就感的。 使用SecureCRT自带主题 效果图 图中个文件的类型: compress.tar.gz 压缩文件 directory 目录 file.txt 普通文件&n…

    Linux干货 2017-09-03
  • shell脚本编程基础

    变量的种类 ——–shell—–父shell                      &…

    Linux干货 2017-04-16
  • nginx及I/O介绍原理

    上课笔记

    2018-03-12
  • bond的常见使用方式和问题

    bond的简单建立于事项

    2017-09-09
  • LVS负载均衡实战演练

    LVS负载均衡实战之lvs-nat模型 1.准备好机器,配置好时间同步,配置号网络,主机名 172.16.251.91 client [桥接] [网关为172.16.251.90] #lvs负载均衡两块网卡 172.16.251.90  lvs [网卡1] [桥接] 192.168.42.150  lvs [网卡2] [VMnet8] 192.168.42.…

    Linux干货 2017-06-22
  • 命令组合实战

    1 列出/etc/下以。conf结尾的文件 [redsun@jiange root]$ ls  /etc/*.conf | tr 'a-z' 'A-Z'  | sed 's/ETC/etc/' > /tmp/etc.conf [redsun@jiange root]$ mo…

    Linux干货 2016-11-13

评论列表(1条)

  • 马哥教育
    马哥教育 2017-10-10 13:11

    一开始的内容比较基础,但是非常重要,这篇博客整理的很不错,再接再励。