Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of adding boot items under Ubuntu

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the methods of adding boot items under Ubuntu". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Method 1: edit the rc.loacl script

The script in the / etc/rc.local file will be executed after Ubuntu is powered on

So we can add the startup script directly to / etc/rc.local.

Of course, it should be added before the statement: exit 0.

Such as:

The code is as follows:

Sudo vi / etc/rc.local

Then add the script code before exit 0.

2. Method 2, add a boot service of Ubuntu.

If you want to add a script file that is executed for boot

You can copy or softly connect the script to the / etc/init.d/ directory first.

Then use the: update-rc.d xxx defaults NN command (NN is the startup order)

Add the script to the queue that initializes the execution.

Note that if the script needs to use the network, NN needs to set a large number, such as 99.

1) copy your startup script to the / etc/init.d directory

The following assumes that your script file name is test.

2) set permissions for script files

The code is as follows:

$sudo chmod 755 / etc/init.d/test

3) execute the following command to put the script in the startup script:

The code is as follows:

$cd / etc/init.d

$sudo update-rc.d test defaults 95

Note: the number 95 is the sequence number of the script, which can be modified according to your own needs. You know what this number does when you have multiple startup scripts and there are successive startup dependencies between them. The output information of this command is as follows:

The code is as follows:

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:

The code is as follows:

$cd / etc/init.d

$sudo update-rc.d-f test remove

The information output from the command is as follows:

The 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

This is the end of the content of "what are the ways to add boot items under Ubuntu". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report