启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?
查看已启动的服务列表:systemctl list-unit-files|grep enabled
[root@linux /]# systemctl list-unit-files|grep enabled
cups.path enabled
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled
firewalld.service enabled
…
[root@linux /]# systemctl stop firewalld.service
[root@linux /]# systemctl disable firewalld.service
[root@linux /]# systemctl status firewalld.service
检查yum源:rpm -qa | grep yum
删除原有的yum源: rpm -qa|grep yum|xargs rpm -e --nodeps
由于网易和CentOS现在不能使用了,故使用阿里云提供的资源
阿里云网络源地址:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
找到以下三个rpm文件
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
在终端中通过wget指令下载(确保联网,可通过ping一下百度服务器看看联网没,Crtl+c终止命令)
为了防止几个包安装时有互相依赖,使用 rpm -ivh yum-* 命令一次性安装三个包
[root@linux su1573]# rpm -ivh yum-*
使用第一条命令检查yum是否安装成功:
[root@linux su1573]# rpm -qa |grep yum
在/etc目录下重命名备份原来的repo:mv yum.repos.d yum.repos.d.backup
[root@linux su1573]# cd /etc
[root@linux etc]# mv yum.repos.d yum.repos.d.backup
再建一个新的yum.repos.d目录(确保在/etc目录下)
[root@linux etc]# mkdir yum.repos.d
下载一个CentOS的repo(我们可以在aliyun镜像站的centos使用帮助中下载学习)
[root@linux su1573]# cd /etc/yum.repos.d
[root@linux yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
通过vim打开并编辑repo
[root@linux yum.repos.d]# vim CentOS7-Base-163.repo
将文件中所有的$releasever全部替换成版本号–>7
shift+: 编辑 输入下面的指令,进行全部替换
%s/$releasever/7/g
shift+: wq,保存退出
最后清理缓存
[root@linux yum.repos.d]# yum clean all ##清理缓存
[root@linux yum.repos.d]# yum makecache ##重新生成缓存
使用yum repolist all查看是否成功
[root@linux yum.repos.d]# yum repolist all
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
--2019-01-30 15:37:43-- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 123.125.7.216, 123.125.7.221, 123.125.7.218, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|123.125.7.216|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1296152 (1.2M) [application/x-redhat-package-manager]
正在保存至: “yum-3.4.3-161.el7.centos.noarch.rpm”
100%[======================================>] 1,296,152 21.5KB/s 用时 64s d
2019-01-30 15:38:47 (19.8 KB/s) - 已保存 “yum-3.4.3-161.el7.centos.noarch.rpm” [1296152/1296152])
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
--2019-01-30 15:40:36-- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.63.56.211, 111.63.56.216, 111.63.56.209, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.63.56.211|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:28348 (28K) [application/x-redhat-package-manager]
正在保存至: “yum-metadata-parser-1.1.4-10.el7.x86_64.rpm”
100%[======================================>] 28,348 --.-K/s 用时 0s
2019-01-30 15:40:42 (128 MB/s) - 已保存 “yum-metadata-parser-1.1.4-10.el7.x86_64.rpm” [28348/28348])
[root@linux su1573]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
--2019-01-30 15:40:54-- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 123.125.7.220, 123.125.7.216, 123.125.7.219, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|123.125.7.220|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:34500 (34K) [application/x-redhat-package-manager]
正在保存至: “yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm”
100%[======================================>] 34,500 15.6KB/s 用时 2.2s
2019-01-30 15:40:57 (15.6 KB/s) - 已保存 “yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm” [34500/34500])
[root@linux su1573]# rpm -ivh yum-*
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
2:yum-plugin-fastestmirror-1.1.31-5################################# [ 67%]
3:yum-3.4.3-161.el7.centos ################################# [100%]
[root@linux su1573]# rpm -qa |grep yum
yum-3.4.3-161.el7.centos.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-50.el7.noarch
[root@linux su1573]# cd /etc/
[root@linux etc]# cd yum.repos.d
[root@linux yum.repos.d]# ll
总用量 8
-rwxrwxrwx. 1 su1573 su1573 1539 1月 30 15:21 CentOS7-Base-163.repo
-rw-r--r--. 1 root root 358 1月 30 15:19 redhat.repo
[root@linux yum.repos.d]# vim CentOS7-Base-163.repo
[root@linux yum.repos.d]# yum clean all
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在清理软件源: base extras updates
[root@linux yum.repos.d]# yum makecache
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
base | 3.6 kB 00:01
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/12): base/x86_64/group_gz | 166 kB 00:27
(2/12): base/x86_64/primary_db | 6.0 MB 00:30
(3/12): extras/x86_64/filelists_db | 189 kB 00:04
(4/12): extras/x86_64/prestodelta | 36 kB 00:04
(5/12): extras/x86_64/other_db | 108 kB 00:00
(6/12): extras/x86_64/primary_db | 156 kB 00:02
(7/12): updates/x86_64/prestodelta | 194 kB 00:03
(8/12): updates/x86_64/primary_db | 1.4 MB 00:07
(9/12): updates/x86_64/other_db | 208 kB 00:01
(10/12): updates/x86_64/filelists_db | 1.4 MB 00:18
(11/12): base/x86_64/other_db | 2.6 MB 00:29
(12/12): base/x86_64/filelists_db | 7.1 MB 01:33
元数据缓存已建立
[root@linux yum.repos.d]#