2. Shell's shell configuration file

Source: Internet
Author: User

    • 1. Location of shell configuration files

The most commonly used shells are SH and bash, which only speak sh and bash here.

1.1. SH (Bourne Shell) configuration file has two main, respectively, each user home directory of the. profile file and/etc/profile file, the former is user-specific, the latter is common to all users;. Profile is run after profile (somewhat complex, not very clear), not specifically explained

There are 5 1.2 bash (bourne-again Shell) profiles, 4 of which are in the user's home directory and one in/etc;

bash_history Operation history command to store files, only when logged off, the user logon process of the operation commands are written to the file, the logon process executed during the command, not immediately write to the file, but written in memory.

The. Bash_logout file executes every time the current user exits the shell, and if not specifically requested, the contents of the file are empty

The . Bash_profile is used to store shell information used by each user, and is often used to set environment variables to execute the user's. bashrc file; The following code is a root user's

#. bash_profile# Get the aliases and Functionsif [-f ~/.BASHRC]; Then    . ~/.bashrcfi# User specific environment and startup Programspath= $PATH: $HOME/binexport PATH

The contents of the. bash_profile file can be seen from the code above, line 5th calls the./bashrc file in the user's home directory, line 10th sets the path system variable, and 12th lines the system variable export

The ./BASHRC contains information about bash that belongs to a user, and the following code is the. bashrc file content for a root user

#. bashrc# User specific aliases and Functionsalias rm= ' rm-i ' Alias cp= ' cp-i ' Alias mv= ' mv-i ' # Source Global Definitionsi f [-F/ETC/BASHRC]; Then    ./etc/bashrcfiexport path=/usr/local/arm/4.3.2/bin: $PATH

From the above content, this file is mainly used to define aliases and functions, such as the 5th line defines the alias, and the 11th line also calls/ETC/BASHRC, line 14th also sets the path system variable

/ETC/BASHRC is very similar to the/etc/profile file in sh, which is a file that all users use together, and any user who logs on to bash will execute

Role:

1) Define PS1 (Command prompt) variable

2) Umask

3) define the PATH variable

4) Call the/etc/profile.d/*.sh file

Note: Linux does not recommend that users directly modify/etc/profile or/ETC/BASHRC files, should try to put the user's configuration in the user's home directory in the corresponding file  

2. Command

2.1. SOURCE command

[[email protected] ~]# source/etc/profile #让/etc/profile configuration file is in effect [[email protected] ~]#./etc/profile #与上面的命令效果一样

Function: Read and execute commands in the configuration file in the current bash environment

3. Environment variable File Execution order

This flowchart is still not very clear!! If you know, leave a connection, thank you here!!

2. Shell's shell configuration file

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.