systemctl.md (974B)
1 # systemctl 2 3 also see [journalctl](journalctl) 4 5 ```bash 6 systemctl list-units [ --all | --type=service ] 7 ``` 8 9 - show all enabled and disabled services 10 ```bash 11 systemctl list-unit-files 12 ``` 13 14 #### create service file 15 ``` 16 vi /etc/systemd/system/<name>.service 17 ``` 18 19 ([manage systemd][]) 20 21 ## user services 22 run `systemctl` (without sudo) and with the `--user` option 23 24 service files are created under '$HOME/.config/systemd/user' 25 26 ### example user service file 27 ``` 28 [Unit] 29 Description=This is an example 30 31 [Service] 32 ExecStart=/path/to/command 33 34 [Install] 35 WantedBy=default.target 36 ``` 37 ([writing user units][]) 38 39 enable and start the user service (without sudo) 40 ``` 41 systemctl --user enable <service> 42 systemctl --user start <service> 43 systemctl --user status <service> 44 ``` 45 46 47 [manage systemd]: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units 48 [writing user units]: https://wiki.archlinux.org/index.php/Systemd/User#Writing_user_units