2018/05/02 a day of learning about Linux. Bash_profile and. BASHRC differences

Source: Internet
Author: User

Recently has been learning other, causing the blog to be negligent, very bad (in fact, they are lazy ...).

--

Why do you use the. Bash_profile and. BASHRC?

In the normal use, some folders or commands are very long, you need to type a long file path to find this file when executing.

This is too tedious, I should have more records to replace my redundant commands and file paths

--

What are the. bash_profile and. BASHRC?

is the meaning of environment variables, so-called environment variables, is to simplify the definition of your file path and command generated.

Make it easy and quick to find your defined path when you enter it.

--

What is the difference between. Bash_profile and. BASHRC ?

First introduce the definition part: The Linux environment variable configuration method combing (. Bash_profile and. BASHRC differences)

/etc/profile: This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects the shell settings from the configuration file of the/ETC/PROFILE.D directory./ETC/BASHRC:  run bash for each The user of the shell executes the file. When the bash shell is opened, the file is read. ~/.bash_profile: Each user can use this file to enter the shell information dedicated to their own use, when the user logs in, the file is only executed once! By default, He sets some environment variables to execute the user's. bashrc file. ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log on and every time you open a new shell. ~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell). In addition, the variables set in/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, etc. (local) only inherit variables from/etc/profile, they are "parent-child" relationships.

In fact, with the above can be understood, in common. Bash_profile and. BASHRC are all acting on environment variables, only the locations and scopes that affect them are different.

--

Alias

The alias used to set the instruction.

Set ~/.BASRC to set the alias of the directive, which simplifies the operation, just like a shortcut

Cases

Alias h-mysql= ' mysql-ugenee-p83719730-h172.17.42.1 '

At this point I entered the terminal

[Email protected]:~$ h-mysqlmysql>

is equivalent to typing the command

--

Export

Setting environment variables

For example

Kettle_home=/etc/nginxexport Kettle_home

Can be seen under the Env

--

Note: Set environment variables and aliases must be performed

source. BASHRC

will only take effect.

--

There is only so much to use at the moment, and other times to learn the words in return to add.

2018/05/02 a day of learning about Linux. Bash_profile and. BASHRC differences

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.