2018/05/02 The difference between .bash_profile and .bashrc in Linux every day

I have been learning other things recently, which has caused the blog to be neglected, which is very bad (in fact, I am lazy...).

--

Why use .bash_profile and .bashrc?

In normal use, some folders or commands are very long, and you need to type a long file path to find the file during execution.

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

--

What are .bash_profile and .bashrc?

It is the meaning of environment variables. The so-called environment variables are generated to simplify the definition of your file paths and commands.

It makes it easy and quick to find the path you defined when typing.

--

What is the difference between .bash_profile and .bashrc  ?

First introduce the definition part: Combing the environment variable configuration method under Linux (the difference between .bash_profile and .bashrc)

/etc/profile: This file sets the environment information for each user of the system. When the user logs in for the first time, this file is executed. It collects the shell settings from the configuration files in the /etc/profile.d directory.

/etc/bashrc: Execute this file for every user running the bash shell. This file is read when the bash shell is opened.
~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use. When the user logs in, this file is executed only once! By default, he sets some environment variables and executes the user's .bashrc file.
~/.bashrc: This file contains bash information specific to your bash shell, which is read when you log in and every time you open a new shell.
~/.bash_logout: This file is executed every time you exit the system (exit the bash shell).
 
In addition, the variables (global) set in /etc/profile can act on any user, while the variables (local) set in ~/.bashrc can only inherit the variables in /etc/profile, they are "father and son" "relation.

In fact, with the above, you can understand. Generally speaking, .bash_profile and .bashrc both act on environment variables, but the affected locations and scopes are different.

--

alias

The alias used to set the directive.

Setting ~/.basrc can set aliases for directives, which can simplify things, just like shortcuts

example

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

At this point I type in the terminal

vagrant@lims2:~$ h-mysql

mysql>

It's like typing a command

--

export

Set environment variables

E.g

KETTLE_HOME=/etc/nginx
export KETTLE_HOME

can be seen under env

--

Note: The set environment variables and aliases must be executed

source .bashrc

will take effect

--

There is only so much I have used at present, and I will come back to supplement it if I learn it at other times.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325259146&siteId=291194637