1.基本操作一:主機名
# centos7有一個新的修改主機名的命令hostnamectl hostnamectl set-hostname --static www.node1.com # 有些命令的參數可以自動補全,如果不能補全,則安裝下面的命令 yum -y install bash-completion
2.基本操作二:關閉iptables
# 查看firewalld服務的狀態,active是啟動狀態,inactive是關閉狀態 systemctl status firewalld.service systemctl stop firewalld.service systemctl list-unit-files |grep firewalld # 查看firewalld是否開機自動啟動 systemctl disable firewalld.service # 類似以前的chkconfig xxx off
3.基本操作三:關閉selinux
# 改完后,在后面重啟系統生效 sed -i 7s/enforcing/disabled/ /etc/selinux/config
4.基本操作四:網絡配置
systemctl stop NetworkManager systemctl status NetworkManager systemctl disable NetworkManager vim /etc/sysconfig/network-scripts/ifcfg-enp2s0 # 網卡名如果不一樣,找到對應的文件就行 BOOTPROTO="static" NAME="enp2s0" DEVICE="enp2s0" ONBOOT="yes" IPADDR=192.168.254.10 NETMASK=255.255.255.0 GATEWAY=192.168.254.2 DNS1=192.168.254.2 DNS1=223.5.5.5 # network服務這里默認還是可以使用原來的管理方法 /etc/init.d/network restart chkconfig network on
5.基本操作五:yum配置
配置本地yum源 # 刪除了它所有的默認的配置(因為這些默認配置要連公網的源,速度太慢) rm -rf /etc/yum.repos.d/* mkdir /media/cdrom mount /dev/cdrom /media/cdrom # 自建本地yum源配置文件 vim /etc/yum.repos.d/local.repo [local] name=local baseurl=file:///media/cdrom enabled=1 gpgcheck=0 yum-config-manager --enable local # 也可以直接把上面的enabled改為1 yum repolist 配置可選163的centos源 配置方法兩種 a)直接公網連接網易163,優點:速度快,軟件包會定期更新 cd /etc/yum.repos.d/ wget http://mirrors.163.com/.help/CentOS7-Base-163.repo b)自己編寫 # vim /etc/yum.repos.d/cento163.repo [centos163] name=centos163 baseurl=http://mirrors.163.com/centos/7.3.1611/os/x86_64 enabled=1 gpgcheck=0 配置可選epel源 配置方法兩種 a)直接公網連接epel,優點:速度快,軟件包會定期更新 # 此版本信息會隨時間推移而變化 wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm rpm -ivh epel-release-7-10.noarch.rpm b)自己編寫 vim /etc/yum.repos.d/epel.repo [epel] name=epel baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64 enabled=1 gpgcheck=0 配置完上面三個yum后 yum clean all yum makecache fast
6.基本操作六:輸入法配置(有需要再研究)
7.基本操作七:時間同步
yum -y install ntp ntpdate vim /etc/ntp.conf # 確認配置文件里有下列的時間同步源 server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server 3.rhel.pool.ntp.org iburst systemctl enable ntpd # 設置開機自動啟動ntpd systemctl start ntpd # 立即啟動ntpd服務 ntpdate 0.rhel.pool.ntp.org # 如果還沒有同步成功,可以用此命令手動同步一下 # 設置默認啟動級別為圖形模式(相當於以前的5級別) systemctl get-default # 查看當前的運行模式 systemctl set-default graphical.target # 設置圖形模式為默認模式