加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Linux (八)服务

发布时间:2020-12-14 00:25:43 所属栏目:Linux 来源:网络整理
导读:1、服务的概念 操作系统中在后台持续运行的程序,本身并没有操作界面,需要通过端口号访问和操作。CentOS 6和CentOS 7的服务管理有很大区别,我们分别来看。 2、CentOS6服务 ?? 2.1 service命令 service ?服务名 start service ?服务名 stop service ?服务名

1、服务的概念

操作系统中在后台持续运行的程序,本身并没有操作界面,需要通过端口号访问和操作。CentOS 6和CentOS 7的服务管理有很大区别,我们分别来看。

2、CentOS6服务

?? 2.1 service命令

service ?服务名 start

service ?服务名 stop

service ?服务名 restart

service ?服务名 reload

service ?服务名 status

2.2? 服务对应程序文件

/etc/init.d目录下都是

2.3? chkconfig命令

查看服务列表:chkconfig [--list]

设置具体服务开机自动启动状态:chkconfig 服务名 on/off

?

思考:你能否区分清楚这两种状态呢?

服务现在是否运行

服务是否开机自动运行

2.4? Linux的运行级别

vim /etc/inittab查看系统配置。CentOS6系统使用0~6这7个数字来控制Linux系统的启动方式。

运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动

运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆

运行级别2:多用户状态(没有NFS),没有网络服务

运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式

运行级别4:系统未使用,保留

运行级别5:X11表示控制台,进入图形界面

运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动

?

常用的是3或5。

?

chkconfig命令使用--level参数和一个数值可以控制一个服务在某个运行级别的是否自动启动。

2.5 防火墙

服务名:iptables

停止防火墙:service iptables stop

3、CentOS7服务

3.1 systemctl命令

systemctl start 服务名(xxxx.service)

systemctl restart 服务名(xxxx.service)

systemctl stop 服务名(xxxx.service)

systemctl reload 服务名(xxxx.service)

systemctl status 服务名(xxxx.service)

3.2 服务对应程序文件

/usr/lib/systemd/system目录下都是

3.3 systemctl命令代替chkconfig命令

查看服务状态:systemctl list-unit-files

设置或取消服务开机自动启动:

  • ?? ? 设置开机自动启动:systemctl enable 服务名
  • ???? 取消开机自动启动:systemctl disable 服务名

3.4? CentOS7简化了运行级别

??????? vim /etc/inittab

# inittab is no longer used when using systemd.

#

# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.

#

# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target

#

# systemd uses ‘targets‘ instead of runlevels. By default,there are two main targets:

#

# multi-user.target: analogous to runlevel 3

# graphical.target: analogous to runlevel 5

#

# To view current default target,run:

# systemctl get-default

#

# To set a default target,run:

# systemctl set-default TARGET.target

systemctl set-default graphical.target

?

3.5 关闭防火墙

systemctl disable firewalld.service

Systemctl stop firewalld.service ?关闭防火墙

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读