天天看點

Centos7安裝完成後一些基本操作

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  # 設定圖形模式為預設模式