The difference between. Bashrc and. Bash? Profile

Time:2020-1-17

To distinguish the difference between the two, we must first make clearlogin shellandno-login shellThe difference between.

login shell

When you enter the user name and password through the terminal, and then enter terminal, the shell environment you enter is called login shell, for example, throughsshRemote access to the host.

no-login shell

As the name implies, it is a shell environment that does not need to enter the user name and password. For example, if you have logged in to your desktop computer, you can find it in the application managertermianlIcon, and then double-click to open the terminal, that is, through thegnome,KDEThe terminal entered by this desktop environment is the so-called shell environment you enterno-login shellEnvironmental Science. In short, it means that you want to passlogin shellRun the shell command into the.bash_profileI want to passno-login shellRun the shell command into the.bashrcIn the document.

exception

There’s an exception to thisMac OSIn the system, every time you run terminal, the system will run one for you by defaultlogin shellEnvironment, so you seeMac OSSystem~/There is only one in the directory.bash_profileFile without.bashrcDocuments, that’s why.

How to use two files at the same time?

So if I wasMac OSThe system also wants to put some shell commands into the.bashrcWhat about the file? Of course, it’s not recommended. It doesn’t make sense. Then you can create a.bashrcDocuments. Then in.bash_profileWrite the following code in the file:

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

Read at terminal.bash_profileIt will load after the file.bashrcContents of the file.

Original link

Recommended Today

RCAST 35: add type to currency

– font ALT: Simsun; MSO font charset: 134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:”Cambria Math”; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; Variable; Ose-1: 216301111; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /\* Style […]