46

Using one command to both start and enable systemctl managed software would be useful to spare a few lines in a few scripts, making them a bit more aesthetic (not really a problem but a nice thing to have).

Is there one systemctl command to both start and enable a program controlled by systemctl?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
  • 2
    Relating-only: https://unix.stackexchange.com/q/374280/117549 – Jeff Schaller Jan 20 '19 at 22:30
  • Yeah, it has been discussed in several places like the post Jeff linked to or [here](https://unix.stackexchange.com/a/47715/22142)... even [in comments](https://unix.stackexchange.com/questions/302261/systemd-unit-activate-vs-enable#comment530710_302267) etc... – don_crissti Jan 21 '19 at 14:15

1 Answers1

64

Yes, there is, since systemd 220 (May 2015):

systemctl enable --now

This will enable and start the named units. See the systemctl manpage for details.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164