centos7优化

1配置网卡(修改ip地址、网关、DNS等)

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0                        #网卡名字
BOOTPROTO=static              #静态IP地址获取状态 如:DHCP表示自动获取IP地址
IPADDR=192.168.1.113            #IP地址
NETMASK=255.255.255.0            #子网掩码
ONBOOT=yes                     #引导时是否激活
GATEWAY=192.168.1.1
DNS=114.114.114.114

安装系统时修改网卡名称为eth0操作:
挂载镜像后,进入系统在第一个选项按tab键后输入参数,回车(修改网卡名称为eth0)
输入net.ifnames=0 biosdevname=0 #net前面有个空格
此外:此操作也可以在安装完系统后再修改,效果是一样的,具体是在 /etc/sysconfig/grub文件中添加了内容。

2.设置主机名

vi /etc/hostname

3.安装基础包

yum -y install gcc glibc gcc-c++ make net-tools screen vim lrzsz tree dos2unix lsof tcpdump bash-completion wget ntp

4.添加epel源

cd /etc/repos.d 
wget https://mirrors.aliyun.com/repo/epel-7.repo

5.修改yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clearn all       #清理yum缓存
yum makecache        #重建缓存
yum update           #更新源文件

6.关闭防火墙和selinux

关闭防火墙

systemctl disable firewalld
systemctl stop firewalld 

关闭selinux

vim /etc/sysconfig/selinux
将SELINUX=enforcing 改为 SELINUX=disabled
重启服务reboot

或者:

sed -i 's#SELINUX=disabled#SELINUX=enforcing#g' /etc/sysconfig/selinux

7.定时自动更新服务器时间

同步公有时间服务器,可搭配任务计划,阿里云的时间服务器ntp.aliyun.com

yum -y install ntp
ntpdate asia.pool.ntp.org
time.nist.gov
time.nuri.net
ntpdate asia.pool.ntp.org 或者 ntp.aliyun.com

注意;如果出现ntpdate[24325]: the NTP socket is in use, exiting,需要systemctl stop ntpd.service停止,然后同步,之后再启动,阿里云服务器默认同步阿里云时间服务器

8.授权普通用户sudo管理

centos7系统需要下载安装sudo命令包

yum install sudo 

【具体步骤;】https://blog.csdn.net/markximo/article/details/81737692

9.查看开机启动的服务

systemctl list-unit-files|grep enabled       #此命令查看开机启动的服务

10.常用快捷键

ctrl+A 光标跳最前
ctrl+E 光标跳最后
ctrl+U 删除光标前所有字符
ctrl+K 删除光标后所有字符
ctrl+R 搜索关键字相关命令历史
ctrl+L 清屏(或clear命令)

[参考链接:]
https://blog.51cto.com/8593714/2176406?source=dra
https://www.cnblogs.com/jokerbj/p/9133093.html
https://www.cnblogs.com/jokerbj/p/9117384.html
https://www.cnblogs.com/blog-tim/p/10075752.html

你可能感兴趣的:(centos7优化)