Linux系统基础(8)--自有服务管理

自有服务,可以简单理解为Linux系统开机自动运行的服务。

一.CentOS6与CentOS7差异

CentOS6/RHEL6
service命令(管理服务开启、停止以及重启)+ chkconfig(定义开机启动项)

service 服务名称 start|stop|restart

CentOS7/RHEL7

systemctl命令 = system系统 + control控制(服务管理+开启启动项管理)

systemctl start|stop|restart 服务名称

二.显示系统服务

1.列出系统所有服务
systemctl list-units --type service --all

2.列出系统已经启动的服务
systemctl list-units --type service

3.列出服务依赖性
systemctl list-dependencies

Tips:可以和管道结合使用查看我们所需要的服务

三.自有服务管理

systemctl status 系统服务名称		#查看服务状态
systemctl stop 系统服务名称			#停止服务
systemctl start 系统服务名称		#启动服务
systemctl restart 系统服务名称		#重启服务
systemctl reload 系统服务名称		#热重载,只重新加载指定服务的配置文件

systemctl enable 系统服务名称		#开机自启
systemctl disable 系统服务名称		#开机不自启
systemctl enable --now 系统服务名称	#开机自启并立即开启

systemctl mask 系统服务名称			#冻结服务
systemctl unmask 系统服务名称		#解冻服务

四.系统运行模式

1.CentOS6的运行级别

0   系统关机状态   
1   单用户工作状态   Single user mode
2   多用户状态(没有NFS) Multiuser, without NFS (The same as 3, if you do not have networking)
3   多用户状态(有NFS)   Full multiuser mode (字符模式,服务基本都是此模式)
4   系统未使用,留给用户   unused
5   图形界面    X11 (图形模式,个人计算机都是此模式)
6   系统正常关闭并重新启动   reboot

2.CentOS7的运行级别

0   shutdown.target
1   emergency.target
2   rescure.target
3   multi-user.target   字符模式
45   graphical.target    图形模式
6

3.运行级别控制

systemctl get-default					#查看系统运行模式
	
systemctl set-default 运行级别(CentOS7)	#设定系统运行模式
init 0				#关机
init 6				#重启
init 3				#字符模式
init 5				#图形模式

4.CentOS6中的chkconfig

chkconfig是当前不生效,Linux重启之后才生效的命令(开机自启动项)
service是即使生效,重启后失效的命令
CentOS6

1.设置服务开机启动
chkconfig network on

2.查看是否成功
chkconfig --list |grep sshd
sshd       0:off	1:off	2:on	3:on	4:on	5:on	6:off
0 关机模式
1 单用户模式
2 多用户模式(无NFS)
3 字符模式
4 自定义模式
5 图形模式
6 重启模式

网上找的:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值