Linux学习笔记

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章