On a minimal Linux system sometimes you can face the error while dealing with any system service to start|stop|restart|enable it. This error “bash: service: command not found” appears because the “initscripts” package has not been installed on your system.
Here are the commands to install Service on different Linux operating systems-
Debian/Ubuntu
apt install sysvinit-utils
Kali Linux
apt install init-system-helpers
RHEL/CentOS/Rocky Linux/ AlmaLinux
yum install initscripts
Fedora
dnf install initscripts
Raspbian
apt-get install sysvinit-utils
Once the installation is completed, you can use the Service command to handle various Linux services-
Common service command syntax.
To Start/Stop/Restart/Reload service
service service-name start|stop|restart|reload
example– sudo service apache2 start
For full restart
service system-service-name --full-restart
example– sudo service mysql --ful-restart
Show the current status of a service:
service system-service-name status
example– sudo service apache2 status
List the status of all services:
service --status-all
[root@68e9dbdfbe9f /] # systemctl status docker
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down
Use Service command instead systemctl