[root@web01 ~]# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 02:30:24 EDT; 3min 22s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 885 (sshd)
CGroup: /system.slice/sshd.service
└─885 /usr/sbin/sshd -D

Mar 20 02:30:24 web01 systemd[1]: Starting OpenSSH server daemon...
Mar 20 02:30:24 web01 sshd[885]: Server listening on 0.0.0.0 port 22.
Mar 20 02:30:24 web01 sshd[885]: Server listening on :: port 22.
Mar 20 02:30:24 web01 systemd[1]: Started OpenSSH server daemon.
Mar 20 02:31:34 web01 sshd[1009]: Accepted password for root from 192.168.31.173 port 13...ssh2
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

[root@web01 ~]# systemctl get-default
multi-user.target
[root@web01 ~]#
[root@web01 ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
[root@web01 ~]# systemctl get-default
graphical.target
[root@web01 ~]#

systemctl 状态输出关键字:

loaded :单元配置文件已经处理

active(running) :正在通过一个进程或者多个持续的进程运行

active(exited):已经成功完成一次性配置

active(waiting):运行中,但有等待事件

inactive: 不在运行

enabled :服务开机启动

disabled :服务开机不会启动

static:无法启用

列出单元文件

[root@web01 ~]# systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats
sys-devices-pci0000:00-0000:00:07.1-ata2-host2-target2:0:0-2:0:0:0-block-sr0.device loaded ac
sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded ac
sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loaded ac
sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda.device loaded active
sys-devices-pci0000:00-0000:00:15.0-0000:03:00.0-net-eth0.device loaded active plugged VMXN
sys-devices-platform-floppy.0-block-fd0.device loaded active plugged /sys/devices/platform/
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS3.device loaded active plugged /sys/devices/platfor
sys-devices-virtual-block-dm\x2d0.device loaded active plugged /sys/devices/virtual/block/d
sys-devices-virtual-block-dm\x2d1.device loaded active plugged /sys/devices/virtual/block/d
sys-module-configfs.device loaded active plugged /sys/module/configfs
sys-subsystem-net-devices-eth0.device loaded active plugged VMXNET3 Ethernet Controller
-.mount loaded active mounted /
boot.mount loaded active mounted /boot
dev-hugepages.mount loaded active mounted Huge Pages File System
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
run-user-0.mount loaded active mounted /run/user/0
sys-kernel-config.mount loaded active mounted Configuration File System
sys-kernel-debug.mount loaded active mounted Debug File System
brandbot.path loaded active waiting Flexible branding
systemd-ask-password-plymouth.path loaded active waiting Forward Password Requests to Plymo
systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall
session-1.scope loaded active running Session 1 of user root
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
。・kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static dev
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapsh
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rc-local.service loaded active exited /etc/rc.d/rc.local Compatibility
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-import-state.service loaded active exited Import network configuration from
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storag
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Syste
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Director
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shut
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hoste
-.slice loaded active active Root Slice
system-getty.slice loaded active active system-getty.slice
system-lvm2\x2dpvscan.slice loaded active active system-lvm2\x2dpvscan.slice
system-selinux\x2dpolicy\x2dmigrate\x2dlocal\x2dchanges.slice loaded active active system-
system.slice loaded active active System Slice
user-0.slice loaded active active User Slice of root
user.slice loaded active active User and Session Slice
dbus.socket loaded active running D-Bus System Message Bus Socket
dm-event.socket loaded active listening Device-mapper event daemon FIFOs
lvm2-lvmetad.socket loaded active running LVM2 metadata daemon socket
lvm2-lvmpolld.socket loaded active listening LVM2 poll daemon socket
systemd-initctl.socket loaded active listening /dev/initctl Compatibility Named P
systemd-journald.socket loaded active running Journal Socket
systemd-shutdownd.socket loaded active listening Delayed Shutdown Socket
systemd-udevd-control.socket loaded active running udev Control Socket
systemd-udevd-kernel.socket loaded active running udev Kernel Socket
dev-mapper-centos\x2dswap.swap loaded active active /dev/mapper/centos-swap
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target loaded active active Network
paths.target loaded active active Paths
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directo

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

96 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

[root@web01 ~]#

查询所有服务状态

[root@web01 ~]# systemctl --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
● kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static devic
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshot
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rc-local.service loaded active exited /etc/rc.d/rc.local Compatibility
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-import-state.service loaded active exited Import network configuration from in
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directorie
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdo
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hosted

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@web01 ~]#

查看服务状态

[root@web01 ~]# systemctl is-active rsyslog.service
active
[root@web01 ~]# systemctl is-enabled rsyslog.service
enabled
[root@web01 ~]#

已加载的服务

[root@web01 ~]# systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
● kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static devic
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshot
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rc-local.service loaded active exited /etc/rc.d/rc.local Compatibility
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-import-state.service loaded active exited Import network configuration from in
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directorie
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdo
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hosted

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

[root@web01 ~]# systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
● kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static devic
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshot
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
network.service loaded active exited LSB: Bring up/down networking
NetworkManager-wait-online.service loaded active exited Network Manager Wait Online
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rc-local.service loaded active exited /etc/rc.d/rc.local Compatibility
rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
rhel-import-state.service loaded active exited Import network configuration from in
rhel-readonly.service loaded active exited Configure read-only root support
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directorie
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdo
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hosted

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
...skipping...
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directorie
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdo
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hosted

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@web01 ~]#
[root@web01 ~]# systemctl list-units --type=service --all
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
brandbot.service loaded inactive dead Flexible Branding Service
chronyd.service loaded active running NTP client/server
cpupower.service loaded inactive dead Configure CPU power related set
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
● display-manager.service not-found inactive dead display-manager.service
dm-event.service loaded inactive dead Device-mapper event daemon
dracut-shutdown.service loaded inactive dead Restore /run/initramfs
emergency.service loaded inactive dead Emergency Shell
● exim.service not-found inactive dead exim.service
getty@tty1.service loaded active running Getty on tty1
● ip6tables.service not-found inactive dead ip6tables.service
● iptables.service not-found inactive dead iptables.service
irqbalance.service loaded inactive dead irqbalance daemon
● kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static
● lvm2-activation.service not-found inactive dead lvm2-activation.service
lines 1-19

已启用和已禁用的服务

[root@web01 ~]# systemctl list-unit-files --type=service
UNIT FILE STATE
arp-ethers.service disabled
auditd.service enabled
autovt@.service enabled
blk-availability.service disabled
brandbot.service static
chrony-dnssrv@.service static
chrony-wait.service disabled
chronyd.service enabled
console-getty.service disabled
console-shell.service disabled
container-getty@.service static
cpupower.service disabled
crond.service enabled
dbus-org.freedesktop.hostname1.service static
dbus-org.freedesktop.import1.service static
dbus-org.freedesktop.locale1.service static
dbus-org.freedesktop.login1.service static
dbus-org.freedesktop.machine1.service static
dbus-org.freedesktop.NetworkManager.service enabled
dbus-org.freedesktop.nm-dispatcher.service enabled
dbus-org.freedesktop.timedate1.service static
dbus.service static
debug-shell.service disabled
dm-event.service disabled
dracut-cmdline.service static
dracut-initqueue.service static
dracut-mount.service static
dracut-pre-mount.service static
dracut-pre-pivot.service static
dracut-pre-trigger.service static
dracut-pre-udev.service static
dracut-shutdown.service static
ebtables.service disabled
emergency.service static
firewalld.service disabled
fstrim.service static
getty@.service enabled
halt-local.service static
initrd-cleanup.service static
initrd-parse-etc.service static
initrd-switch-root.service static
initrd-udevadm-cleanup-db.service static
iprdump.service disabled
iprinit.service disabled
iprupdate.service disabled
irqbalance.service enabled
kdump.service enabled
kmod-static-nodes.service static
lvm2-lvmetad.service disabled
lvm2-lvmpolld.service disabled
lvm2-monitor.service enabled
lvm2-pvscan@.service static
messagebus.service static
microcode.service enabled
NetworkManager-dispatcher.service enabled
NetworkManager-wait-online.service disabled
NetworkManager.service enabled
plymouth-halt.service disabled
plymouth-kexec.service disabled
plymouth-poweroff.service disabled
plymouth-quit-wait.service disabled
plymouth-quit.service disabled
plymouth-read-write.service disabled
plymouth-reboot.service disabled
plymouth-start.service disabled
plymouth-switch-root.service static
polkit.service static
postfix.service enabled
quotaon.service static
rc-local.service static
rdisc.service disabled
rescue.service static
rhel-autorelabel-mark.service static
rhel-autorelabel.service static
rhel-configure.service static
rhel-dmesg.service disabled
rhel-domainname.service disabled
rhel-import-state.service static
rhel-loadmodules.service static
rhel-readonly.service static
rsyslog.service enabled
selinux-policy-migrate-local-changes@.service static
serial-getty@.service disabled
sshd-keygen.service static
sshd.service enabled
sshd@.service static
svnserve.service disabled
systemd-ask-password-console.service static
systemd-ask-password-plymouth.service static
systemd-ask-password-wall.service static
systemd-backlight@.service static
systemd-binfmt.service static
systemd-bootchart.service disabled
systemd-firstboot.service static
systemd-fsck-root.service static
systemd-fsck@.service static
systemd-halt.service static
systemd-hibernate-resume@.service static
systemd-hibernate.service static
systemd-hostnamed.service static
systemd-hwdb-update.service static
systemd-hybrid-sleep.service static
systemd-importd.service static
systemd-initctl.service static
systemd-journal-catalog-update.service static
systemd-journal-flush.service static
systemd-journald.service static
systemd-kexec.service static
systemd-localed.service static
systemd-logind.service static
systemd-machine-id-commit.service static
systemd-machined.service static
systemd-modules-load.service static
systemd-nspawn@.service disabled
systemd-poweroff.service static
systemd-quotacheck.service static
systemd-random-seed.service static
systemd-readahead-collect.service enabled
systemd-readahead-done.service indirect
systemd-readahead-drop.service enabled
systemd-readahead-replay.service enabled
systemd-reboot.service static
systemd-remount-fs.service static
systemd-rfkill@.service static
systemd-shutdownd.service static
systemd-suspend.service static
systemd-sysctl.service static
systemd-timedated.service static
systemd-tmpfiles-clean.service static
systemd-tmpfiles-setup-dev.service static
systemd-tmpfiles-setup.service static
systemd-udev-settle.service static
systemd-udev-trigger.service static
systemd-udevd.service static
systemd-update-done.service static
systemd-update-utmp-runlevel.service static
systemd-update-utmp.service static
systemd-user-sessions.service static
systemd-vconsole-setup.service static
tcsd.service disabled
teamd@.service static
tuned.service enabled
vgauthd.service enabled
vmtoolsd.service enabled
wpa_supplicant.service disabled

145 unit files listed.

[root@web01 ~]#

启用失败的服务

[root@web01 ~]# systemctl --failed --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
● kdump.service loaded failed failed Crash recovery kernel arming

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@web01 ~]#

查看服务状态:

[root@web01 ~]# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 02:30:24 EDT; 1h 3min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 885 (sshd)
CGroup: /system.slice/sshd.service
└─885 /usr/sbin/sshd -D

Mar 20 02:30:24 web01 systemd[1]: Starting OpenSSH server daemon...
Mar 20 02:30:24 web01 sshd[885]: Server listening on 0.0.0.0 port 22.
Mar 20 02:30:24 web01 sshd[885]: Server listening on :: port 22.
Mar 20 02:30:24 web01 systemd[1]: Started OpenSSH server daemon.
Mar 20 02:31:34 web01 sshd[1009]: Accepted password for root from 192.168.31.173 port 13...ssh2
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

验证服务运行

[root@web01 ~]# systemctl restart rsyslog.service
[root@web01 ~]# systemctl status rsyslog.service
。・rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 03:37:48 EDT; 15s ago
Docs: man:rsyslogd(8)
http://www.rsyslog.com/doc/
Main PID: 1206 (rsyslogd)
CGroup: /system.slice/rsyslog.service
ゥクゥ、1206 /usr/sbin/rsyslogd -n

Mar 20 03:37:47 web01 systemd[1]: Starting System Logging Service...
Mar 20 03:37:48 web01 rsyslogd[1206]: [origin software="rsyslogd" swVersion="8.24.0" x-p...art
Mar 20 03:37:48 web01 systemd[1]: Started System Logging Service.
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

[root@web01 ~]# systemctl stop rsyslog.service
[root@web01 ~]# systemctl restart rsyslog.service
[root@web01 ~]# systemctl status rsyslog.service
● rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 03:39:07 EDT; 2s ago
Docs: man:rsyslogd(8)
http://www.rsyslog.com/doc/
Main PID: 1257 (rsyslogd)
CGroup: /system.slice/rsyslog.service
└─1257 /usr/sbin/rsyslogd -n

Mar 20 03:39:07 web01 systemd[1]: Starting System Logging Service...
Mar 20 03:39:07 web01 rsyslogd[1257]: [origin software="rsyslogd" swVersion="8.24.0" x-p...art
Mar 20 03:39:07 web01 systemd[1]: Started System Logging Service.
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

屏蔽服务

[root@web01 ~]# systemctl mask network
Created symlink from /etc/systemd/system/network.service to /dev/null.
[root@web01 ~]# systemctl restart network
Failed to restart network.service: Unit is masked.
[root@web01 ~]# systemctl unmask network.service
Removed symlink /etc/systemd/system/network.service.
[root@web01 ~]# systemctl restart network
[root@web01 ~]#

[root@web01 ~]# systemctl status chronyd.service
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:chronyd(8)
man:chrony.conf(5)

Mar 20 03:43:24 web01 chronyd[641]: Source 199.182.204.197 offline
Mar 20 03:43:24 web01 chronyd[641]: Source 124.108.20.1 offline
Mar 20 03:43:24 web01 chronyd[641]: Source 119.28.206.193 offline
Mar 20 03:43:24 web01 chronyd[641]: Can't synchronise: no selectable sources
Mar 20 03:43:24 web01 chronyd[641]: Source 108.59.2.24 online
Mar 20 03:43:24 web01 chronyd[641]: Source 119.28.206.193 online
Mar 20 03:43:24 web01 chronyd[641]: Source 199.182.204.197 online
Mar 20 03:43:24 web01 chronyd[641]: Source 124.108.20.1 online
Mar 20 03:45:49 web01 systemd[1]: Stopping NTP client/server...
Mar 20 03:45:49 web01 systemd[1]: Stopped NTP client/server.
[root@web01 ~]#

[root@web01 ~]# systemctl restart chronyd.service
[root@web01 ~]# systemctl status chronyd.service
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 03:46:34 EDT; 9s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 1962 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Process: 1958 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 1960 (chronyd)
CGroup: /system.slice/chronyd.service
└─1960 /usr/sbin/chronyd

Mar 20 03:46:34 web01 systemd[1]: Starting NTP client/server...
Mar 20 03:46:34 web01 chronyd[1960]: chronyd version 3.1 starting (+CMDMON +NTP +REFCLOCK...UG)
Mar 20 03:46:34 web01 chronyd[1960]: Frequency -7.886 +/- 3.569 ppm read from /var/lib/ch...ift
Mar 20 03:46:34 web01 systemd[1]: Started NTP client/server.
Mar 20 03:46:41 web01 chronyd[1960]: Selected source 119.28.206.193
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

[root@web01 ~]# systemctl is-enabled chronyd.service
disabled
[root@web01 ~]# systemctl enable chronyd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
[root@web01 ~]#

[root@web01 ~]# systemctl reload sshd.service
[root@web01 ~]#
[root@web01 ~]# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-20 02:30:24 EDT; 1h 17min ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 2048 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 885 (sshd)
CGroup: /system.slice/sshd.service
└─885 /usr/sbin/sshd -D

Mar 20 02:30:24 web01 systemd[1]: Starting OpenSSH server daemon...
Mar 20 02:30:24 web01 sshd[885]: Server listening on 0.0.0.0 port 22.
Mar 20 02:30:24 web01 sshd[885]: Server listening on :: port 22.
Mar 20 02:30:24 web01 systemd[1]: Started OpenSSH server daemon.
Mar 20 02:31:34 web01 sshd[1009]: Accepted password for root from 192.168.31.173 port 13...ssh2
Mar 20 03:47:58 web01 sshd[885]: Received SIGHUP; restarting.
Mar 20 03:47:58 web01 systemd[1]: Reloaded OpenSSH server daemon.
Mar 20 03:47:58 web01 sshd[885]: Server listening on 0.0.0.0 port 22.
Mar 20 03:47:58 web01 sshd[885]: Server listening on :: port 22.
Hint: Some lines were ellipsized, use -l to show in full.
[root@web01 ~]#

[root@web01 ~]# systemctl get-default
multi-user.target
[root@web01 ~]#
[root@web01 ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
[root@web01 ~]# systemctl get-default
graphical.target
[root@web01 ~]# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
[root@web01 ~]#

systemctl 控制单元的更多相关文章

  1. systemctl介绍

    声明:本文转载自:systemd (中文简体) systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 ...

  2. systemd 之 systemctl

    Systemd 常规操作与彩蛋 一.前言 上了俩个月的RHCE工程师的班,收获颇多.话说回来,在 redhat 7 中有个非常重要的概念,即:systemd systemd 是 Linux 下的一款系 ...

  3. 【RHEL7/CentOS7服务控制之systemctl命令】

    Systemd对于Linux来说,就是一个init程序,可以作为sysVinit和Upstat的替代. RHEL7监控和控制Systemd的主要命令是systemctl,该命令可查看系统状态和管理系统 ...

  4. ubuntu18.04 systemctl

    systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 socket 式与 D-Bus 总线式激活服务 ...

  5. systemctl详解

    [root@hadoop01 hadoop]# systemctl --help systemctl [OPTIONS...] {COMMAND} ... Query or send control ...

  6. systemd详解

    CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...

  7. linux_systemctl介绍

    声明:本文转载自:systemd (中文简体) systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 ...

  8. linux systemd详解

    CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...

  9. systemd基础

    systemd 起源 systemd这一名字源于Unix中的一个惯例:在Unix中常以“d”作为系统守护进程(英语:daemon,亦称后台进程)的后缀标识.除此以外,systemd亦是借代英文术语D体 ...

随机推荐

  1. Python 安装 numpy 以及 matplotlib 的过程

    系统:ubuntu 16.04 版本:Python3.5 步骤: 安装 pip sudo apt install python3-pip 查看 pip list 是否有 numpy 以及 matplo ...

  2. P3375 【模板】KMP字符串匹配 (KMP模板)

    题目描述 如题,给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置. 为了减少骗分的情况,接下来还要输出子串的前缀数组next. (如果你不知道这是什么意思也不要问,去百度 ...

  3. docker-compose,docker-machine,docker swarm 的简单总结

    1.docker-compose: 用来在单机上启动一组应用服务.这个服务中可能包含有很多应用,比如你的app服务,redis,mysql,等等. (1)我们需要先创建好docker-compose的 ...

  4. 园区IP地址规划(非常详细)

    转:https://mp.weixin.qq.com/s/Zlm7x5eunIYLAG7Sp0yVCQ 经过这些年工作,接触从几万.几十万到上亿的项目都有: 我简单总结了接触的大部分的项目,将园区网核 ...

  5. Spring知识梳理

    Spring框架介绍 Spring是一个贯穿各层为javaEE提供一站式解决方案的框架,Spring中主要有容器模块,AOP模块,ORM和DAO模块,Web模块等等,具体有以下功能特征. IOC(或者 ...

  6. 【基础训练】HDOJ2032杨辉三角

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvWEdzaWxlbmNl/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...

  7. ubuntu中写一个shell脚本的过程

    gedit hello.sh ,然后输入 #!/bin/bash echo "Hello world!" chmod +x hello.sh ./hello.sh

  8. MMORPG大型游戏设计与开发(server 游戏场景 事件)

    游戏截图 场景事件 一个完整的对象一般都拥有事件,至于什么是事件在这里就不多解释了. 在场景中的事件在天龙/武侠世界中的事件包含场景初始化.场景定时器.场景退出.玩家进入场景.角色升级.角色死亡.角色 ...

  9. Android recovery UI实现分析

    Android recovery模式为何物? 关于这个问题, baidu上已经有无数的答案.不理解的朋友先补习一下. 从纯技术角度来讲, recovery和android本质上是两个独立的rootfs ...

  10. Rails中关联数据表的添加操作(嵌套表单)

    很早就听说有Web敏捷开发这回事,最近终于闲了下来,可以利用业余的时间学些新东西,入眼的第一个东东自然是Ruby on Rails.Rails中的核心要素也就是MVC.ORM这些了,因此关于Rails ...