systemctl 管理服务

Linux systemctl

systemctl 命令,主要有两个功能:

  • 控制 systemd 系统
  • 管理系统上运行的服务

systemctl 融合了 service 和 chkconfig 的功能于一体,可以通过它启用/禁用服务,不带任何参数执行 systemctl 命令会列出所有已启动的 unit。unit 有如下几种类型:

  1. service
  2. socket
  3. device
  4. mount
  5. automount
  6. swap
  7. target
  8. timer

语法:

systemctl [OPTIONS…] COMMAND [NAME…]

COMMAND:

  • start:立刻启动后面接的 unit
  • stop:立刻关闭后面接的 unit
  • restart:立刻重新启动后面接的unit
  • reload:不关闭 unit 的情况下,重新载入配置文件,让设置生效
  • enable:设置下次开机时,后面接的 unit 会被启动
  • disable:设置下次开机时,后面接的 unit 不会被启动
  • status:目前后面接的这个 unit 的状态
  • list-unit-files:列出所有已经安装的服务及状态
UNIT FILE                                     STATE   
proc-sys-fs-binfmt_misc.automount             static  
dev-hugepages.mount                           static  
dev-mqueue.mount                              static  
proc-sys-fs-binfmt_misc.mount                 static  
sys-fs-fuse-connections.mount                 static  
sys-kernel-config.mount                       static  
sys-kernel-debug.mount                        static  
tmp.mount                                     disabled
brandbot.path                                 disabled
systemd-ask-password-console.path             static  
systemd-ask-password-plymouth.path            static  
systemd-ask-password-wall.path                static  
session-1.scope                               static  
aliyun.service                                disabled
arp-ethers.service                            disabled
atd.service                                   enabled 
auditd.service                                enabled 
autovt@.service                               enabled 
blk-availability.service                      disabled

注:static 指对应的 Unit 文件中没有定义[Install]区域,因此无法配置为开机启动服务

查看 Linux 系统版本

  • uname -a (查看操作系统内核信息)
Linux lslxy1021 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • cat /etc/redhat-release (查看发行版本信息)
CentOS Linux release 7.3.1611 (Core) 
  • lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.3.1611 (Core) 
Release:	7.3.1611
Codename:	Core
[root@lslxy1021 ~]# lsb_release
LSB Version:	:core-4.1-amd64:core-4.1-noarch
  • cat /proc/cpuinfo (查看 cpu 信息,包括型号、主频、核数)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值