{"id":736,"date":"2021-01-10T00:00:37","date_gmt":"2021-01-10T00:00:37","guid":{"rendered":"https:\/\/dft.wiki\/?p=736"},"modified":"2026-06-09T13:18:42","modified_gmt":"2026-06-09T17:18:42","slug":"run-commands-on-boot-in-linux","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=736","title":{"rendered":"Run Commands on Boot in Linux"},"content":{"rendered":"<p>To execute commands on Linux startup, add them to \/etc\/rc.local:<\/p>\n<pre>sudo nano \/etc\/rc.local<\/pre>\n<p>The default content of this file starts with:<\/p>\n<pre>#!\/bin\/sh<\/pre>\n<p>And ends with:<\/p>\n<pre>exit 0<\/pre>\n<p>Any commands you want to execute must be placed between these two lines.<\/p>\n<p>If the file does not exist, create it and make sure it is owned by <strong>root<\/strong> with permissions set to <strong>755<\/strong>:<\/p>\n<pre>sudo chown root: \/etc\/rc.local\r\nsudo chmod 755 \/etc\/rc.local<\/pre>\n<p>Verify that <strong>rc-local.service<\/strong> is running and enabled to start at boot:<\/p>\n<pre>sudo systemctl status rc-local.service\r\nsudo systemctl enable rc-local.service<\/pre>\n<p>This procedure applies to most Debian-based Linux distributions, but if you are using something other than Ubuntu 20.04 or Raspberry Pi OS, check for any distribution-specific differences.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To execute commands on Linux startup, add them to \/etc\/rc.local: sudo nano \/etc\/rc.local The default [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-736","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=736"}],"version-history":[{"count":4,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/736\/revisions"}],"predecessor-version":[{"id":5800,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/736\/revisions\/5800"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}