How To Use Etc Rc Local
The script etc rc local is for use by the system administrator.
How to use etc rc local. That s the content of ubuntu 16 04 s stock etc rc local file. If you enable etc rc local to run on system boot using the command. You can now use this file to execute commands at system boot. Just paste your commands above the line that says exit 0. 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.
Make sure etc rc local file is executable. Sudo chmod x etc rc local. Sudo su systemctl status rc local. To exit the file press ctrl x. To save a file in nano text editor press ctrl o then press enter to confirm.
Contents of rc local file bin sh e rc local this script is executed at the end of each multiuser runlevel. Sudo i nano etc rc local step 2 fill with bash script in the rc local file. Sudo systemctl enable rc local. You will learn how to enable etc rc local on ubuntu 20 04 focal fossa during startup. You must edit with root for example.
Sudo chmod x etc rc local. First you need to create etc rc local file if it doesn t exists. Finally enable the service on system boot. 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. 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.
You might use it to start a custom service for example a server that s installed in usr local. Second please fill in the rc local file using bash script. Type the following command in order to switch to the root user you will need to type in a password when prompted. Open the terminal on ubuntu. Now make it executable chmod x etc rc local.