Centos7安装完成后一些基本操作
1.基本操作一:主机名
|
1
2
3
4
|
# centos7有一个新的修改主机名的命令hostnamectlhostnamectl set-hostname --static www.node1.com# 有些命令的参数可以自动补全,如果不能补全,则安装下面的命令yum -y install bash-completion |
2.基本操作二:关闭iptables
|
1
2
3
4
5
|
# 查看firewalld服务的状态,active是启动状态,inactive是关闭状态systemctl status firewalld.servicesystemctl stop firewalld.servicesystemctl list-unit-files |grep firewalld # 查看firewalld是否开机自动启动systemctl disable firewalld.service # 类似以前的chkconfig xxx off |
3.基本操作三:关闭selinux
|
1
2
|
# 改完后,在后面重启系统生效sed -i 7s/enforcing/disabled/ /etc/selinux/config |
4.基本操作四:网络配置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
systemctl stop NetworkManagersystemctl status NetworkManagersystemctl disable NetworkManagervim /etc/sysconfig/network-scripts/ifcfg-enp2s0 # 网卡名如果不一样,找到对应的文件就行BOOTPROTO="static"NAME="enp2s0"DEVICE="enp2s0"ONBOOT="yes"IPADDR=192.168.254.10NETMASK=255.255.255.0GATEWAY=192.168.254.2DNS1=192.168.254.2DNS1=223.5.5.5# network服务这里默认还是可以使用原来的管理方法/etc/init.d/network restartchkconfig network on |
5.基本操作五:yum配置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
配置本地yum源# 删除了它所有的默认的配置(因为这些默认配置要连公网的源,速度太慢)rm -rf /etc/yum.repos.d/*mkdir /media/cdrommount /dev/cdrom /media/cdrom# 自建本地yum源配置文件vim /etc/yum.repos.d/local.repo[local]name=localbaseurl=file:///media/cdromenabled=1gpgcheck=0yum-config-manager --enable local # 也可以直接把上面的enabled改为1yum repolist配置可选163的centos源配置方法两种a)直接公网连接网易163,优点:速度快,软件包会定期更新cd /etc/yum.repos.d/wget http://mirrors.163.com/.help/CentOS7-Base-163.repob)自己编写# vim /etc/yum.repos.d/cento163.repo[centos163]name=centos163baseurl=http://mirrors.163.com/centos/7.3.1611/os/x86_64enabled=1gpgcheck=0配置可选epel源配置方法两种a)直接公网连接epel,优点:速度快,软件包会定期更新# 此版本信息会随时间推移而变化wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpmrpm -ivh epel-release-7-10.noarch.rpmb)自己编写vim /etc/yum.repos.d/epel.repo[epel]name=epelbaseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64enabled=1gpgcheck=0配置完上面三个yum后yum clean allyum makecache fast |
6.基本操作六:输入法配置(有需要再研究)
7.基本操作七:时间同步
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
yum -y install ntp ntpdatevim /etc/ntp.conf# 确认配置文件里有下列的时间同步源server 0.rhel.pool.ntp.org iburstserver 1.rhel.pool.ntp.org iburstserver 2.rhel.pool.ntp.org iburstserver 3.rhel.pool.ntp.org iburstsystemctl enable ntpd # 设置开机自动启动ntpdsystemctl start ntpd # 立即启动ntpd服务ntpdate 0.rhel.pool.ntp.org # 如果还没有同步成功,可以用此命令手动同步一下# 设置默认启动级别为图形模式(相当于以前的5级别)systemctl get-default # 查看当前的运行模式systemctl set-default graphical.target # 设置图形模式为默认模式 |

浙公网安备 33010602011771号