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

系统安装初始化

时间:2019-09-21 13:11:22      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:netmask   LEDE   mit   同步时间   配置文件   rename   centos   top   shang   

#修改主机名
hostnamectl set-hostname xxxx.xxxx
#修改主机列表
cat <<EOF >> /etc/hosts
192.168.2.xxx xxxx.xxxx
192.168.2.xxx xxxx.xxxx
EOF
#修改IP地址
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-ens33
DEVICE=ens33
BOOTPROTO=static
IPADDR=192.168.x.x
GATEWAY=192.168.x.x
NETMASK=255.255.255.0
DNS1=192.168.x.x
ONBOOT=yes
EOF
systemctl restart network.service
#修改提示符颜色
echo "PS1=‘\[\e[1;32m\][\u@\h \w]\$ \[\e[0m\]‘" >> ~/.bashrc && . ~/.bashrc
#关闭防火墙
systemctl stop firewalld.service && systemctl disable firewalld.service
#临时关闭SELinux
setenforce 0 && sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
#字符编码设置
cat <<EOF > /etc/locale.conf
LANG="zh_CN.UTF-8"
EOF
#修改日志记录格式
sed -i "30s/^/#/" /etc/rsyslog.conf && sed -e ‘30a\$template CustomFormat,"%$NOW% %TIMESTAMP:8:15% %HOSTNAME% %syslogtag% %msg%\\n"‘ -e ‘31a\$ActionFileDefaultTemplate CustomFormat‘ /etc/rsyslog.conf && systemctl restart rsyslog
#安装相关应用
yum install -y wget bash-completion vim
#设置yum源
cd /etc/yum.repos.d/
rename repo repo.bak *
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-7.repo
#同步时间
yum -y install ntpdate && timedatectl set-timezone Asia/Shanghai && ntpdate ntp2.aliyun.com && hwclock --systohc
#修改配置文件
sed -i "s/^HISTSIZE/#HISTSIZE/" /etc/profile
cat <<EOF >> /etc/profile
PS1=‘\[\e[1;32m\][\u@\h \w]\$ \[\e[0m\]‘
alias vi="vim"
HISTSIZE=10000
HISTTIMEFORMAT="%F %T "
EOF
source /etc/profile
#ssh配置
sed -i "s/PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config && systemctl restart sshd

系统安装初始化

标签:netmask   LEDE   mit   同步时间   配置文件   rename   centos   top   shang   

原文地址:https://www.cnblogs.com/fourw/p/11562215.html

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