码迷,mamicode.com
首页 > 其他好文 > 详细

RHCE7 -- systemctl命令

时间:2015-07-17 00:08:59      阅读:386      评论:0      收藏:0      [点我收藏+]

标签:

查询所有单元的状态:

[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:0:0-1:0:0:0-block-sr0.device loaded active plugged   VBOX_CD-ROM
sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device loaded active plugged   PRO/1000 MT Desktop Adapter
sys-devices-pci00...0-0000:00:05.0-sound-card0.device loaded active plugged   82801AA AC97 Audio Controller
sys-devices-pci0000:00-0000:00:08.0-net-enp0s8.device loaded active plugged   PRO/1000 MT Desktop Adapter
sys-devices-pci00...0:0-2:0:0:0-block-sda-sda1.device loaded active plugged   VBOX_HARDDISK
sys-devices-pci00...0:0-2:0:0:0-block-sda-sda2.device loaded active plugged   LVM PV ewUQqv-N1i5-9xcA-GRad-2BLV-qOTh-vNPOd2 on /dev/
sys-devices-pci00...get2:0:0-2:0:0:0-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 2015-07-17 11:08:27 CST; 32min ago
  Process: 649 ExecStart=/sbin/rngd -f (code=exited, status=1/FAILURE)
 Main PID: 649 (code=exited, status=1/FAILURE)
   CGroup: /system.slice/rngd.service

Jul 17 11:08:25 rhce7.example.com systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
Jul 17 11:08:27 rhce7.example.com rngd[649]: Unable to open file: /dev/tpm0
Jul 17 11:08:27 rhce7.example.com rngd[649]: cant open any entropy source
Jul 17 11:08:27 rhce7.example.com rngd[649]: Maybe RNG device modules are not loaded
Jul 17 11:08:27 rhce7.example.com systemd[1]: rngd.service: main process exited, code=exited, status=1/FAILURE
Jul 17 11:08:27 rhce7.example.com systemd[1]: 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

 

RHCE7 -- systemctl命令

标签:

原文地址:http://www.cnblogs.com/abclife/p/4652561.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!