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: 1902924129@qq.com
    #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:              1902924129@qq.com
        #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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值