0%

CentOS7最小安装后配置

1.开启所有网卡

find /etc/sysconfig/network-scripts/ -type f -path '*/ifcfg-*' | xargs sed -i 's/ONBOOT.*/ONBOOT=yes/g' && systemctl restart network

2.设置镜像源并更新

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache

3.安装常用软件

yum install -y \
wget lrzsz zip unzip p7zip screen vim ntpdate yum-utils bash-completion net-tools bind-utils lsof telnet whois traceroute \
fuse ntfs-3g \
http://download1.rpmfusion.org/free/el/updates/7/x86_64/f/fuse-exfat-1.3.0-1.el7.x86_64.rpm \
http://download1.rpmfusion.org/free/el/updates/7/x86_64/e/exfat-utils-1.3.0-1.el7.x86_64.rpm

4.开机界面显示 IP 地址

cat >>/etc/rc.d/rc.local<<'EOF'

# 开机界面显示 IP 地址
cp -rf /etc/issue.net /etc/issue
echo Server IP:`hostname -I` >> /etc/issue
echo "" >> /etc/issue
EOF
chmod +x /etc/rc.d/rc.local

5.配置同步时间

cat >>/etc/rc.d/rc.local<<'EOF'

# 同步时间
/sbin/ntpdate -u ntp.aliyun.com >/dev/null &
EOF
chmod +x /etc/rc.d/rc.local

6.设置别名

cat >>~/.bashrc<<'EOF'
alias cp='cp'
alias mv='mv'
alias rm='rm'
alias ll='ls -al --color=auto --time-style=long-iso'
EOF

100.清理临时数据

cp -rf /etc/issue.net /etc/issue
#rm -rf /var/cache/*
echo >/var/log/btmp
echo >/var/log/wtmp
history -c