Services and process management
PS command
ps aux- display all running services (snapshot) ex.ps aux | grep "ssh"sudo kill <pid>- kill process with provided pid, provided bypscommandpkill <process-name>- kill process by name :sunglasses:
OG COMMAND -> ps -auxf (tree structure)
Systemd (Ubuntu/Debian)
systemctl | grep <service_name>- display all running services or grep onesudo systemctl is-enabled ssh- check if service is enabledsystemctl list-unit-files --type=service --state=enabled- list all enabled servicessudo systemctl enable --now ssh- Enable and start servicesudo systemctl disable --now ssh- Disable and stop servicesudo systemctl status ssh- check status of servicesudo systemctl start ssh- start servicesudo systemctl stop ssh- stop servicesystemctl --failed --type=service- list failed servicessystemctl list-units --type=service- list all running servicessystemctl list-units --type=service --state=inactive- list all inactive servicessystemctl list-units --type=service --all- list all services
RedHat/CentOS
chkconfig --list- list all serviceschkconfig --list | grep ssh- list service by namechkconfig sshd on- enable servicechkconfig sshd off- disable serviceservice sshd status- check status of serviceservice sshd start- start serviceservice sshd stop- stop serviceservice sshd restart- restart serviceservice sshd reload- reload serviceservice sshd condrestart- restart service if it is already runningservice sshd try-restart- restart service if it is already runningservice sshd force-reload- force reload service