To use a good bash shell, first of all to understand the bash shell environment configuration, only the configuration, we will be handy, to configure, we must understand the type of bash configuration file, and then according to the actual needs to do some corresponding additions or modifications.
One, bash configuration files
(i) by effective scope: global configuration, personal configuration
1. Global configuration:
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
2. Personal configuration:
~/.bash_profile
~/.bashrc
(ii) by function: Profiile class, BASHRC class
1. Profile class: Provides configuration for the interactive login shell
Global:/etc/profile,/etc/profile.d/*.sh
Personal: ~/.bash_profile
Function:
(1) for defining environment variables
(2) run a command or script
2. BASHRC class: Provides configuration for non-interactive and interactive login shells
Global:/ETC/BASHRC
Personal: ~/.BASHRC
Function:
(1) Defining command aliases and functions
(2) Defining local variables
Two ways of Shell login: Interactive login, non-interactive login
1. Interactive login:
(1) Directly through the terminal input account password login;
(2) Users who switch with "Su-username"
Read the configuration file order:/etc/profile--/etc/profile.d/*.sh---~/.bash_profile---~/.BASHRC---/ETC/BASHRC
2. Non-interactive login:
(1) Su UserName
(2) The terminal opened under the graphical interface
(3) Execute script
Read configuration file Order: ~/.BASHRC-/ETC/BASHRC-/etc/profile.d/*.sh
Third, edit the configuration file effective method
Does not take effect immediately after modifying profile and BASHRC files
Two ways to take effect immediately:
1 restarting the shell process
2. or source
Cases:. ~/.bashrc
Iv. Bash out of the task
Saved in the ~/.bash_logout file (User Configuration)
Run when you exit the login shell
For
Create an automatic backup
Clear Temporary files
V. Create a temporary file
Mktemp command: Create a temporary file to avoid conflicts
mktemp [OPTION] ... [TEMPLATE]
-D: Create a temp directory
--tmpdir=/dir: Indicates the location of the directory where the temporary files are stored
TEMPLATE:filename.XXX
x must appear at least three
Instance:
#mktemp--tmpdir=/testdir test. Xxxxxx
Vi. Installing the Copy File--install command
Install [OPTION] ... [-T] SOURCE DEST Single File
Install [OPTION] ... SOURCE ... DIRECTORY
Install [OPTION] ...-t DIRECTORY SOURCE ...
Install [OPTION] ...-d DIRECTORY ... Create an empty directory
-M MODE, default 755
-O OWNER
-G GROUP
Vii. block command-line extensions
A backslash (\) causes subsequent characters to be interpreted as intended
$ echo Your Cost: \$5.00
Your Cost: $5.00
Quotation marks to prevent extension
Single quotation mark (') prevents all extensions
Double quotation marks (") also prevent all extensions, but the following exceptions apply:
$ (dollar sign)-variable extension
' (anti-quote)-command substitution
\ (backslash)-suppresses single character expansion
! (exclamation mark)-Historical command replacement
This article is from the "Love Firewall" blog, be sure to keep this source http://183530300.blog.51cto.com/894387/1841669
Linux Foundation--bash Shell Environment configuration