This article mainly introduces two methods for adding boot items under Ubuntu. you can add a boot script to ubuntu. For more information, see the following tag: Ubuntu.
1. Method 1: Edit the rc. loacl script
After Ubuntu is started, the script in the/etc/rc. local file will be executed,
Therefore, we can directly add the startup script in/etc/rc. local.
Of course, you must add it to the statement before exit 0.
For example:
Copy codeThe code is as follows: sudo vi/etc/rc. local
Then add the script code before exit 0.
2. Method 2: Add an Ubuntu startup service.
If you want to add a script file for startup,
You can copy or soft connect the script to the/etc/init. d/directory,
Then run the: update-rc.d xxx defaults NN command (NN for the startup order ),
Add the script to the queue for initialization.
Note: If the script requires a network, NN needs to set a large number, for example, 99.
1) copy your startup script to the/etc/init. d Directory.
Assume that the file name of your script is test.
2) set the permission for the script file
Copy codeThe code is as follows: $ sudo chmod 755/etc/init. d/test
3) execute the following command to put the script into the startup script:
Copy codeThe code is as follows: $ cd/etc/init. d
$ Sudo update-rc.d test defaults 95
Note: The number 95 indicates the sequence number started by the script. you can modify the sequence number as needed. When you have multiple startup scripts and dependencies between them are successively started, you will know the specific functions of this number. The output information of this command is as follows:
Copy codeCode: update-rc.d: warning:/etc/init. d/test missing LSB information
Update-rc.d: see
Adding system startup for/etc/init. d/test...
/Etc/rc0.d/K95test-> ../init. d/test
/Etc/rc1.d/K95test-> ../init. d/test
/Etc/rc6.d/K95test->.../init. d/test
/Etc/rc2.d/S95test->.../init. d/test
/Etc/rc3.d/S95test-> ../init. d/test
/Etc/rc4.d/S95test-> ../init. d/test
/Etc/rc5.d/S95test-> ../init. d/test
How to uninstall the startup script:
Copy codeThe code is as follows: $ cd/etc/init. d
$ Sudo update-rc.d-f test remove
The command output information is as follows:
Copy codeThe code is as follows: Removing any system startup links for/etc/init. d/test...
/Etc/rc0.d/K95test
/Etc/rc1.d/K95test
/Etc/rc2.d/S95test
/Etc/rc3.d/S95test
/Etc/rc4.d/S95test
/Etc/rc5.d/S95test
/Etc/rc6.d/K95test