※修改主机名: centos5/6 1、/etc/sysconfig/network 2、修改hosts文件:/etc/hosts centos7 1、/etc/hostname,或者hostnamectl set-hostname newhostname 2、修改host文件 ※将网卡改为默认开机自动启动:

※同步服务器时间 centos 5/6 1、在/etc/ntp.conf里面加:server 170.18.0.1 iburst 2、service ntpd status &>/dev/null || service ntpd start &>/dev/null 3、设置开机启动:chkconfig ntpd on 4、同步时间:ntpdate 172.18.0.1 centos 7 1./etc/chrony.conf里面加server 172.18.0.1 iburst 2.systemctl status chronyd &>/dev/null || systemctl start chronyd &>/dev/null 3.设置开机启动:systemctl enable chronyd &>/dev/null 4.同步时间:ntpdate 172.18.0.1

※查看文件或者目录大小:du -sh 目录名/文件名

※新加硬盘df不显示,需要激活: echo ' - - - ' > /sys/class/scsi_host/host2/scan echo ' - - - ' > /sys/class/scsi_host/host0/scan echo ' - - - ' > /sys/class/scsi_host/host1/scan ※取passwd中用户名和bash一样的行:getent passwd|egrep "^([a-z]+):.*/\1$"

※echo centos| passwd --stdin luo>/dev/null

※Centos7配置网卡名为eth0 /etc/sysconfig/network-scripts/ifcfg-ens33(或则eth0) ONBOOT改为yes 1、在/etc/default/grub里面GRUB_CMDLINE后面加net.ifnames=0 或/boot/grub2/grub.cfg中第一个linux 16开头行尾net.ifnames=0 如果是dell服务器(rpm -qi biosdevname)需另外加biosdevname=0 2、执行命令:grub2-mkconfig -o /boot/grub2/grub.cfg 如果是efi的需要执行grub2-mkconfig -o /boot/grub2/efi grub.cfg 3、重启生效 ※Ubuntu配置网络 一、网卡名配置为eth0 1、在/etc/default/grub里面GRUB_CMDLINE后面加net.ifnames=0 2、执行命令:grub-mkconfig -o /boot/grub/grub.cfg 3、重启生效 二、配置动态ip

配置静态IP

※防火墙 iptables -vnL查看防火墙信息 iptables -F清空防火墙策略 Centos 6 关闭防火墙:service iptables stop 关闭防火墙下次开机不启动:chkconfig iptables off Centos 7 systemctl stop firewalld关闭防火墙 systemctl disable firewalld下次开机不启动防火墙

把某个IP加进防火墙:iptables -A INPUT -s 192.168.33.107 -j REJECT

※centos7设置光盘自动挂载: yum install autofs systemctl start autofs systemctl enable autofs ※关闭SElinux的步骤:/etc/selinux/config中SELINUX=disabled 批量关闭主机列表中的selinux: pssh -h /data/hostip.txt "sed -i.bak -r 's/^(SELINUX=).*/\1disabled/' /etc/selinux/config" ※关闭SSH反向解析: ###centos 6设置##### sed -r -i.bak -e "s@^#(UseDNS)@\1@" -e "s@^#(GSSAPIAuthentication)@\1@" /etc/ssh/sshd_config 关闭ssh反向解析,79行GSSAPIAuthentication yes改为no,去掉#号,115行#UserDNS no前的#号去掉 重启服务 service sshd restart centos7设置########## sed -r -i.bak -e 's@^(GSSAPIAuthentication )yes$@\1no@' -e 's@^#(UseDNS )yes$@\1no@' /etc/ssh/sshd_config 重启服务 systemctl restart sshd

※系统开机默认启动模式: centos6:cat /etc/inttab,改为3 centos7:systemctl set-default multi-user.target