Two methods to add startup items under Ubuntu

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.