linux systemctl 命令

$ systemctl --version

$ systemctl

start:立刻启动后面接的 unit。stop:立刻关闭后面接的 unit。restart:立刻关闭后启动后面接的 unit,亦即执行 stop 再 start 的意思。reload:不关闭 unit 的情况下,重新载入配置文件,让设置生效。enable:设置下次开机时,后面接的 unit 会被启动。disable:设置下次开机时,后面接的 unit 不会被启动。status:目前后面接的这个 unit 的状态,会列出有没有正在执行、开机时是否启动等信息。is-active:目前有没有正在运行中。is-enable:开机时有没有默认要启用这个 unit。kill :不要被 kill 这个名字吓着了,它其实是向运行 unit 的进程发送信号。show:列出 unit 的配置。mask:注销 unit,注销后你就无法启动这个 unit 了。unmask:取消对 unit 的注销。

关于 unit 的启动状态,除了 enable 和 disable 之外还有:static:这个 unit 不可以自己启动,不过可能会被其它的 enabled 的服务来唤醒。mask:这个 unit 无论如何都无法被启动!因为已经被强制注销。可通过 systemctl unmask 改回原来的状态。

关于 unit 的运行状态 Active,除了 active 和 inactive 之外还有:active (exited):仅执行一次就正常结束的服务,目前并没有任何程序在系统中执行。举例来说,开机或者是挂载时才会进行一次的 quotaon 功能,就是这种模式! Quotaon 不需要一直执行,只在执行一次之后,就交给文件系统去自行处理。通常用 bash shell 写的小型服务,大多是属于这种类型。active (waiting):正在执行当中,不过还再等待其他的事件才能继续处理。举例来说,打印的相关服务就是这种状态。

$ systemctl enable prometheus.service

$ systemctl show prometheus.service

$ systemctl mask prometheus.service

$ systemctl unmask prometheus.service

list-units:列出当前已经启动的 unit,如果添加 -all 选项会同时列出没有启动的 unit。list-unit-files:根据 /lib/systemd/system/ 目录内的文件列出所有的 unit。--type=TYPE:可以过滤某个类型的 unit。

$ systemctl list-unit-files

$ systemctl list-units --type=service --all

--type=mount 就可以了:

$ systemctl --failed

--type=target 就可以用 systemctl list-units 命令查看系统中默认有多少种 target:

graphical.target:就是文字界面再加上图形界面,这个 target 已经包含了下面的 multi-user.target。multi-user.target:纯文本模式!rescue.target:在无法使用 root 登陆的情况下,systemd 在开机时会多加一个额外的临时系统,与你原本的系统无关。这时你可以取得 root 的权限来维护你的系统。emergency.target:紧急处理系统的错误,在无法使用 rescue.target 时,可以尝试使用这种模式!shutdown.target:就是执行关机。getty.target:可以设置 tty 的配置。

systemctl [command] [unit.target] get-default:取得目前的 target。set-default:设置后面接的 target 成为默认的操作模式。isolate:切换到后面接的模式。

$ systemctl get-default

$ systemctl set-default multi-user.target

$ systemctl isolate multi-user.target

$ systemctl emergency # 强制进入紧急救援模式

suspend:暂停模式会将系统的状态保存到内存中,然后关闭掉大部分的系统硬件,当然,并没有实际关机。当用户按下唤醒机器的按钮,系统数据会从内存中回复,然后重新驱动被大部分关闭的硬件,所以唤醒系统的速度比较快。hibernate:休眠模式则是将系统状态保存到硬盘当中,保存完毕后,将计算机关机。当用户尝试唤醒系统时,系统会开始正常运行,然后将保存在硬盘中的系统状态恢复回来。因为数据需要从硬盘读取,因此唤醒的速度比较慢(如果你使用的是 SSD 磁盘,唤醒的速度也是非常快的)。

systemctl list-dependencies [unit] [--reverse]       选项 --reverse 会反向追踪是谁在使用这个 unit。

$ systemctl list-dependencies multi-user.target --reverse

graphical.target 依赖 multi-user.target。

/lib/systemd/system/ 大多数 unit 的配置文件都放在这个目录下。 /run/systemd/system/ 系统运行过程中产生的脚本,比如用户相关的脚本和会话相关的脚本。/etc/systemd/system/ 这个目录中主要的文件都是指向 /lib/systemd/system/ 目录中的链接文件。

$ systemctl list-sockets

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


LinuxSystemd服务(2021.07.09)目录LinuxSystemd服务(2021.07.09)一、概述二、配置文件2.1Unit2.2Service2.3Install三、开机启动四、启动服务五、查看状态六、停止服务七、重启服务一、概述本文将介绍通过systemd来实现服务的自启动。systemd是一套系统启动和管理的工具,字
opidrvabortingprocessM002ospid(3561)asaresultofORA-600ORA-27300:操作系统相关操作:semctl失败,状态为:22ORA-27301:操作系统故障消息:InvalidargumentORA-27302:错误发生在:sskgpwrm1ORA-27157:已删除了操作系统发送/等待功能ORA-27300:操作系统相关操作
安装好haproxy后,配置正确无法启动,看日志:Feb1309:32:50cluster-node2systemd:StartedHAProxyLoadBalancer.Feb1309:32:50cluster-node2haproxy-systemd-wrapper:[ALERT]043/093250(6538):Startingproxymysql-pxc-cluster:cannotbindsocket[192.168.22.3
Linux 系统与服务管理工具Systemd被曝存在3大漏洞,影响几乎所有Linux发行版。Systemd是Linux系统的基本构建块,它提供了对系统和服务的管理功能,以PID1运行并启动系统的其它部分。目前大部分Linux发行版都以Systemd取代了原有的SystemV。安全公司Qualys近日发
一、systemd查看日志文件有隐藏 systemctlstatusSERVICE-l-l选项显示完整选项 journalctl-uSERVICE使用journalct命令查看 二、写一个systemd的配置文件,让nginx服务可以开机启动[Unit]Description=nginx[Service]Type=forkingPIDFile=/varunginx.pidExec
不要在mp目录下保存文件,该目录会定期清理文件mp默认保存10天/varmp默认保存30天配置文件:/usr/libmpfiles.dmp.conf默认配置文件:#Thisfileispartofsystemd.##systemdisfreesoftware;youcanredistributeitand/ormodifyit#underthetermsofthe
Step1:查看系统默认运行级别[root@node-1html]#systemctlget-default    //图形界面graphical.target[root@node-1html]#systemctllist-units--type=target  //查看支持的运行级别Step2:更改运行级别为level3 [root@node-1html]#systemctlset-defaultm
1.安装蓝牙驱动管理#apt-getinstallblueman2.打开蓝牙驱动管理,关闭设备3.关闭蓝牙开机启动服务#systemctldisablebluetooth.service#/lib/systemd/systemd-sysv-installdisablebluetooth4.重启reboot 
dhcpcd项目地址:http://www.linuxfromscratch.org/blfs/view/stable-systemd/basicnet/dhcpcd.html1.下载dhcpcd包并校验md5wgethttp:/oy.marples.name/downloads/dhcpcd/dhcpcd-7.0.7.tar.xzmd5sum-cmd5sums2.解压并进入包目录tar-xvfdhcpcd-7.0.7.tar.xzcddhcp
1.背景首先,我们先看一下/etc/init.d/README内容:Youarelookingforthetraditionalinitscriptsin/etcc.d/init.d,andtheyaregone?Here'sanexplanationonwhat'sgoingon:Youarerunningasystemd-basedOSwheretraditionalinitscriptshavebe
早就发现了,Arch的systemd提供的那个rc-local.service貌似有问题,rc.local不会执行。因为没用rc.local,一直没管。解决方法源自这里,需要稍加改动:http://superuser.com/questions/278396/systemd-does-not-run-etc-rc-local建立文件/etc/systemd/systemclocal.service(我怕和系
转载:https://www.cnblogs.com/sparkdev/p/8521812.html我们运行linux服务器的主要目的是通过运行程序提供服务,比如mysql、webserver等。因此管理linux服务器主要工作就是配置并管理上面运行的各种服务程序。在linux系统中服务程序的管理主要由init系统负责。如同笔者在
系统:Ubuntu18.04.02K8s版本:1.13.4故障现象:安装KubeDNS后,Pod内无法ping通外网域名,访问外网IP、K8s内部域名或者IP均正常  原因分析:查看Pod中的resolv.conf:kubectlexecbusybox--cat/etcesolv.confnameserver10.96.0.10searchdefault.svc.cluster.localsvc.cl
1.journalctl :日志查看工具journalctl -n5 //查看最近3条日志journalctl -perr //查看错误日志journalctl -overbose //查看日志的详细参数journalctl --since //查看从什么时间开始的日志journalctl --until //查看到什么时间为止的日志
此案例是以一个主,三个node来部署的,当然node可以根据自己情况部署192.168.1.130master192.168.1.131node1192.168.1.132node2192.168.1.133node3合法的EnableNTPonmasterandallnodes:[root@k-master~]#yum-yinstallntp[root@k-master~]#systemctlstartntpd[r
常用安装包下载yuminstall-yepel-releaseyum-yinstallbash-completionyum-yinstallnet-toolsyum-yinstalliprouteyum-yinstallwgetvimyum-yinstalllrzsznmaptreedos2unixnctelnetyum-yinstallopenssl一、系统类型1.1sysvinit1.系统第一个进程(p
修改了/etc/systemd/system.conf以后,发现不生效?修改了/etc/systemd/system.conf以后,必须使用systemctldaemon-reexec命令才能生效,使用systemctldaemon-reload是没有用的。daemon-reload重新加载的是所有单元文件,而不是systemd本身的配置。一定要注意了。被坑了。#addin/
Manjaro启动项目及服务配置备忘===============系统服务GUI管理搜索 systemdgenie 并安装,类似Windows的服务管理。================系统启动项目的快捷方式放在如下2个地方:/etc/xdg/autostart/cd~/.config/autostart,比如:/homeom/.config/autostart/===============#net
*1、systemd查看日志文件有隐藏该如何处理?答:Centos7.x使用systemd提供的journalctl日志管理a.基本上,系统由systemd所管理,那所有经由systemd启动的服务()如果在启动或结束的过程中发生了一些问题或是正常的信息),就会将该信息由systemd-journald.service以二进制的方式记录下来,之后
环境:centos7 创建的开机启动的链接地址: /etc/systemd/system/multi-user.target.wants/ 如:[root@tiaobanjisystem]#ll/etc/systemd/system/multi-user.target.wantsotal0lrwxrwxrwx.1rootroot38Feb2812:18auditd.service->/usr/lib/systemd/system/audit