系统安装初始化

Posted fourw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了系统安装初始化相关的知识,希望对你有一定的参考价值。

#修改主机名
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

以上是关于系统安装初始化的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7.5 系统安装与初始化配置

①操作系统安装流程及初始化规范

操作系统安装及初始化规范

一:Greenplum5.10.2 生产环境安装配置 (系统初始化安装准备)

树莓派3B+ 系统安装+环境初始化

安装Linux系统与常见命令