One of my favorite things in Linux is that there is always some function or configuration or program that allows you to automate tasks or processes, such as when you need to execute scripts or any other command (automatically mount drives, run a check, log, etc.). etc) when starting our Linux distribution automatically and transparently.
The rc.local file to the rescue
There are many ways to execute terminal commands when logging into our Linux, one of them is through the rc.local file which is located at: /etc/rc.local.
By default fedora does not include this file; although it can be created and will be taken over by the OS without any inconvenience.
The file is plain text and can be opened by programs for this purpose such as Nano, Vim or Gedit; when opening the file we will see the following content:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
If we want to run an sh script called script.sh when Linux starts we add:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sh <ruta>/script.sh
exit 0
Where <path> is the path of our file.
And this is all, when starting our system we will get the previously specified file to run.
![Andrés Cruz Andrés Cruz](/public/images/perfil.jpg)
Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter