【Auto-start configuration】Ubuntu set boot auto-start script

The scripts that Ubuntu runs at startup are related to the level of the current operating system. The operating levels of the OS are roughly divided into seven


Table of contents

1. View OS run level

2. Create a self-starting script

3. Add a soft link


1. View OS run level

Enter the command runlevel to view the current system run level. The current system's runlevel is 5

2. Create a self-starting script

Create a self-starting script in  the /etc/init.d/ directory, which will automatically run when the system starts. Assuming that the name of the created script is gzx-autostart.sh, we can add the command to start and execute in this script

sudo touch gzx-autostart.sh

At the same time, we serve the script execution permission

sudo chmod a+x gzx-autostart.sh

3. Add a soft link

We first enter the /etc directory, there are several rcX.d directories under this directory. rc1.d means that when the system operation level is 1, the script corresponding to the soft link in this directory will be run automatically.

The current system operation level is 5, so we need to enter the rc5.d directory and create a soft link S99-autostart in this directory. The linked file is the script file we created in the previous step.

cd /etc/rc5.d
sudo ln -s ../init.d/gzx-autostart.sh S99-autostart

Guess you like

Origin blog.csdn.net/challenglistic/article/details/131864920