systemctl 控制单元
[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 控制单元的更多相关文章
- systemctl介绍
声明:本文转载自:systemd (中文简体) systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 ...
- systemd 之 systemctl
Systemd 常规操作与彩蛋 一.前言 上了俩个月的RHCE工程师的班,收获颇多.话说回来,在 redhat 7 中有个非常重要的概念,即:systemd systemd 是 Linux 下的一款系 ...
- 【RHEL7/CentOS7服务控制之systemctl命令】
Systemd对于Linux来说,就是一个init程序,可以作为sysVinit和Upstat的替代. RHEL7监控和控制Systemd的主要命令是systemctl,该命令可查看系统状态和管理系统 ...
- ubuntu18.04 systemctl
systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 socket 式与 D-Bus 总线式激活服务 ...
- systemctl详解
[root@hadoop01 hadoop]# systemctl --help systemctl [OPTIONS...] {COMMAND} ... Query or send control ...
- systemd详解
CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...
- linux_systemctl介绍
声明:本文转载自:systemd (中文简体) systemd 是 Linux 下的一款系统和服务管理器,兼容 SysV 和 LSB 的启动脚本.systemd 的特性有:支持并行化任务:同一时候採用 ...
- linux systemd详解
CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...
- systemd基础
systemd 起源 systemd这一名字源于Unix中的一个惯例:在Unix中常以“d”作为系统守护进程(英语:daemon,亦称后台进程)的后缀标识.除此以外,systemd亦是借代英文术语D体 ...
随机推荐
- 用于检测进程的shell脚本
用于检测进程的shell脚本 2010-07-07 10:38:08| 分类: Centos |字号 订阅 脚本一: #!/bin/sh program=XXXX #进程名 sn=`ps - ...
- CNN实现terecord、数据集、模型训练
AlexNet(Alex Krizhevsky,ILSVRC2012冠军)适合做图像分类.层自左向右.自上向下读取,关联层分为一组,高度.宽度减小,深度增加.深度增加减少网络计算量. 训练模型数据集 ...
- 2016 年 Java 工具和技术的调查:IDEA 已超过
最近「技术最前线」看到 RebelLabs 做了一次 2016 年 Java 工具与技术的调查,调查报告虽然是 6 月公布的,但数据一点也不过时. 所以「技术最前线」忙会了一中午,写了这篇文章,带大家 ...
- Spring学习总结(15)——Spring AOP 拦截器的基本实现
一个程序猿在梦中解决的 Bug 没有人是不做梦的,在所有梦的排行中,白日梦最令人伤感.不知道身为程序猿的大家,有没有睡了一觉,然后在梦中把睡之前代码中怎么也搞不定的 Bug 给解决的经历?反正我是有过 ...
- Mysql提升大数据导入速度的绝妙方法
一.对于Myisam类型的表,可以通过以下方式快速的导入大量的数据. ALTER TABLE tblname DISABLE KEYS; loading the data A ...
- Java多线程演示样例(模拟通话,sleep,join,yield,wait,notify,Semaphore)
主线程等待子线程的多种方法 synchronized浅析 sleep 是静态方法,Thread.sleep(xx)谁调用谁睡眠. join 是合并方法.当前线程调用其它线程xx.join()则等到xx ...
- Ubuntu下的用户和权限(三)
七.增删群组相关的命令 相同的我们要先介绍两个重要的设定档:/etc/group和/etc/gshadow,前面那个事实上和/etc/passwd一样.而后者就是群组的password表了.先看看长啥 ...
- codeforces 490 D Chocolate
题意:给出a1*b1和a2*b2两块巧克力,每次可以将这四个数中的随意一个数乘以1/2或者2/3,前提是要可以被2或者3整除,要求最小的次数让a1*b1=a2*b2,并求出这四个数最后的大小. 做法: ...
- 2015.04.21,外语,读书笔记-《Word Power Made Easy》 12 “如何奉承朋友” SESSION 32
TEASER PREVIEW 如何描述这些人: 很友好.容易相处的人: 不知疲倦的人: 简单.直率..aboveboard([ə'bʌv'bɔ:d] adv. 光明正大地, 率直地 adj. 光明正大 ...
- angularjs1-8,cacheFactory,sce
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...