查询所有单元的状态:

[root@rhce7 ~]# systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automoun
sys-devices-pci00...get1::-:::-block-sr0.device loaded active plugged VBOX_CD-ROM
sys-devices-pci0000:-::03.0-net-enp0s3.device loaded active plugged PRO/ MT Desktop Adapter
sys-devices-pci00...-::05.0-sound-card0.device loaded active plugged 82801AA AC'97 Audio Controller
sys-devices-pci0000:-::08.0-net-enp0s8.device loaded active plugged PRO/ MT Desktop Adapter
sys-devices-pci00...:-:::-block-sda-sda1.device loaded active plugged VBOX_HARDDISK
sys-devices-pci00...:-:::-block-sda-sda2.device loaded active plugged LVM PV ewUQqv-N1i5-9xcA-GRad-2BLV-qOTh-vNPOd2 on /dev/
sys-devices-pci00...get2::-:::-block-sda.device loaded active plugged VBOX_HARDDISK
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0
...

仅查询服务单元的状态:

[root@rhce7 ~]# systemctl --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrt-xorg.service loaded active running ABRT Xorg log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting Tool
accounts-daemon.service loaded active running Accounts Service
...

查看处于失败或维护状态的任何单元:

[root@rhce7 ~]# systemctl status rngd.service -l
rngd.service - Hardware RNG Entropy Gatherer Daemon
Loaded: loaded (/usr/lib/systemd/system/rngd.service; enabled)
Active: failed (Result: exit-code) since Fri -- :: CST; 32min ago
Process: ExecStart=/sbin/rngd -f (code=exited, status=/FAILURE)
Main PID: (code=exited, status=/FAILURE)
CGroup: /system.slice/rngd.service Jul :: rhce7.example.com systemd[]: Started Hardware RNG Entropy Gatherer Daemon.
Jul :: rhce7.example.com rngd[]: Unable to open file: /dev/tpm0
Jul :: rhce7.example.com rngd[]: can't open any entropy source
Jul :: rhce7.example.com rngd[]: Maybe RNG device modules are not loaded
Jul :: rhce7.example.com systemd[]: rngd.service: main process exited, code=exited, status=/FAILURE
Jul :: rhce7.example.com systemd[]: Unit rngd.service entered failed state.
[root@rhce7 ~]#

查看特定单元是否活动:

[root@rhce7 ~]# systemctl is-active sshd
active

查看特定单元是否已经开启自启动:

[root@rhce7 ~]# systemctl is-enabled sshd
enabled

列出所有已经加载单元的活动状态

[root@rhce7 ~]# systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrt-xorg.service loaded active running ABRT Xorg log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting
accounts-daemon.service loaded active running Accounts Service
alsa-state.service loaded active running Manage Sound Card State (rest
atd.service loaded active running Job spooling tools

查看所有单元的已启用和已禁用设置

[root@rhce7 ~]# systemctl list-unit-files --type=service
UNIT FILE STATE
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-pstoreoops.service disabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled
accounts-daemon.service enabled
alsa-restore.service static

查看失败的服务的状态

[root@rhce7 ~]# systemctl list-unit-files --type=service
UNIT FILE STATE
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-pstoreoops.service disabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled
accounts-daemon.service enabled
alsa-restore.service static

屏蔽服务
有时候可能安装了互相冲突的服务,比如network和NetworkManager,iptables和firewalld
可以将服务屏蔽。屏蔽将在配置目录中创建链接,使的启动该服务时不发生任何事

[root@rhce7 ~]# systemctl mask network
ln -s '/dev/null' '/etc/systemd/system/network.service'
[root@rhce7 ~]# systemctl unmask network
rm '/etc/systemd/system/network.service'

 禁用服务

[root@rhce7 ~]# systemctl disable network
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network off
[root@rhce7 ~]#

禁用服务和屏蔽服务的区别:

·禁用服务:服务不会再系统系统的时候自动启动,也不会被其它单元文件启动,但可以手动启动

·屏蔽服务:无法手动启动,也无法自启动

RHCE7 -- systemctl命令的更多相关文章

  1. Centos7中systemctl命令详解

    Linux Systemctl是一个系统管理守护进程.工具和库的集合,用于取代System V.service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器.通过Syst ...

  2. 【搬运】systemctl 命令完全指南

    Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. Systemd是一个系统管理守护进程.工具和库的集合,用于取代System V初始进程.Systemd的功能是 ...

  3. systemctl命令用法详解

    systemctl命令用法详解系统环境:Fedora 16binpath:/bin/systemctlpackage:systemd-units systemctl enable httpd.serv ...

  4. centos7 systemctl命令

    systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起. 实例: 启动nfs服务:systemctl start nfs-server.s ...

  5. systemctl命令

    systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起. 任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 ...

  6. centos7中systemctl命令使用方法和心得体会

    使用linux的同学对service和chkconfig两个命令都不陌生,其重要性不言而喻,那么怎么会突然冒出个systemctl命令呢?其实,为了简化操作,systemctl命令将service和c ...

  7. systemctl 命令完全指南

    http://www.linuxidc.com/Linux/2015-07/120833.htm Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. System ...

  8. (转)systemctl 命令完全指南

    场景:在使用chkconfig查看vsftpd是否看机启动时候看不到启动项,用systemctl 才看到自己想要的结果 1 总结 from:https://linux.cn/article-5926- ...

  9. Linux systemctl 命令完全指南

    Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. Systemd是一个系统管理守护进程.工具和库的集合,用于取代System V初始进程.Systemd的功能是 ...

随机推荐

  1. Ofstream的endl不好用怎么回事?

    用endl,std::endl, "\n"都不好用,不输出换行,怎么回事? [解决方法] If you're writing a text file, you shouldn't ...

  2. javascript获取数组种最大值?

    Array.prototype.max = function () { return Math.max.apply({}, this) } Array.prototype.min = function ...

  3. hadoop2.2.0_hbase0.96_zookeeper3.4.5全分布式安装文档下载

    本文档主要内容有: 1.hadoop 2.2.0 集群安装与部署 2.HBase 0.96 集群安装与部署 3.Zookeeper 3.4.5集群安装部署 备注:安装文档可能有所遗漏,后续将持续更新. ...

  4. jansson的使用

    https://jansson.readthedocs.org/en/2.5/gettingstarted.html https://github.com/akheron/jansson/blob/m ...

  5. uni-app 如何引入全局方法或变量?

    利用Vue.prototype挂载到Vue实例上即可

  6. sql数据库表复制、查看是否锁表

    1.不同数据库之间复制表的数据的方法: 当表目标表存在时: insert into 目的数据库..表 select * from 源数据库..表 当目标表不存在时: select * into 目的数 ...

  7. D. Flowers Codeforces Round #271(div2)

    D. Flowers time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input ...

  8. 解决java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'

    今天使用mysql,用java程序往mysql中写数据,出现如下错误: Caused by: java.sql.SQLException: Incorrect string value: '\xD3\ ...

  9. 在云主机或vps上用bzr拉OpenERP7.0代码

    前面的文章讲过了用bzr来参与OpenERP开发的过程,其中很重要的一步就是创建本地分支.我在阿里云上建server和web的分支都没有问题,就是addons分支搞了30几次都在中途被kill了. 今 ...

  10. eclipse 如何对maven项目进行打包?

      eclipse 如何对maven项目进行打包? CreateTime--2018年4月19日22:02:50 Author:Marydon 1.方式一:使用eclipse中的maven插件(命令) ...