命令自动补齐
yum install bash-completion -y
关闭防火墙
#禁用firewalld
systemctl stop firewalld && systemctl disable firewalld && setenforce 0
#禁用selinux 把 enforcing 改成disabled
vim /etc/selinux/config
SELINUX=disabled
#修改防火墙规则,最后添加(可不做)
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
查看所有端口
netstat -ntlp
ssh远程登陆慢
#在sshd_config文件中修改以下两个设置为no(如果被注释了记得取消注释)
GSSAPIAuthentication no
UseDNS no
#重启服务
systemctl restart sshd
使用阿里云镜像
#备份最初的镜像
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清理缓存
yum clean all
重新生成缓存
yum makecache
centos7 优先是使用ipv4
#文件默认不存在,需要自己创建
vim /etc/gai.conf
precedence ::ffff:0:0/96 100
重启 restart
查看命令用哪个包可以安装(以ifconfig为例子)
yum provides ifconfig
虚拟机时间校准
#设置一个定时任务
vim ntpdate.cron
#内容是:(一分钟刷新一下时间)
*/1 * * * * ntpdate time.windows.com
#执行定时任务
crontab ntpdate.cron
#查看定时任务
crontab -l