1、每12小時備份並壓縮/etc/目錄至/backup目錄中,保存文件名稱格式爲,"etc-年-月-日-時-分.tar.gz"
-
/12 /usr/bin/cp /etc /backup/etc-$(‘date +%Y-%m-%e-%H-%M’)
2、rpm包管理功能總結以及實例應用演示。
https://blog.51cto.com/13369003/2424347
3、yum的配置和使用總結以及yum私有倉庫的創建。
https://blog.51cto.com/13369003/2424350
4、寫一個腳本實現列出以下菜單給用戶:
(1)disk:show disk info信息
(2)mem: show memory info信息
(3)cpu: show cpu info信息
(*)quit[root@gumt data]#cat test.sh
#!/bin/bash
#****
#Author: Gumt
#Mail: [email protected]
#Date: 2019-07-28
#FileName: test.sh
#Version: V1.0
#Description: The test script
#Copyright (C): 2019 All rights reserved
#****cat<<EOF (1)disk:show disk info信息 (2)mem:show memory info信息 (3)cpu:show cpu info信息 (*)quit EOF read -p "Your chioce: " option if [[ "$option" == "disk" ]]; then fdisk -l /dev/[sh]d[a-z] elif [[ "$option" == "mem" ]]; then free -m elif [[ "$option" == "cpu" ]]; then lscpu else echo "Unknow option." exit 3 fi
5、sed用法總結並結合實例演示
https://blog.51cto.com/13369003/2424321
6、 用bash實現統計訪問日誌文件中狀態碼大於等於400的IP數量並排序
[root@gumt data]#cat ip_sort.sh
#!/bin/bash
#********************************************************************
#Author: Gumt
#Mail: [email protected]
#Date: 2019-07-28
#FileName: ip_sort.sh
#Version: V1.0
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
nginx_log='/usr/local/nginx/logs/mynginx.log'
code_400_num=$(grep -o '[4|5][0-9][0-9]' ${nginx_log} | wc -l)
code_400_sort=$(grep '[4|5][0-9][0-9]' ${nginx_log} | sort)
echo $code_400_num
echo $code_400_sort
7、 使用自制的yum源安裝ftp、openssh、curl、wget、tcpdump等軟件包
[root@centos-7 ~]# mount -r /dev/cdrom /mnt/cdrom
[root@centos-7 ~]# cat /etc/yum.repos.d/base.repo
[base]
name=base1
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
[root@gumt ~]#yum -y install ftp
[root@centos-7 ~]# yum -y install openssh
[root@centos-7 ~]# yum -y install curl
[root@centos-7 ~]# yum -y install wget
[root@centos-7 ~]# yum -y install tcpdump