service: command not found

The service command is another way to control SysVinit services through SysVinit scripts. It supports the following subcommands.

Subcommand Used To
{service} status Print current state of service.
{service} start Activate service immediately.
{service} stop Deactivate service immediately.
{service} restart Restart service immediately.
{service} reload Re-read config files while service runs.

Syntax

The syntax of the service command is:

# service [options] [service] [subcommand]

If you encounter the below error while running the service command:

service: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
Debian apt-get install sysvinit-utils
Ubuntu apt-get install sysvinit-utils
Kali Linux apt-get install init-system-helpers
CentOS yum install initscripts
Fedora dnf install initscripts
Raspbian apt-get install sysvinit-utils

service Command Examples

1. To status of a program:

# service vsftpd status 

2. To start a service:

# service vsftpd start 

3. To stop a service:

# service vsftpd stop 

4. To restart a service:

# service vsftpd restart 

5. To see the status fo all the programs:

# service --status-all 

6. To see the help:

# service -h
# service --help 

7. To see the version:

# service --version 

8. Do a full restart (runs script twice with start and stop):

# service service_name --full-restart
Related Post