GraphQL vim复制 image rest listview requirejs rss Pure CSS vue社区 linux内存管理 华为路由器ipv6配置 mysql重新初始化 oracle删除字段 mysql统计数量 mysql时间戳转日期 python运行环境 java接口实现 java获取当前线程 java循环list linux安装 linux用户 python网站开发实例 h5模板 tabletpc 如何强行退出小米账号 飞猪ip 思源黑体cn groupy 福昕阅读器绿色版 临时会话 快打旋风3出招表 java字符串截取 骰子动态图 司司网吧 js正则匹配字符串 俄罗斯方块代码 方正兰亭粗黑字体下载 bilibili硬币 苹果手机怎么微信双开 视频旋转软件
当前位置: 首页 > 学习教程  > 编程语言

从零开始的linux学习(3)

2020/8/11 19:43:39 文章标签:

B

bzip2
bunzip2
bzcat

C

compress
cpio

F

find

G

gunzip
gzip

L

ldd
locate

S

split

T

tar

U

unxz
unzip
updatedb

X

xargs
xzcat

Z

zcat
zip

初始化脚本(alpha 0.1)

#!/bin/bash
#
#********************************************************************
#Author:		    rzx
#QQ: 			    970707452
#Date: 			    2020-05-05
#FileName:		    reset_pro.sh
#URL: 			    https://www.cnblogs.com/rzx-006/
#Description:		The test script
#Copyright (C): 	2020 All rights reserved
#********************************************************************
source /etc/init.d/functions

network () {
    mkdir -p /etc/sysconfig/network-scripts/bak
    mv /etc/sysconfig/network-scripts/* /etc/sysconfig/network-scripts/bak
    cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
    DEVICE=eth0
    NAME=eth0
    IPADDR=10.0.0.88
    PREFIX=24
    GATEWAY=10.0.0.2
    DNS1=180.76.76.76
EOF
}

firewall () {
    systemctl disable firewalld --now || chkconfig iptables off;service iptables stop
}

selinux () {
    sed -ri.bak 's/^(SELINUX=).*/\1disabled/' /etc/selinux/config
}

vimrc () {
    if ! [ -e ~/.vimrc ]; then
    cat > ~/.vimrc <<EOF
    set ts=4
    set expandtab
    set ignorecase
    set cursorline
    set autoindent
    autocmd BufNewFile *.sh exec ":call SetTitle()"
    func SetTitle()
    if expand("%:e") == 'sh'
    call setline(1,"#!/bin/bash") 
    call setline(2,"#") 
    call setline(3,"#********************************************************************")         
    call setline(4,"#Author:            rzx") 
    call setline(5,"#QQ:                970707452") 
    call setline(6,"#Date:              ".strftime("%Y-%m-%d"))
    call setline(7,"#FileName:         ".expand("%"))
    call setline(8,"#URL:               https://www.cnblogs.com/rzx-006/")
    call setline(9,"#Description:      The test script") 
    call setline(10,"#Copyright (C):    ".strftime("%Y")." All rights reserved")
    call setline(11,"#********************************************************************") 
    call setline(12,". /data/color.sh")
    endif
    endfunc
    autocmd BufNewFile * normal G
EOF
    fi
}

packages () {
    yum -y install gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree tmux lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages
}

yumrepo () {
mkdir -p /etc/yum.repos.d/bak

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

if [ `sed -nr 's/.*release ([0-9])\..*/\1/p' /etc/redhat-release` -eq 6 ]; then                                                                                                                                                                   
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
elif [ `sed -nr 's/.*release ([0-9])\..*/\1/p' /etc/redhat-release` -eq 7 ]; then
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
elif [ `sed -nr 's/.*release ([0-9])\..*/\1/p' /etc/redhat-release` -eq 8 ]; then
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
fi
}

chPS1 () {
    echo 'PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$"' >> /etc/profile.d/env.sh
}

aliases () {
    if ! cat ~/.bashrc | grep ^alias.*scripts\'$ &> /dev/null; then
        echo alias cdnet=\'cd /etc/sysconfig/network-scripts\' >> ~/.bashrc
    fi

    if ! cat ~/.bashrc | grep ^alias.*vim\'$ &> /dev/null; then
        echo alias vi=\'vim\' >> ~/.bashrc
    fi
    if ! cat ~/.bashrc | grep 'echo - - - > /sys/class/scsi_host/host0/scan;' &> /dev/null;then
        echo alias scandisk=\'echo - - - \> /sys/class/scsi_host/host0/scan\;echo - - - \> /sys/class/scsi_host/host1/scan\;echo - - - \> /sys/class/scsi_host/host2/scan\' >> ~/.bashrc
    fi
}

networkcard () {
    cat /etc/default/grub | grep net.ifname | sed -ri.bak 's/^(GRUB_CMDLINE_LINUX=.*)"/\1 net.ifnames=0\"/' /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg && reboot
}
while :;do
    echo '*****************************************************************************************'
    echo '*                                                                                       *'
    echo '*                                                                                       *'
    echo '*           1.修改网卡名称         2.修改IP             3.配置yum仓库                   *'
    echo '*           (会重启服务器)                                                              *'
    echo '*                                                                                       *'
    echo '*           4.安装常用软件包       5.修改PS1变量        6.配置vimrc                     *'
    echo '*                                                                                       *'
    echo '*                                                                                       *'
    echo '*           7.关闭防火墙           8.关闭selinux        9.设置别名         0.退出       *'
    echo '*                                                                                       *'
    echo '*                                                                                       *'
    echo '*****************************************************************************************'

    read -p "输入你想执行的操作:" NUM
    case $NUM in
    0)
    exit
    ;;
    1)
    if networkcard;then
        action "网卡名修改成功"
    fi
    ;;
    2)
    if network;then
        action "IP修改成功"
    fi
    ;;
    3)
    if yumrepo;then
        action "yum仓库配置成功"
    fi
    ;;
    4)
    if packages;then
        action "常用软件包安装成功"
    fi
    ;;
    5)
    if chPS1;then
        action "PS1变量修改成功"
    fi
    ;;
    6)
    if vimrc;then
        action "vimrc配置成功"
    fi
    ;;
    7)
    if firewall;then
        action "防火墙已关闭"
    fi
    ;;
    8)
    if selinux;then
        action "selinux已关闭"
    fi
    ;;
    9)
    if aliases;then
        action "别名已配置"
    fi
    ;;
    esac
    done




本文链接: http://www.dtmao.cc/news_show_100160.shtml

附件下载

相关教程

    暂无相关的数据...

共有条评论 网友评论

验证码: 看不清楚?