码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS7.5模板机配置

时间:2019-11-04 13:39:27      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:grub   design   profile   临时   运用   min   type   epel   绿色   

CentOS7.5模板机配置

标签(空格分隔): linux学习知识整理
Mr.Wei‘s notes!
人一定要有梦想,没有梦想那根咸鱼有什么区别;
即便自己成为了一条咸鱼,也要成为咸鱼里最咸的那一条。 --Mr.Wei


关闭selinux

    [root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    [root@localhost ~]# sed -i 's/vmlinuz.*/& selinux=0/g' /boot/grub2/grub.cfg

关闭防火墙

    [root@localhost ~]# systemctl disable firewalld.service
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    [root@localhost ~]# systemctl disable iptables-services 
    Failed to execute operation: No such file or directory

优化SSH(禁止DNS反向解析

    [root@localhost ~]# echo "UseDNS no" >> /etc/ssh/sshd_config 
    [root@localhost ~]# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

网卡ens32配置

   #PROXY_METHOD="none" 
   #BROWSER_ONLY="no" 
   #DEFROUTE="yes" 
   #IPV4_FAILURE_FATAL="no" 
   #IPV6INIT="yes" 
   #IPV6_AUTOCONF="yes" 
   #IPV6_DEFROUTE="yes" 
   #IPV6_FAILURE_FATAL="no"
   #IPV6_ADDR_GEN_MODE="stable-privacy"
   #UUID="a6eba8a3-057d-4655-9bd1-b6f6f90c2197" 
   NAME="ens32"
   TYPE="Ethernet" 
   DEVICE="ens32" 
   ONBOOT="yes" 
   BOOTPROTO="none" 
   IPADDR="192.168.146.100" 
   NETMASK="255.255.255.0" 
   GATEWAY="192.168.146.2"
   DNS1="192.168.146.2"

配置yum库,运用脚本一件配置yum库

    #!/bin/bash #designed by WeiLei
    #test if the network is working 
    yum_install()
    {
    umount /dev/sr0 &>/dev/null
    rm -rf /etc/yum.repos.d/* &>/dev/null
    [ -d /media/cdrom ] || mkdir -p /media/cdrom
    mount /dev/sr0 /media/cdrom &>/dev/null 
    if [ $? -ne 0 ];then
    echo "please check your cdrom status"
    exit 
fi
[ -d /etc/yum.repos.d ] || mkdir -p /etc/yum.repos.d 
cd /etc/yum.repos.d 
mv * /tmp/ &>/dev/null
cat > /etc/yum.repos.d/local.repo << FOF 
[local]
name=local 
baseurl=file:///media/cdrom 
gpgcheak=0
enabled=1 
FOF
yum -y clean all &>/dev/null 
yum makecache &>/dev/null 
which wget &>/dev/null
if [ $? -ne 0 ];then
    yum -y install wget &>/dev/null
    fi
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo 
    wget -O /etc/yum.repos.d/163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
    yum -y clean all
    yum makecache &>/dev/null
        }
    }
    yum_install

还原rc.local执行脚本的能力

[root@localhost ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 Apr 11 2018 /etc/rc.d/rc.local      
[root@localhost ~]# chmod +x /etc/rc.d/rc.local 
[root@localhost ~]# ll /etc/rc.d/rc.local
   -rwxr-xr-x. 1 root root 473 Apr 11 2018 /etc/rc.d/rc.local
#在/etc/rc.d/rc.local中加入开机自动挂载
[root@localhost ~]# vim /etc/rc.d/rc.local 
#!/bin/bash
touch /var/lock/subsys/local 
mount /dev/sr0 /media/cdrom

基本命令的安装

[root@localhost ~]#yum y install net-tools vim tree htop iotop iftop lrzsz sl wget unzip telnet nmap nc psmisc dos2unix bash- completion sysstat rsync nfs-utils gcc gcc-c++ make 

临时修改命令提示符为黄色

[root@localhost ~]# vim /etc/profile
export PS1='\[\e[33;40m\][\u@\h \W]# \[\e[0m\]' 
[root@localhost ~]# source /etc/profile
颜色 黑色 红色 绿色 黄色 蓝色 紫红色 青蓝色 白色
F 30 31 32 33 34 35 36 37
B 40 41 42 43 44 45 46 47
在PS1中设置字符颜色的格式为:\[\e[F;Bm\]\[\e[0m\],其中“F“为字体颜色,编号为30-37,“B”为背景颜色,编号为40-47,\[\e[0m\] 作为颜色设定的结束。

永久修改命令提示符的颜色

[root@localhost ~]# vim /etc/profile 
[root@localhost ~]# ls -a
.   .bash_history  .bash_profile .cache .pki    viminfo
.. .bash_logout .bashrc .cshrc tcshrc
[root@localhost ~]# vim .bashrc
加入:export PS1='\[\e[33;40m\][\u@\h \W]# \[\e[0m\]'
[root@localhost ~]# source .bashrc

CentOS7.5模板机配置

标签:grub   design   profile   临时   运用   min   type   epel   绿色   

原文地址:https://www.cnblogs.com/Mr-Wei/p/11791437.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!