System and processes

The service command

Starts, stops or checks a service. On systemd systems it is a shortcut to systemctl.

Syntax

service NOMBRE {start|stop|restart|status}Try it in the terminal →

Most useful options

statusShows whether the service is active or stopped
startStarts it
stopStops it
restartStops it and starts it again
reloadReloads its configuration without stopping it, if the service supports that
--status-allLists the /etc/init.d scripts with their state: [ + ] running, [ - ] stopped, [ ? ] no status command

Copy-ready examples

$ service nginx statuschecks whether the service is running.
$ sudo service nginx restartrestarts the service after changing its configuration. Requires root.
$ sudo service ssh stopstops the SSH server. If it is your only remote access, you may be unable to log back in.
$ sudo service ssh startstarts the SSH server again after the previous example.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
Unit nginxx.service could not be found.On a systemd system, service delegates to systemctl and no unit has that name.Check the name with systemctl list-units --type=service.
nginxx: unrecognized serviceWithout systemd, service finds no script with that name in /etc/init.d.See the available names with ls /etc/init.d or service --status-all.

Typical mistakes

  • Without sudo, starting, stopping or restarting fails. Checking the status normally does not need root.
  • For detail, automatic start or logs, use systemctl and journalctl; service only covers the basics.
  • Before stopping a remote service, check what depends on it: stopping it may cut your access.

Differences from similar commands

  • systemctl: manages systemd units, including start at boot. service translates start, stop, status and reload into their equivalents.
  • update-rc.d: decides whether an init script starts at boot on Debian and Ubuntu. service only acts right now.

Related commands

FAQ

Does service still work on modern systems?

Yes, it is still available on Debian and Ubuntu. For detailed status, logs or automatic start, use systemctl.

Why does it ask for sudo?

Starting, stopping or restarting changes the state of the system and needs administrator rights. Checking the status normally does not.

How do I see which services I have?

With systemctl list-units --type=service, which is the real list on systemd systems.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course