start 启动
┌──(root㉿kali)-[~]
└─# systemctl start apache2
stop 停止
┌──(root㉿kali)-[~]
└─# systemctl stop apache2
┌──(root㉿kali)-[~]
└─# echo $?
0
restart 重启
enable 把服务设置开机启动
┌──(root㉿kali)-[~]
└─# systemctl enable apache2
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
┌──(root㉿kali)-[~]
└─# systemctl is-enabled apache2
enabled
disable 把服务设置开机不启动
is-enabled 查询是否开机启动
┌──(root㉿kali)-[~] 查看进程
└─# ps aux | grep apache2
root 3032 0.0 0.2 6568 2304 pts/2 S+ 09:47 0:00 grep --color=auto apache2
┌──(root㉿kali)-[~] 查看端口
└─# netstat -tunlp | grep 80
┌──(root㉿kali)-[~]
└─# systemctl is-enabled ssh
disabled
┌──(root㉿kali)-[~]
└─# systemctl is-enabled apache2
disabled
status 查询服务的状态
┌──(root㉿kali)-[~]
└─# systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: disabled)
Active: active (running) since Fri 2023-08-18 09:54:44 CST; 2min 32s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 6773 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 6790 (apache2)
Tasks: 6 (limit: 1014)
Memory: 28.8M
CPU: 217ms
CGroup: /system.slice/apache2.service
├─6790 /usr/sbin/apache2 -k start
├─6793 /usr/sbin/apache2 -k start
├─6794 /usr/sbin/apache2 -k start
├─6795 /usr/sbin/apache2 -k start
├─6796 /usr/sbin/apache2 -k start
└─6797 /usr/sbin/apache2 -k start
8月 18 09:54:43 kali systemd[1]: Starting apache2.service - The Apache HTTP Server...
8月 18 09:54:44 kali systemd[1]: Started apache2.service - The Apache HTTP Server.
pstree 查看进程树
┌──(root㉿kali)-[~]
└─# pstree
systemd─┬─ModemManager───3*[{ModemManager}]
├─NetworkManager───3*[{NetworkManager}]
├─agetty
├─apache2───5*[apache2]
├─colord───3*[{colord}]
├─cron
├─dbus-daemon
├─haveged
├─lightdm─┬─Xorg───{Xorg}
│ ├─lightdm─┬─xfce4-session─┬─Thunar───3*[{Thunar}]
│ │ │ ├─agent───3*[{agent}]
│ │ │ ├─blueman-applet───4*[{blueman-applet}]
│ │ │ ├─light-locker───4*[{light-locker}]
│ │ │ ├─nm-applet───4*[{nm-applet}]
│ │ │ ├─polkit-gnome-au───3*[{polkit-gnome-au}]
│ │ │ ├─ssh-agent
│ │ │ ├─xfce4-panel─┬─panel-1-whisker───3*[{panel-1-whis+
│ │ │ │ ├─panel-13-cpugra───3*[{panel-13-cpu+
│ │ │ │ ├─panel-14-systra───3*[{panel-14-sys+
│ │ │ │ ├─panel-15-genmon───3*[{panel-15-gen+
│ │ │ │ ├─panel-16-pulsea───3*[{panel-16-pul+
│ │ │ │ ├─panel-17-notifi───3*[{panel-17-not+
│ │ │ │ ├─panel-18-power-───3*[{panel-18-pow+
│ │ │ │ ├─panel-22-action───3*[{panel-22-act+
│ │ │ │ └─3*[{xfce4-panel}]
│ │ │ ├─xfce4-power-man───3*[{xfce4-power-man}]
│ │ │ ├─xfdesktop───3*[{xfdesktop}]
│ │ │ ├─xfsettingsd───3*[{xfsettingsd}]
│ │ │ ├─xfwm4───4*[{xfwm4}]
│ │ │ ├─xiccd───3*[{xiccd}]
│ │ │ └─3*[{xfce4-session}]
│ │ └─3*[{lightdm}]
│ └─3*[{lightdm}]
├─polkitd───3*[{polkitd}]
├─qterminal─┬─zsh───sudo───sudo───su───zsh───pstree
│ └─2*[{qterminal}]
├─qterminal─┬─zsh
│ └─2*[{qterminal}]
├─rtkit-daemon───2*[{rtkit-daemon}]
├─systemd─┬─(sd-pam)
│ ├─at-spi-bus-laun─┬─dbus-daemon
│ │ └─4*[{at-spi-bus-laun}]
│ ├─at-spi2-registr───3*[{at-spi2-registr}]
│ ├─dbus-daemon
│ ├─dconf-service───3*[{dconf-service}]
│ ├─gnome-keyring-d───4*[{gnome-keyring-d}]
│ ├─gpg-agent
│ ├─gvfs-afc-volume───4*[{gvfs-afc-volume}]
│ ├─gvfs-goa-volume───3*[{gvfs-goa-volume}]
│ ├─gvfs-gphoto2-vo───3*[{gvfs-gphoto2-vo}]
│ ├─gvfs-mtp-volume───3*[{gvfs-mtp-volume}]
│ ├─gvfs-udisks2-vo───4*[{gvfs-udisks2-vo}]
│ ├─gvfsd─┬─gvfsd-trash───3*[{gvfsd-trash}]
│ │ └─3*[{gvfsd}]
│ ├─gvfsd-fuse───6*[{gvfsd-fuse}]
│ ├─gvfsd-metadata───3*[{gvfsd-metadata}]
│ ├─obexd
│ ├─2*[pipewire───2*[{pipewire}]]
│ ├─pipewire-pulse───2*[{pipewire-pulse}]
│ ├─wireplumber───5*[{wireplumber}]
│ ├─xfce4-notifyd───3*[{xfce4-notifyd}]
│ └─xfconfd───3*[{xfconfd}]
├─systemd-journal
├─systemd-logind
├─systemd-timesyn───{systemd-timesyn}
├─systemd-udevd
├─udisksd───5*[{udisksd}]
├─upowerd───3*[{upowerd}]
├─vmtoolsd───3*[{vmtoolsd}]
├─vmtoolsd───4*[{vmtoolsd}]
├─vmware-vmblock-───2*[{vmware-vmblock-}]
└─xcape───{xcape}
本文来自博客园,作者:depressiom,转载请注明原文链接:https://www.cnblogs.com/depressiom/p/17639638.html