firewalld
- 打开firewalld
- systemctl disable iptables
- systemctl stop iptables
- systemctl enable firewalld
- systemctl start firewalld
- firewalld 默认有9个zone
- 默认zone 为public
- firewall-cmd --get-zones ···查看所有zone
- firewall-cmd --get-default-zone···查看默认zone
- 打开firewalld
[root@xuexi-001 ~]# systemctl disable iptablesRemoved symlink /etc/systemd/system/basic.target.wants/iptables.service.[root@xuexi-001 ~]# systemctl stop iptables[root@xuexi-001 ~]# systemctl enable firewalld[root@xuexi-001 ~]# systemctl start firewalld
- 查看所有zone
[root@xuexi-001 ~]# firewall-cmd --get-zonesblock dmz drop external home internal public trusted work
查看默认zone
[root@xuexi-001 ~]# firewall-cmd --get-default-zonepublic
firewalld关于zone的操作
- 设定默认zone
[root@xuexi-001 ~]# firewall-cmd --set-default-zone=worksuccess
- 查指定网卡
[root@xuexi-001 ~]# firewall-cmd --get-zone-of-interface=ens33public
- 给指定网卡设置zone
[root@xuexi-001 ~]# firewall-cmd --zone=public --add-interface=losuccess[root@xuexi-001 ~]# firewall-cmd --get-zone-of-interface=lopublic
- 针对网卡指定zone
[root@xuexi-001 ~]# firewall-cmd --zone=dmz --change-interface=losuccess[root@xuexi-001 ~]# firewall-cmd --get-zone-of-interface=lodmz
- 针对网卡删除zone
[root@xuexi-001 ~]# firewall-cmd --zone=dmz --remove-interface=losuccess[root@xuexi-001 ~]# firewall-cmd --get-zone-of-interface=lono zone
- 查看系统所有网卡所在的zone
[root@xuexi-001 ~]# firewall-cmd --get-active-zonespublic interfaces: ens33
firewalld关于service的操作
- 查看所有的service
[root@xuexi-001 ~]# firewall-cmd --get-servicesRH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kibana klogin kpasswd kshell ldap ldaps libvirt libvirt-tls managesieve mdns mosh mountd ms-wbt mssql mysql nfs nrpe ntp openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius rpc-bind rsh rsyncd samba samba-client sane sip sips smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server
- 查看当前zone下有哪些service
[root@xuexi-001 ~]# firewall-cmd --zone=public --list-servicessh dhcpv6-client
- 把http增加到public zone下面
[root@xuexi-001 ~]# firewall-cmd --zone=public --add-service=httpsuccess[root@xuexi-001 ~]# firewall-cmd --zone=public --list-servicessh dhcpv6-client http
- 将ftp增加到public并保存在配置文件中 /etc/firewall/zones
[root@xuexi-001 ~]# firewall-cmd --zone=public --add-service=ftp --permanentsuccess[root@xuexi-001 ~]# ls /etc/firewalld/zones/public.xml public.xml.old[root@xuexi-001 ~]# cat /etc/firewalld/zones/public.xmlPublic For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
- 把http删除public zone
[root@xuexi-001 ~]# firewall-cmd --zone=public --remove-service=httpsuccess[root@xuexi-001 ~]# firewall-cmd --zone=public --list-servicessh dhcpv6-client[root@xuexi-001 ~]# firewall-cmd --zone=public --remove-service=http --permanent ·····永久删除success[root@xuexi-001 ~]# cat /etc/firewalld/zones/public.xmlPublic For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
- zone 的文件配置模板
[root@xuexi-001 ~]# ls /usr/lib/firewalld/zones/block.xml drop.xml home.xml public.xml work.xmldmz.xml external.xml internal.xml trusted.xml
- 更改配置文件,之后会在/etc/firewalld/zones 目录下面生成配置文件
[root@xuexi-001 ~]# firewall-cmd --zone=public --add-service=http --permanentsuccess
需求:ftp服务自定义端口1121,需要在work zone下面发行ftp
[root@xuexi-001 ~]# cp /usr/lib/firewalld/services/ftp.xml /etc/firewalld/services/[root@xuexi-001 ~]# vi /etc/firewalld/services/ftp.xml更改文件 :[root@xuexi-001 ~]# cp /usr/lib/firewalld/zones/work.xml /etc/firewalld/zones/[root@xuexi-001 ~]# vi /etc/firewalld/zones/work.xml 增加一行内容: [root@xuexi-001 ~]# firewall-cmd --reloadsuccess[root@xuexi-001 ~]# firewall-cmd --zone=work --list-servicessh dhcpv6-client ftp
linux 任务计划
- crontab -u -e -l -r
- 格式:分 时 日 月 周 user command
- 文件/var/spool/cron/usename
- 分范围0-59,时范围0-23,日范围0-31,月范围0-12,周范围1-6
- 可用格式1-5表示一个范围1到5
- 可用格式1,2,3便是1或者2或者3
- 可用格式*/2表示被2整除的数字,比如小时,那就是每隔2小时
- 要保证服务是启动状态
- systemctl start crond.service
任务计划的配置文件
[root@xuexi-001 ~]# cat /etc/crontabSHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root# For details see man 4 crontabs# Example of job definition:# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed
linux系统服务管理 -chkconfig
- chkconfig --list
- chkconfig --level 3 network off
- chkconfig ---level 345 network off
- chkconfig --del network
- chkconfig --add network
- --add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据;
- --del:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据;
- --level<等级代号>:指定读系统服务要在哪一个执行等级中开启或关毕。
等级代号列表:
-
等级0表示:表示关机
-
等级1表示:单用户模式
-
等级2表示:无网络连接的多用户命令行模式
-
等级3表示:有网络连接的多用户命令行模式
-
等级4表示:不可用
-
等级5表示:带图形界面的多用户模式
-
等级6表示:重新启动
-
chkconfig --list
[root@xuexi-001 ~]# chkconfig --list注:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
- chkconfig --level 3 network off
[root@xuexi-001 ~]# chkconfig --list注:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:关 4:开 5:开 6:关
- chkconfig --add 123
- chkconfig --del 123
[root@xuexi-001 ~]# cd /etc/init.d/[root@xuexi-001 init.d]# lsfunctions netconsole network README[root@xuexi-001 init.d]# cp network 123[root@xuexi-001 init.d]# ls123 functions netconsole network README[root@xuexi-001 init.d]# chkconfig --add 123[root@xuexi-001 init.d]# chkconfig --list注:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。123 0:关 1:关 2:开 3:开 4:开 5:开 6:关netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:关 4:开 5:开 6:关[root@xuexi-001 init.d]# chkconfig --del 123[root@xuexi-001 init.d]# chkconfig --list注:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:关 4:开 5:开 6:关
linux 系统服务管理-systemd
- systemctl list-units --all --type=service
- 几个常用的相关命令
- systemctl enable crond.service ···服务开机启动
- systemctl disable crond ···不让开机启动
- systemctl status crond ···查看状态
- systemctl stop cron ···停止服务
- systemctl restart crond ···重启服务
- systemctl is-enabled crond ···检查服务是否开机启动
- systemctl list-untils --all --type=service
[root@xuexi-001 ~]# systemctl list-units --all --type=service UNIT LOAD ACTIVE SUB DESCRIPTION auditd.service loaded active running Security Auditing S brandbot.service loaded inactive dead Flexible Branding S chronyd.service loaded active running NTP client/server cpupower.service loaded inactive dead Configure CPU power crond.service loaded active running Command Scheduler dbus.service loaded active running D-Bus System Messag● display-manager.service not-found inactive dead display-manager.ser dracut-shutdown.service loaded inactive dead Restore /run/initra ebtables.service loaded inactive dead Ethernet Bridge Fil emergency.service loaded inactive dead Emergency Shell● exim.service not-found inactive dead exim.service firewalld.service loaded active running firewalld - dynamic getty@tty1.service loaded active running Getty on tty1 ip6tables.service loaded inactive dead IPv6 firewall with ● ipset.service not-found inactive dead ipset.service iptables.service loaded inactive dead IPv4 firewall with irqbalance.service loaded inactive dead irqbalance daemon kdump.service loaded active exited Crash recovery kern kmod-static-nodes.service loaded active exited Create list of requ microcode.service loaded inactive dead Load CPU microcode network.service loaded active exited LSB: Bring up/down ● NetworkManager-wait-online.service loaded failed failed Network Ma NetworkManager.service loaded active running Network Manager● ntpd.service not-found inactive dead ntpd.service● ntpdate.service not-found inactive dead ntpdate.service plymouth-quit-wait.service loaded inactive dead Wait for Plymouth plymouth-quit.service loaded inactive dead Terminate Plymouth plymouth-read-write.service loaded inactive dead Tell Plymouth To plymouth-start.service loaded inactive dead Show Plymouth Boot polkit.service loaded active running Authorization Manag postfix.service loaded active running Postfix Mail Transp rc-local.service loaded inactive dead /etc/rc.d/rc.local rescue.service loaded inactive dead Rescue Shell rhel-autorelabel-mark.service loaded inactive dead Mark the need t rhel-autorelabel.service loaded inactive dead Relabel all filesys rhel-configure.service loaded inactive dead Reconfigure the sys rhel-dmesg.service loaded active exited Dump dmesg to /var/ rhel-import-state.service loaded active exited Import network conf rhel-loadmodules.service loaded inactive dead Load legacy module rhel-readonly.service loaded active exited Configure read-only rsyslog.service loaded active running System Logging Serv selinux-policy-migrate-local-changes@targeted.service loaded inactive● sendmail.service not-found inactive dead sendmail.service● sntp.service not-found inactive dead sntp.service sshd-keygen.service loaded inactive dead OpenSSH Server Key sshd.service loaded active running OpenSSH server daem● syslog.service not-found inactive dead syslog.service sysstat.service loaded active exited Resets System Activ systemd-ask-password-console.service loaded inactive dead Dispatch systemd-ask-password-plymouth.service loaded inactive dead Forward systemd-ask-password-wall.service loaded inactive dead Forward Pas systemd-binfmt.service loaded inactive dead Set Up Additional B systemd-firstboot.service loaded inactive dead First Boot Wizard systemd-fsck-root.service loaded inactive dead File System Check o systemd-hwdb-update.service loaded inactive dead Rebuild Hardware systemd-initctl.service loaded inactive dead /dev/initctl Compat systemd-journal-catalog-update.service loaded inactive dead Rebuil systemd-journal-flush.service loaded active exited Flush Journal t systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running Login Service systemd-machine-id-commit.service loaded inactive dead Commit a tr systemd-modules-load.service loaded inactive dead Load Kernel Modu● systemd-random-seed-load.service not-found inactive dead systemd-rand systemd-random-seed.service loaded active exited Load/Save Random systemd-readahead-collect.service loaded inactive dead Collect Rea systemd-readahead-done.service loaded inactive dead Stop Read-Ahea systemd-readahead-replay.service loaded inactive dead Replay Read- systemd-reboot.service loaded inactive dead Reboot systemd-remount-fs.service loaded active exited Remount Root and K systemd-rfkill@rfkill0.service loaded active exited Load/Save RF K systemd-shutdownd.service loaded inactive dead Delayed Shutdown Se systemd-sysctl.service loaded active exited Apply Kernel Variab● systemd-sysusers.service not-found inactive dead systemd-sysusers.se● systemd-timesyncd.service not-found inactive dead systemd-timesyncd.s systemd-tmpfiles-clean.service loaded inactive dead Cleanup of Tem systemd-tmpfiles-setup-dev.service loaded active exited Create Sta systemd-tmpfiles-setup.service loaded active exited Create Volatil systemd-udev-trigger.service loaded active exited udev Coldplug al systemd-udevd.service loaded active running udev Kernel Device systemd-update-done.service loaded inactive dead Update is Complet systemd-update-utmp-runlevel.service loaded inactive dead Update U systemd-update-utmp.service loaded active exited Update UTMP about systemd-user-sessions.service loaded active exited Permit User Ses systemd-vconsole-setup.service loaded active exited Setup Virtual tuned.service loaded active running Dynamic System Tuni vgauthd.service loaded active running VGAuth Service for vmtoolsd.service loaded active running Service for virtualLOAD = 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.87 loaded units listed.To show all installed unit files use 'systemctl list-unit-files'.
命令演示:
[root@xuexi-001 ~]# systemctl enable crond.service ······ 开机启动crond服务Created symlink from /etc/systemd/system/multi-user.target.wants/crond.service to /usr/lib/systemd/system/crond.service.[root@xuexi-001 ~]# systemctl disable crond.service ······ 不让开机启动服务Removed symlink /etc/systemd/system/multi-user.target.wants/crond.service.[root@xuexi-001 ~]# systemctl status crond.service ······ 查看服务状态● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; disabled; vendor preset: enabled) Active: active (running) since 一 2018-06-18 20:40:08 CST; 34min ago Main PID: 541 (crond) CGroup: /system.slice/crond.service └─541 /usr/sbin/crond -n6月 18 20:40:08 xuexi-001 systemd[1]: Started Command Scheduler.6月 18 20:40:08 xuexi-001 systemd[1]: Starting Command Scheduler...6月 18 20:40:08 xuexi-001 crond[541]: (CRON) INFO (RANDOM_DELAY will ...)6月 18 20:40:09 xuexi-001 crond[541]: (CRON) INFO (running with inoti...)Hint: Some lines were ellipsized, use -l to show in full.[root@xuexi-001 ~]# systemctl stop crond.service······ 停止服务[root@xuexi-001 ~]# systemctl restart crond······重启服务[root@xuexi-001 ~]# systemctl is-enabled cronddisabled ······查看服务是否开机启动
- ls /usr/lib/systemd/system ···系统所有unit,分为以下类型
- service 系统服务
- target 多个unit组成的组
- device 硬件设备
- mount 文件系统挂载点
- automount 自动挂载点
- path 文件或路径
- scope 不是有systemd启动的外部进程
- slice 进程组
- snapshot systemd 快照
- socket 进程间通信套接字
- swap swap文件
- timer定时器
[root@xuexi-001 ~]# ls /usr/lib/systemd/systemarp-ethers.serviceauditd.serviceautovt@.servicebasic.targetbasic.target.wantsblk-availability.servicebluetooth.targetbrandbot.pathbrandbot.servicechrony-dnssrv@.servicechrony-dnssrv@.timerchronyd.servicechrony-wait.serviceconsole-getty.serviceconsole-shell.servicecontainer-getty@.servicecpupower.servicecrond.servicecryptsetup-pre.targetcryptsetup.targetctrl-alt-del.targetdbus-org.freedesktop.hostname1.servicedbus-org.freedesktop.import1.servicedbus-org.freedesktop.locale1.servicedbus-org.freedesktop.login1.servicedbus-org.freedesktop.machine1.servicedbus-org.freedesktop.timedate1.servicedbus.servicedbus.socketdbus.target.wantsdebug-shell.servicedefault.targetdefault.target.wantsdev-hugepages.mountdev-mqueue.mountdracut-cmdline.servicedracut-initqueue.servicedracut-mount.servicedracut-pre-mount.servicedracut-pre-pivot.servicedracut-pre-trigger.servicedracut-pre-udev.servicedracut-shutdown.serviceebtables.serviceemergency.serviceemergency.targetfinal.targetfirewalld.servicefstrim.servicefstrim.timergetty@.servicegetty.targetgraphical.targetgraphical.target.wantshalt-local.servicehalt.targethalt.target.wantshibernate.targethybrid-sleep.targetinitrd-cleanup.serviceinitrd-fs.targetinitrd-parse-etc.serviceinitrd-root-fs.targetinitrd-switch-root.serviceinitrd-switch-root.targetinitrd-switch-root.target.wantsinitrd.targetinitrd.target.wantsinitrd-udevadm-cleanup-db.serviceip6tables.serviceiprdump.serviceiprinit.serviceiprupdate.serviceiprutils.targetiptables.serviceirqbalance.servicekdump.servicekexec.targetkexec.target.wantskmod-static-nodes.servicelocal-fs-pre.targetlocal-fs.targetlocal-fs.target.wantsmachine.slicemachines.targetmessagebus.servicemicrocode.servicemulti-user.targetmulti-user.target.wantsNetworkManager-dispatcher.serviceNetworkManager.serviceNetworkManager-wait-online.servicenetwork-online.targetnetwork-online.target.wantsnetwork-pre.targetnetwork.targetnss-lookup.targetnss-user-lookup.targetpaths.targetplymouth-halt.serviceplymouth-kexec.serviceplymouth-poweroff.serviceplymouth-quit.serviceplymouth-quit-wait.serviceplymouth-read-write.serviceplymouth-reboot.serviceplymouth-start.serviceplymouth-switch-root.servicepolkit.servicepostfix.servicepoweroff.targetpoweroff.target.wantsprinter.targetproc-sys-fs-binfmt_misc.automountproc-sys-fs-binfmt_misc.mountquotaon.servicerc-local.servicerdisc.servicereboot.targetreboot.target.wantsremote-fs-pre.targetremote-fs.targetrescue.servicerescue.targetrescue.target.wantsrhel-autorelabel-mark.servicerhel-autorelabel.servicerhel-configure.servicerhel-dmesg.servicerhel-domainname.servicerhel-import-state.servicerhel-loadmodules.servicerhel-readonly.servicerpcbind.targetrsyncd.servicersyncd@.servicersyncd.socketrsyslog.servicerunlevel0.targetrunlevel1.targetrunlevel1.target.wantsrunlevel2.targetrunlevel2.target.wantsrunlevel3.targetrunlevel3.target.wantsrunlevel4.targetrunlevel4.target.wantsrunlevel5.targetrunlevel5.target.wantsrunlevel6.targetselinux-policy-migrate-local-changes@.serviceserial-getty@.serviceshutdown.targetshutdown.target.wantssigpwr.targetsleep.target-.sliceslices.targetsmartcard.targetsockets.targetsockets.target.wantssound.targetsshd-keygen.servicesshd.servicesshd@.servicesshd.socketsuspend.targetswap.targetsys-fs-fuse-connections.mountsysinit.targetsysinit.target.wantssys-kernel-config.mountsys-kernel-debug.mountsyslog.socketsyslog.target.wantssysstat.servicesystemd-ask-password-console.pathsystemd-ask-password-console.servicesystemd-ask-password-plymouth.pathsystemd-ask-password-plymouth.servicesystemd-ask-password-wall.pathsystemd-ask-password-wall.servicesystemd-backlight@.servicesystemd-binfmt.servicesystemd-bootchart.servicesystemd-firstboot.servicesystemd-fsck-root.servicesystemd-fsck@.servicesystemd-halt.servicesystemd-hibernate-resume@.servicesystemd-hibernate.servicesystemd-hostnamed.servicesystemd-hwdb-update.servicesystemd-hybrid-sleep.servicesystemd-importd.servicesystemd-initctl.servicesystemd-initctl.socketsystemd-journal-catalog-update.servicesystemd-journald.servicesystemd-journald.socketsystemd-journal-flush.servicesystemd-kexec.servicesystemd-localed.servicesystemd-logind.servicesystemd-machined.servicesystemd-machine-id-commit.servicesystemd-modules-load.servicesystemd-nspawn@.servicesystemd-poweroff.servicesystemd-quotacheck.servicesystemd-random-seed.servicesystemd-readahead-collect.servicesystemd-readahead-done.servicesystemd-readahead-done.timersystemd-readahead-drop.servicesystemd-readahead-replay.servicesystemd-reboot.servicesystemd-remount-fs.servicesystemd-rfkill@.servicesystemd-shutdownd.servicesystemd-shutdownd.socketsystemd-suspend.servicesystemd-sysctl.servicesystemd-timedated.servicesystemd-tmpfiles-clean.servicesystemd-tmpfiles-clean.timersystemd-tmpfiles-setup-dev.servicesystemd-tmpfiles-setup.servicesystemd-udevd-control.socketsystemd-udevd-kernel.socketsystemd-udevd.servicesystemd-udev-settle.servicesystemd-udev-trigger.servicesystemd-update-done.servicesystemd-update-utmp-runlevel.servicesystemd-update-utmp.servicesystemd-user-sessions.servicesystemd-vconsole-setup.servicesystem.slicesystem-update.targettcsd.serviceteamd@.servicetimers.targettimers.target.wantstime-sync.targettmp.mounttuned.serviceumount.targetuser.slicevgauthd.servicevmtoolsd.servicewpa_supplicant.service
unit相关的命令
-
systemctl list-units //列出正在运行的unit
-
systemctl list-unite --all //列出所有,包括失败的或者inactive的
-
systemctl list-units --all --state=inactive //列出inactive的unit
-
systemctl list-units --type=service //列出状态为active的service
-
systemctl is-active crond.service // 查看某个服务是为active
-
systemctl list-units //列出正在运行的unit
[root@xuexi-001 ~]# systemctl list-units UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Exec sys-devices-pci0000:00-0000:00:07.1-ata2-host2-target2:0:0-2:0:0:0-block sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda. sys-devices-pci0000:00-0000:00:11.0-0000:02:00.0-usb2-2\x2d2-2\x2d2.1-2\ sys-devices-pci0000:00-0000:00:11.0-0000:02:00.0-usb2-2\x2d2-2\x2d2.1 ······ sysinit.target loaded active active System Initialization timers.target loaded active active Timers systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of TeLOAD = 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.101 loaded units listed. Pass --all to see loaded but inactive units, too.To show all installed unit files use 'systemctl list-unit-files'.lines 82-109/109 (END)
- systemctl list-unite --all //列出所有,包括失败的或者inactive的
[root@xuexi-001 ~]# systemctl list-units --all UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary dev-cdrom.device loaded active plugged VMware_Virtual_ID dev-disk-by\x2did-ata\x2dVMware_Virtual_IDE_CDROM_Drive_1000000000000000 dev-disk-by\x2dlabel-CentOS\x5cx207\x5cx20x86_64.device loaded active dev-disk-by\x2dpath-pci\x2d0000:00:07.1\x2data\x2d2.0.device loaded a dev-disk-by\x2dpath-pci\x2d0000:00:10.0\x2dscsi\x2d0:0:0:0.device loaded dev-disk-by\x2dpath-pci\x2d0000:00:10.0\x2dscsi\x2d0:0:0:0\x2dpart1.devi dev-disk-by\x2dpath-pci\x2d0000:00:10.0\x2dscsi\x2d0:0:0:0\x2dpart2.devi dev-disk-by\x2dpath-pci\x2d0000:00:10.0\x2dscsi\x2d0:0:0:0\x2dpart3.devi dev-disk-by\x2duuid-2017\x2d09\x2d06\x2d10\x2d51\x2d00\x2d00.device load dev-disk-by\x2duuid-7d77ac07\x2d1105\x2d4db2\x2d9676\x2d34dcaadc2f10.dev dev-disk-by\x2duuid-8121e215\x2dbb40\x2d4f33\x2d89ad\x2d0ee2a8f8c942.dev dev-disk-by\x2duuid-be6981b9\x2d0dba\x2d4bfa\x2da07c\x2d0e701142d321.dev dev-sda.device loaded active plugged VMware_Virtual_S dev-sda1.device loaded active plugged VMware_Virtual_S dev-sda2.device loaded active plugged VMware_Virtual_S dev-sda3.device loaded active plugged VMware_Virtual_S dev-sr0.device loaded active plugged VMware_Virtual_ID dev-ttyS0.device loaded active plugged /dev/ttyS0 dev-ttyS1.device loaded active plugged /dev/ttyS1 dev-ttyS2.device loaded active plugged /dev/ttyS2 dev-ttyS3.device loaded active plugged /dev/ttyS3 sys-devices-pci0000:00-0000:00:07.1-ata2-host2-target2:0:0-2:0:0:0-block sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda- sys-devices-pci0000:00-0000:00:10.0-host0-target0:0:0-0:0:0:0-block-sda. sys-devices-pci0000:00-0000:00:11.0-0000:02:00.0-usb2-2\x2d2-2\x2d2.1-2\ sys-devices-pci0000:00-0000:00:11.0-0000:02:00.0-usb2-2\x2d2-2\x2d2.1-2\ sys-devices-pci0000:00-0000:00:11.0-0000:02:01.0-net-ens33.device loaded sys-devices-pci0000:00-0000:00:11.0-0000:02:02.0-sound-card0.device load sys-devices-pci0000:00-0000:00:11.0-0000:02:05.0-net-ens37.device loaded sys-devices-platform-serial8250-tty-ttyS0.device loaded active plug sys-devices-platform-serial8250-tty-ttyS1.device loaded active plug sys-devices-platform-serial8250-tty-ttyS2.device loaded active plug sys-devices-platform-serial8250-tty-ttyS3.device loaded active plug sys-module-configfs.device loaded active plugged /sys/module/conf sys-subsystem-bluetooth-devices-hci0.device loaded active plugged sys-subsystem-net-devices-ens33.device loaded active plugged 8254 sys-subsystem-net-devices-ens37.device loaded active plugged 8254 sys-subsystem-rfkill-devices-rfkill0.device loaded active plugged -.mount loaded active mounted / boot.mount loaded active mounted /boot dev-hugepages.mount loaded active mounted Huge Pages File S dev-mqueue.mount loaded active mounted POSIX Message Que proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Exe run-user-0.mount loaded active mounted /run/user/0 sys-fs-fuse-connections.mount loaded inactive dead FUSE Control sys-kernel-config.mount loaded active mounted Configuration Fil sys-kernel-debug.mount loaded active mounted Debug File System tmp.mount loaded inactive dead Temporary Directo brandbot.path loaded active waiting Flexible branding systemd-ask-password-console.path loaded inactive dead Dispatch systemd-ask-password-plymouth.path loaded active waiting Forward systemd-ask-password-wall.path loaded active waiting Forward Pass session-1.scope loaded active running Session 1 of user session-2.scope loaded active running Session 2 of user auditd.service loaded active running Security Auditing brandbot.service loaded inactive dead Flexible Branding chronyd.service loaded active running NTP client/server cpupower.service loaded inactive dead Configure CPU pow crond.service loaded active running Command Scheduler dbus.service loaded active running D-Bus System Mess● display-manager.service not-found inactive dead display-manager.s dracut-shutdown.service loaded inactive dead Restore /run/init ebtables.service loaded inactive dead Ethernet Bridge F emergency.service loaded inactive dead Emergency Shell● exim.service not-found inactive dead exim.service firewalld.service loaded active running firewalld - dynam getty@tty1.service loaded active running Getty on tty1 ip6tables.service loaded inactive dead IPv6 firewall wit● ipset.service not-found inactive dead ipset.service iptables.service loaded inactive dead IPv4 firewall wit irqbalance.service loaded inactive dead irqbalance daemon kdump.service loaded active exited Crash recovery ke kmod-static-nodes.service loaded active exited Create list of re microcode.service loaded inactive dead Load CPU microcod network.service loaded active exited LSB: Bring up/dow● NetworkManager-wait-online.service loaded failed failed Network NetworkManager.service loaded active running Network Manager● ntpd.service not-found inactive dead ntpd.service● ntpdate.service not-found inactive dead ntpdate.service plymouth-quit-wait.service loaded inactive dead Wait for Plymout plymouth-quit.service loaded inactive dead Terminate Plymout plymouth-read-write.service loaded inactive dead Tell Plymouth T plymouth-start.service loaded inactive dead Show Plymouth Boo polkit.service loaded active running Authorization Man postfix.service loaded active running Postfix Mail Tran rc-local.service loaded inactive dead /etc/rc.d/rc.loca rescue.service loaded inactive dead Rescue Shell rhel-autorelabel-mark.service loaded inactive dead Mark the need rhel-autorelabel.service loaded inactive dead Relabel all files rhel-configure.service loaded inactive dead Reconfigure the s rhel-dmesg.service loaded active exited Dump dmesg to /va rhel-import-state.service loaded active exited Import network co rhel-loadmodules.service loaded inactive dead Load legacy modul rhel-readonly.service loaded active exited Configure read-on rsyslog.service loaded active running System Logging Se selinux-policy-migrate-local-changes@targeted.service loaded inactive● sendmail.service not-found inactive dead sendmail.service● sntp.service not-found inactive dead sntp.service sshd-keygen.service loaded inactive dead OpenSSH Server Ke sshd.service loaded active running OpenSSH server da● syslog.service not-found inactive dead syslog.service sysstat.service loaded active exited Resets System Act systemd-ask-password-console.service loaded inactive dead Dispat systemd-ask-password-plymouth.service loaded inactive dead Forwa systemd-ask-password-wall.service loaded inactive dead Forward P systemd-binfmt.service loaded inactive dead Set Up Additional systemd-firstboot.service loaded inactive dead First Boot Wizard systemd-fsck-root.service loaded inactive dead File System Check systemd-hwdb-update.service loaded inactive dead Rebuild Hardwar systemd-initctl.service loaded inactive dead /dev/initctl Comp systemd-journal-catalog-update.service loaded inactive dead Rebu systemd-journal-flush.service loaded active exited Flush Journal systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running Login Service systemd-machine-id-commit.service loaded inactive dead Commit a systemd-modules-load.service loaded inactive dead Load Kernel Mo● systemd-random-seed-load.service not-found inactive dead systemd-ra systemd-random-seed.service loaded active exited Load/Save Rando systemd-readahead-collect.service loaded inactive dead Collect R systemd-readahead-done.service loaded inactive dead Stop Read-Ah systemd-readahead-replay.service loaded inactive dead Replay Rea systemd-reboot.service loaded inactive dead Reboot systemd-remount-fs.service loaded active exited Remount Root and systemd-rfkill@rfkill0.service loaded active exited Load/Save RF systemd-shutdownd.service loaded inactive dead Delayed Shutdown systemd-sysctl.service loaded active exited Apply Kernel Vari● systemd-sysusers.service not-found inactive dead systemd-sysusers.● systemd-timesyncd.service not-found inactive dead systemd-timesyncd systemd-tmpfiles-clean.service loaded inactive dead Cleanup of T systemd-tmpfiles-setup-dev.service loaded active exited Create S systemd-tmpfiles-setup.service loaded active exited Create Volat systemd-udev-trigger.service loaded active exited udev Coldplug systemd-udevd.service loaded active running udev Kernel Devic systemd-update-done.service loaded inactive dead Update is Compl systemd-update-utmp-runlevel.service loaded inactive dead Update systemd-update-utmp.service loaded active exited Update UTMP abo systemd-user-sessions.service loaded active exited Permit User S systemd-vconsole-setup.service loaded active exited Setup Virtua tuned.service loaded active running Dynamic System Tu vgauthd.service loaded active running VGAuth Service fo vmtoolsd.service loaded active running Service for virtu -.slice loaded active active Root Slice system-getty.slice loaded active active system-getty.slic system-selinux\x2dpolicy\x2dmigrate\x2dlocal\x2dchanges.slice loaded system-systemd\x2drfkill.slice loaded active active system-syste system.slice loaded active active System Slice user-0.slice loaded active active User Slice of roo user.slice loaded active active User and Session dbus.socket loaded active running D-Bus System Mess sshd.socket loaded inactive dead OpenSSH Server So syslog.socket loaded inactive dead Syslog Socket systemd-initctl.socket loaded active listening /dev/initctl Comp systemd-journald.socket loaded active running Journal Socket systemd-shutdownd.socket loaded active listening Delayed Shutdown systemd-udevd-control.socket loaded active running udev Control S systemd-udevd-kernel.socket loaded active running udev Kernel Soc dev-disk-by\x2dpath-pci\x2d0000:00:10.0\x2dscsi\x2d0:0:0:0\x2dpart2.swap dev-disk-by\x2duuid-be6981b9\x2d0dba\x2d4bfa\x2da07c\x2d0e701142d321.swa dev-sda2.swap loaded active active /dev/sda2 basic.target loaded active active Basic System bluetooth.target loaded active active Bluetooth cryptsetup.target loaded active active Encrypted Volumes emergency.target loaded inactive dead Emergency Mode final.target loaded inactive dead Final Step getty.target loaded active active Login Prompts graphical.target loaded inactive dead Graphical Interfa local-fs-pre.target loaded active active Local File System local-fs.target loaded active active Local File System multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target loaded active active Network (Pre) network.target loaded active active Network nss-user-lookup.target loaded inactive dead User and Group Na paths.target loaded active active Paths remote-fs-pre.target loaded inactive dead Remote File Syste remote-fs.target loaded active active Remote File Syste rescue.target loaded inactive dead Rescue Mode shutdown.target loaded inactive dead Shutdown slices.target loaded active active Slices sockets.target loaded active active Sockets sound.target loaded active active Sound Card swap.target loaded active active Swap sysinit.target loaded active active System Initializa● syslog.target not-found inactive dead syslog.target time-sync.target loaded inactive dead System Time Synch timers.target loaded active active Timers umount.target loaded inactive dead Unmount All Files systemd-readahead-done.timer loaded inactive dead Stop Read-Ahea systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup 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.192 loaded units listed.To show all installed unit files use 'systemctl list-unit-files'.lines 173-200/200 (END)
- systemctl list-units --all --state=inactive //列出inactive的unit
[root@xuexi-001 ~]# systemctl list-units --all --state=inactive UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executab sys-fs-fuse-connections.mount loaded inactive dead FUSE Control File tmp.mount loaded inactive dead Temporary Directory systemd-ask-password-console.path loaded inactive dead Dispatch Passw brandbot.service loaded inactive dead Flexible Branding Serv cpupower.service loaded inactive dead Configure CPU power re● display-manager.service not-found inactive dead display-manager.servic dracut-shutdown.service loaded inactive dead Restore /run/initramfs ebtables.service loaded inactive dead Ethernet Bridge Filter emergency.service loaded inactive dead Emergency Shell● exim.service not-found inactive dead exim.service ip6tables.service loaded inactive dead IPv6 firewall with ip6● ipset.service not-found inactive dead ipset.service iptables.service loaded inactive dead IPv4 firewall with ipt irqbalance.service loaded inactive dead irqbalance daemon microcode.service loaded inactive dead Load CPU microcode upd● ntpd.service not-found inactive dead ntpd.service● ntpdate.service not-found inactive dead ntpdate.service plymouth-quit-wait.service loaded inactive dead Wait for Plymouth Boo plymouth-quit.service loaded inactive dead Terminate Plymouth Boo plymouth-read-write.service loaded inactive dead Tell Plymouth To Wri plymouth-start.service loaded inactive dead Show Plymouth Boot Scr rc-local.service loaded inactive dead /etc/rc.d/rc.local Com rescue.service loaded inactive dead Rescue Shell rhel-autorelabel-mark.service loaded inactive dead Mark the need to r rhel-autorelabel.service loaded inactive dead Relabel all filesystem rhel-configure.service loaded inactive dead Reconfigure the system rhel-loadmodules.service loaded inactive dead Load legacy module con selinux-policy-migrate-local-changes@targeted.service loaded inactive● sendmail.service not-found inactive dead sendmail.service● sntp.service not-found inactive dead sntp.service sshd-keygen.service loaded inactive dead OpenSSH Server Key Gen● syslog.service not-found inactive dead syslog.service systemd-ask-password-console.service loaded inactive dead Dispatch Pa systemd-ask-password-plymouth.service loaded inactive dead Forward Pa systemd-ask-password-wall.service loaded inactive dead Forward Passwo systemd-binfmt.service loaded inactive dead Set Up Additional Bina systemd-firstboot.service loaded inactive dead First Boot Wizard systemd-fsck-root.service loaded inactive dead File System Check on R systemd-hwdb-update.service loaded inactive dead Rebuild Hardware Dat systemd-initctl.service loaded inactive dead /dev/initctl Compatibi systemd-journal-catalog-update.service loaded inactive dead Rebuild J systemd-machine-id-commit.service loaded inactive dead Commit a trans systemd-modules-load.service loaded inactive dead Load Kernel Modules● systemd-random-seed-load.service not-found inactive dead systemd-random- systemd-readahead-collect.service loaded inactive dead Collect Read-A systemd-readahead-done.service loaded inactive dead Stop Read-Ahead D systemd-readahead-replay.service loaded inactive dead Replay Read-Ahe systemd-reboot.service loaded inactive dead Reboot systemd-shutdownd.service loaded inactive dead Delayed Shutdown Servi● systemd-sysusers.service not-found inactive dead systemd-sysusers.servi● systemd-timesyncd.service not-found inactive dead systemd-timesyncd.serv systemd-tmpfiles-clean.service loaded inactive dead Cleanup of Tempor systemd-update-done.service loaded inactive dead Update is Completed systemd-update-utmp-runlevel.service loaded inactive dead Update UTMP sshd.socket loaded inactive dead OpenSSH Server Socket syslog.socket loaded inactive dead Syslog Socket emergency.target loaded inactive dead Emergency Mode final.target loaded inactive dead Final Step graphical.target loaded inactive dead Graphical Interface nss-user-lookup.target loaded inactive dead User and Group Name Lo remote-fs-pre.target loaded inactive dead Remote File Systems (P rescue.target loaded inactive dead Rescue Mode shutdown.target loaded inactive dead Shutdown● syslog.target not-found inactive dead syslog.target time-sync.target loaded inactive dead System Time Synchroniz umount.target loaded inactive dead Unmount All Filesystem systemd-readahead-done.timer loaded inactive dead Stop Read-Ahead DatLOAD = 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.68 loaded units listed.To show all installed unit files use 'systemctl list-unit-files'.lines 49-76/76 (END)
- systemctl list-units --type=service //列出状态为active的service
[root@xuexi-001 ~]# systemctl list-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION auditd.service loaded active running Security Auditing Servic 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 firewalld.service loaded active running firewalld - dynamic fire getty@tty1.service loaded active running Getty on tty1 kdump.service loaded active exited Crash recovery kernel ar kmod-static-nodes.service loaded active exited Create list of required network.service loaded active exited LSB: Bring up/down netwo● NetworkManager-wait-online.service loaded failed failed Network Manager NetworkManager.service loaded active running Network Manager polkit.service loaded active running Authorization Manager postfix.service loaded active running Postfix Mail Transport A rhel-dmesg.service loaded active exited Dump dmesg to /var/log/d rhel-import-state.service loaded active exited Import network configura rhel-readonly.service loaded active exited Configure read-only root rsyslog.service loaded active running System Logging Service sshd.service loaded active running OpenSSH server daemon sysstat.service loaded active exited Resets System Activity L systemd-journal-flush.service loaded active exited Flush Journal to Per 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 systemd-rfkill@rfkill0.service loaded active exited Load/Save RF Kill S systemd-sysctl.service loaded active exited Apply Kernel Variables systemd-tmpfiles-setup-dev.service loaded active exited Create Static D systemd-tmpfiles-setup.service loaded active exited Create Volatile Fil systemd-udev-trigger.service loaded active exited udev Coldplug all Dev systemd-udevd.service loaded active running udev Kernel Device Manag systemd-update-utmp.service loaded active exited Update UTMP about Syst systemd-user-sessions.service loaded active exited Permit User Sessions systemd-vconsole-setup.service loaded active exited Setup Virtual Conso tuned.service loaded active running Dynamic System Tuning Da vgauthd.service loaded active running VGAuth Service for open- vmtoolsd.service loaded active running Service for virtual machLOAD = 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.36 loaded units listed. Pass --all to see loaded but inactive units, too.To show all installed unit files use 'systemctl list-unit-files'.
- systemctl is-active crond.service // 查看某个服务是为active
[root@xuexi-001 ~]# systemctl is-active crond.serviceactive
- 系统为了方便管理用target来管理unit
- systemctl list-unit-files --type=target
- systemctl list-dependencies multi-user.target 查看指定target下面有哪些unit
- systemctl get-default 查看系统默认的target
- systemctl set-default multi-user.target
- 一个service属于一个类型的unit
- 多个unit组成一个target
- 一个target里面包含多个service
- cat /usr/lib/systemd/system/sshd.service ······看【install】部分
- systemctl list-unit-files --type=target
[root@xuexi-001 ~]# systemctl list-unit-files --type=targetUNIT FILE STATE basic.target static bluetooth.target static cryptsetup-pre.target static cryptsetup.target static ctrl-alt-del.target disableddefault.target enabled emergency.target static final.target static getty.target static graphical.target static halt.target disabledhibernate.target static hybrid-sleep.target static initrd-fs.target static initrd-root-fs.target static initrd-switch-root.target static initrd.target static iprutils.target disabledkexec.target disabledlocal-fs-pre.target static local-fs.target static machines.target disabledmulti-user.target enabled network-online.target static network-pre.target static network.target static nss-lookup.target static nss-user-lookup.target static paths.target static poweroff.target disabledprinter.target static reboot.target disabledremote-fs-pre.target static remote-fs.target enabled rescue.target disabledrpcbind.target static runlevel0.target disabledrunlevel1.target disabledrunlevel2.target enabled runlevel3.target enabled runlevel4.target enabled runlevel5.target static runlevel6.target disabledshutdown.target static sigpwr.target static sleep.target static slices.target static smartcard.target static sockets.target static sound.target static suspend.target static swap.target static sysinit.target static system-update.target static time-sync.target static timers.target static umount.target static 57 unit files listed.lines 33-60/60 (END)
- systemctl list-dependencies multi-user.target 查看指定target下面有哪些unit
[root@xuexi-001 ~]# systemctl list-dependencies multi-user.targetmulti-user.target● ├─auditd.service● ├─brandbot.path● ├─chronyd.service● ├─crond.service● ├─dbus.service● ├─firewalld.service● ├─irqbalance.service● ├─kdump.service● ├─network.service● ├─NetworkManager.service● ├─plymouth-quit-wait.service● ├─plymouth-quit.service● ├─postfix.service● ├─rsyslog.service● ├─sshd.service● ├─sysstat.service● ├─systemd-ask-password-wall.path● ├─systemd-logind.service● ├─systemd-readahead-collect.service● ├─systemd-readahead-replay.service● ├─systemd-update-utmp-runlevel.service● ├─systemd-user-sessions.service● ├─tuned.service● ├─vmtoolsd.service● ├─basic.target● │ ├─microcode.service● │ ├─rhel-autorelabel-mark.service● │ ├─rhel-autorelabel.service● │ ├─rhel-configure.service● │ ├─rhel-dmesg.service● │ ├─rhel-loadmodules.service● │ ├─selinux-policy-migrate-local-changes@targeted.service● │ ├─paths.target● │ ├─slices.target● │ │ ├─-.slice● │ │ └─system.slice● │ ├─sockets.target● │ │ ├─dbus.socket● │ │ ├─systemd-initctl.socket● │ │ ├─systemd-journald.socket● │ │ ├─systemd-shutdownd.socket● │ │ ├─systemd-udevd-control.socket● │ │ └─systemd-udevd-kernel.socket● │ ├─sysinit.target● │ │ ├─dev-hugepages.mount● │ │ ├─dev-mqueue.mount● │ │ ├─kmod-static-nodes.service● │ │ ├─plymouth-read-write.service● │ │ ├─plymouth-start.service● │ │ ├─proc-sys-fs-binfmt_misc.automount● │ │ ├─sys-fs-fuse-connections.mount● │ │ ├─sys-kernel-config.mount● │ │ ├─sys-kernel-debug.mount● │ │ ├─systemd-ask-password-console.path● │ │ ├─systemd-binfmt.service● │ │ ├─systemd-firstboot.service● │ │ ├─systemd-hwdb-update.service● │ │ ├─systemd-journal-catalog-update.service● │ │ ├─systemd-journal-flush.service● │ │ ├─systemd-journald.service● │ │ ├─systemd-machine-id-commit.service● │ │ ├─systemd-modules-load.service● │ │ ├─systemd-random-seed.service● │ │ ├─systemd-sysctl.service● │ │ ├─systemd-tmpfiles-setup-dev.service● │ │ ├─systemd-tmpfiles-setup.service● │ │ ├─systemd-udev-trigger.service● │ │ ├─systemd-udevd.service● │ │ ├─systemd-update-done.service● │ │ ├─systemd-update-utmp.service● │ │ ├─systemd-vconsole-setup.service● │ │ ├─cryptsetup.target● │ │ ├─local-fs.target● │ │ │ ├─-.mount● │ │ │ ├─boot.mount● │ │ │ ├─rhel-import-state.service● │ │ │ ├─rhel-readonly.service● │ │ │ └─systemd-remount-fs.service● │ │ └─swap.target● │ │ └─dev-disk-by\x2duuid-be6981b9\x2d0dba\x2d4bfa\x2da07c\x2d0e70114.● │ └─timers.target● │ └─systemd-tmpfiles-clean.timer● ├─getty.target● │ └─getty@tty1.service● └─remote-fs.targetlines 59-86/86 (END)
- systemctl get-default 查看系统默认的target
[root@xuexi-001 ~]# systemctl get-defaultmulti-user.target
- systemctl set-default multi-user.target
[root@xuexi-001 ~]# systemctl set-default multi-user.targetRemoved symlink /etc/systemd/system/default.target.Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
- cat /usr/lib/systemd/system/sshd.service ······看【install】部分
[root@xuexi-001 ~]# cat /usr/lib/systemd/system/sshd.service[Unit]Description=OpenSSH server daemonDocumentation=man:sshd(8) man:sshd_config(5)After=network.target sshd-keygen.serviceWants=sshd-keygen.service[Service]Type=notifyEnvironmentFile=/etc/sysconfig/sshdExecStart=/usr/sbin/sshd -D $OPTIONSExecReload=/bin/kill -HUP $MAINPIDKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target