How To Use Etc Rc Local
Unit description etc rc d rc local compatibility conditionfileisexecutable etc rc d rc local after network target service type forking execstart etc rc d rc local start timeoutsec 0 remainafterexit yes.
How to use etc rc local. Bin bash add your script or command here example route add net 192 168 0 0 24 gw 192 168 0 100 exit 0 step 3 grant execute access file rc local. On your pi edit the file etc rc local using the editor of your choice. Sudo su systemctl status rc local. Second please fill in the rc local file using bash script. Next run the following command to make sure etc rc local file is executable.
Open the terminal on ubuntu. To save a file in nano text editor press ctrl o then press enter to confirm. Make sure etc rc local file is executable. Add commands below the comment but leave the line exit 0 at the end then save the file and exit. Sudo systemctl enable rc local.
You will learn how to enable etc rc local on ubuntu 20 04 focal fossa during startup. That s the content of ubuntu 16 04 s stock etc rc local file. You must edit with root for example. First you need to create etc rc local file if it doesn t exists. You might use it to start a custom service for example a server that s installed in usr local.
Now make it executable chmod x etc rc local. You can now use this file to execute commands at system boot. Third grant execute access rights to the rc. Adding commands to the bottom of this script is an easy way to perform necessary tasks like starting special services or initialize devices without writing complex initialization. Type the following command in order to switch to the root user you will need to type in a password when prompted.
It is traditionally executed after all the normal system services are started at the end of the process of switching to a multiuser run level. Sudo chmod x etc rc local. Sudo chmod x etc rc local. Save and close the file. The script etc rc local is for use by the system administrator.