service(8)

๐Ÿ’– service(8) โ€” the System Manager's Manual glow-up ๐Ÿ’–

okay bestie, welcome to service(8), straight out of the System Manager's Manual โœจ this is the lil command that runs your System V init scripts, and honestly? she's doing the most with the least. let's get into it ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

service โ€” run a System V init script ๐ŸŽ€


โœจ SYNOPSIS โœจ

service SCRIPT COMMAND [OPTIONS]

service --status-all

service --help | -h | --version

like, that's the whole vibe check. three shapes, pick your fighter ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

service runs a System V init script in as predictable an environment as possible โ€” which lowkey means it yeets most of your environment variables out the window and sets the current working directory to /. no cap. clean slate energy โœจ

the SCRIPT parameter specifies a System V init script, and she lives at /etc/init.d/SCRIPT ๐Ÿ  the supported values of COMMAND depend on whichever script you invoked, because service is a total girlboss delegator โ€” she passes COMMAND and OPTIONS to the init script unmodified. she does not edit. she does not interpret. she just hands it over ๐Ÿ’…

โœจ pro tip from the ancestors: all scripts should support at least the start and stop commands. that's the bare minimum, babes.

now for the special case ๐ŸŒˆ if COMMAND is --full-restart, the script gets run twice โ€” first with the stop command, then with the start command. it's giving "we're doing this properly" ๐Ÿ˜ค

service --status-all runs all the init scripts, in alphabetical order, with the status command. very organized. very demure. very mindful ๐Ÿงš

and here's the plot twist ๐Ÿ˜ญ if the init script file does not exist, the script tries to use legacy actions. if there's no suitable legacy action found and COMMAND is one of the actions specified in the LSB Core Specification, then input is redirected to systemctl. otherwise? the command fails with return code 2 ๐Ÿ’€ so close, yet so far.


๐ŸŽ€ FILES ๐ŸŽ€

  • /etc/init.d โ€” the directory containing System V init scripts. it's the home address of every script you're about to summon ๐Ÿก

๐Ÿ’œ ENVIRONMENT ๐Ÿ’œ

  • PATH, TERM โ€” these two are literally the only environment variables passed to the init scripts. that's it. that's the whole guest list. everyone else got left on read ๐Ÿ™ˆ

โญ SEE ALSO โญ

go read those too, bestie, they're all in the same friend group ๐Ÿซถ


๐Ÿ’– that's the whole page!! this one came from the System Manager's Manual, dated Jan 2006 โ€” yeah she's been iconic for a minute ๐Ÿ‘‘ thanks for reading, mwah ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from