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

The instruction in rc.local in CentOS7 cannot take effect.

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Question:

When / etc/rc.local sets the self-boot command on the system, restart the computer, the instructions in the file will not take effect.

I compiled and installed a mongodb database service here, and then modified the environment variables. Written to the .bash _ profile file, the command can be executed directly in shell.

View the file, the command of the file is also correct

The instruction will not take effect after restart.

First, before summing up the problems, we must first understand the role of several documents.

Rc.local

Path / etc/rc.d/rc.local or / etc/rc.local (soft connection file)

Function: it is used to boot some specified instructions.

. / .bash _ profile:

Path: hidden files under the root directory of each user

Function, used to set the user's environment variables, personal settings, after the setting can only be used by yourself.

/ etc/profile:

Path: / etc/profile

Function: used to set the environment variables of all users, the overall setting, after the settings are completed, all users can use the

Second, find out the causes of the problems.

In linux, when there is a problem with a file, you should first check the integrity and permissions of the file. (personal habits).

(1) when starting, the execution of the document is successively.

Although I have modified the environment variables here, the / etc/rc.local file is executed before the / etc/profile or .bash _ profile file when the computer starts.

Therefore, I have to order here that the form of absolute path should be used. (which mongod).

(2) the right to execute the file.

View the soft connection file:

Most people will have problems here because what is shown here has executable permissions. The final execution of this file is still going to the / etc/rc.d/rc.local file, so the file permissions we need to see should be the source file.

It can be seen here that the file does not have execution permission at all, so when the computer is powered on, the file will not be executed.

Solution (1) when executing a command, write the command as the absolute path to the execution file (2) attach executable permissions to the / etc/rc.d/rc.local file

Chmod + x / etc/rc.d/rc.local

Just restart it when you're done.

IV. Summary

One of the reasons for this problem is that / etc/rc.d/rc.local does not have the execution permission (the version problem, depending on the situation, may drop this file later). Second, the execution sequence of / etc/rc.d/rc.local file and / etc/profile file is not recognized clearly. It can be solved by modifying file permissions and instruction execution methods.

In fact, here, careful students may notice the comments in the / etc/rc.d/rc/local file.

I've made it clear.

It's all my fault that my English is too poor. I skipped it when I saw it.

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

Network Security

Wechat

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

12
Report