What is the difference between /etc/rc.local and ~/.bashrc?

李哲源

This is a linux related problem. I have searched around but did not get a good explanation.

It seems to me that both file configure the setup when I log in, but is there any difference? I notice that there seems to be "some rule" in deciding what should go into two different files. For example, if I need to add a specific search path to $PATH, I should do it in ~/.bashrc. But if I decide to change some system setting, like

/sys/class/backlight

or

/sys/devices/cpu/cpu#/online

then I have to do this in /etc/rc.local, otherwise it will not work.

Is it because these configurations can not differ between users?

Thanks.

Harry

The difference is in when they are run and who they're running as when run i.e. rc.local is run on a change of run level and it runs as root. bashrc is bash specific and run on a non login shell as a particular user.

You can find a good explanation of rc.local here

The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.

and you can find what you need about bashrc

man bash

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.

There's more info on bashrc in this question...

https://superuser.com/questions/49289/what-is-the-bashrc-file

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What's the difference between .bashrc and .inputrc

From Dev

What is the difference between /etc/profile and .bashrc

From Dev

What is the difference between local and .local in ubuntu?

From Dev

What is the difference between adding to PATH on the CLI vs in bashrc

From Dev

What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc ...?

From Java

What is the difference between local value and master value

From Dev

What's the difference between .local, .home, and .lan?

From Dev

What is the difference between local value and master value

From Dev

What is the difference between /opt and /usr/local?

From Dev

What is the difference between /etc and /usr/local/etc

From Dev

What is the difference between local and remote IP forwarding?

From Dev

What is the difference between static and local dns

From Java

What is the difference between .env.local and .env.development.local?

From Dev

What is the difference between background-attachment : scroll and local?

From Java

What is the difference between local runtime and hosted runtime in Google Colab?

From Dev

What's the difference between working directory and local repository?

From Dev

What is the difference between Local and External Parameter Names in Swift

From Dev

What is the difference between application state and component local state in Clojurescript Om?

From Dev

What is the difference between Local beam search and Stochastic beam search?

From Dev

What is the difference between rc, rc.local and rc.sysinit?

From Dev

What is the difference between Local and External Parameter Names in Swift

From Dev

What is the difference between //*[local-name()='element'] and //*:element?

From Dev

What is the difference between a Matrix4 "World Transform" and "Local Transform"?

From Dev

What is the difference between /usr/lib and /usr/local/lib?

From Dev

What is the difference between Genetic Algorithm and Iterated Local Search Algorithm?

From Dev

What is the difference between local and global data association in object tracking context?

From Dev

Difference between .bashrc and .bash_profile

From Java

What's the difference between `yum install <local path>` and `yum localinstall <local path>`

From Dev

What's the difference between /etc/rc.local and /etc/init.d/rc.local?

Related Related

  1. 1

    What's the difference between .bashrc and .inputrc

  2. 2

    What is the difference between /etc/profile and .bashrc

  3. 3

    What is the difference between local and .local in ubuntu?

  4. 4

    What is the difference between adding to PATH on the CLI vs in bashrc

  5. 5

    What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc ...?

  6. 6

    What is the difference between local value and master value

  7. 7

    What's the difference between .local, .home, and .lan?

  8. 8

    What is the difference between local value and master value

  9. 9

    What is the difference between /opt and /usr/local?

  10. 10

    What is the difference between /etc and /usr/local/etc

  11. 11

    What is the difference between local and remote IP forwarding?

  12. 12

    What is the difference between static and local dns

  13. 13

    What is the difference between .env.local and .env.development.local?

  14. 14

    What is the difference between background-attachment : scroll and local?

  15. 15

    What is the difference between local runtime and hosted runtime in Google Colab?

  16. 16

    What's the difference between working directory and local repository?

  17. 17

    What is the difference between Local and External Parameter Names in Swift

  18. 18

    What is the difference between application state and component local state in Clojurescript Om?

  19. 19

    What is the difference between Local beam search and Stochastic beam search?

  20. 20

    What is the difference between rc, rc.local and rc.sysinit?

  21. 21

    What is the difference between Local and External Parameter Names in Swift

  22. 22

    What is the difference between //*[local-name()='element'] and //*:element?

  23. 23

    What is the difference between a Matrix4 "World Transform" and "Local Transform"?

  24. 24

    What is the difference between /usr/lib and /usr/local/lib?

  25. 25

    What is the difference between Genetic Algorithm and Iterated Local Search Algorithm?

  26. 26

    What is the difference between local and global data association in object tracking context?

  27. 27

    Difference between .bashrc and .bash_profile

  28. 28

    What's the difference between `yum install <local path>` and `yum localinstall <local path>`

  29. 29

    What's the difference between /etc/rc.local and /etc/init.d/rc.local?

HotTag

Archive