Ubuntu systemd systemctl rc.local Cheatsheet

Infos

  • systemctl list-units --no-pager
  • systemctl list-units --no-pager | grep apt
  • systemctl list-unit-files --no-pager | grep apt
  • systemctl status apt-daily.timer
  • systemctl show apt-daily.timer
  • systemctl is-enabled apt-daily-upgrade.timer

 

Enable a service

  • systemctl enable apt-daily-upgrade.timer

 

Files:

  • ls -la /etc/systemd/system/timers.target.wants

 

Enable rc.local

https://sleeplessbeastie.eu/2020/10/30/how-to-execute-rc-local-shell-script-during-boot-using-systemd/

  • /lib/systemd/system-generators/systemd-rc-local-generator
  • systemctl enable rc-local.service 
  • vi /etc/rc.local
    • #!/bin/bash
      
      echo foo >> /foo.txt
      
      exit 0
  • chmod 744 /etc/rc.local

  • reboot