Linux environment variable configuration file

Source: Internet
Author: User
Tags aliases

The environment variable configuration file is primarily defined as the system default environment variables, such as path, that are in effect for the system operating environment. When you log on to a Linux system to launch a bash shell, bash looks for commands in several files by default, and the boot file that bash checks depends on how the bash shell works. There are three ways to start a bash shell:

(1). Login as Default login shell

(2). As a non-landing interactive shell

(3). As a non-interactive shell that runs scripts

Environment variable configuration file:

/etc/profile/etc/profile.d/*.sh~/.bash_profile #每个用户下面都有 ~/.BASHRC #每个用户下面都有/ETC/BASHRC

1. Default login Shell.

When logging into the Linux system, the Bash shell is launched as the default login shell, which reads the following files at a time:

/etc/profile--> ~/.bash_profile--> ~/.BASHRC-->/etc/bashrc--> command Prompt

The role of/etc/profile:

User variable logname variable mail variable PATH variable hostname variable histsize variable umask variable call/etc/profile.d/*.sh file

The/etc/profile file is the default bash Shell master boot file on the system. This startup file is executed each time the user logs on the system. In Bash Z, there is an important paragraph:

#/etc/forlogin in/etc/bashrc# It's nota good idea-to-change this file unless your know what's you # is doing. It's much better to create a custom.sh shell script future updates.

The/etc/profile file has a for statement that accesses each file in the/ETC/PROFILE.D directory one at a time. The/ETC/PROFILE.D directory provides a place for the system to host the application-specific startup files to be executed when the user logs in. The files in this directory are basically related to specific applications on the system. Most apps create two self-starter files: The bash Shell's. sh file and the C Shell's. csh file. Lang.sh and LANG.CSH will determine the default language character set on the system, and then set the lang variable correctly

The role of ~/.bash_profile

1. Call the ~/.BASHRC file. 2. Added ": $HOME/bin" Behind the PATH variable

Cat . Bash_profile #. bash_profile# Get the aliases and functions if  Then ~/. bashrcfi# User specific environment and startup Programspath= $PATH: $HOME      /Binexport PATH

~/.BASHRC file function:

1. View the common BASHRC files in the/etc directory. 2. Provide users with custom-made aliases and private scripting functions

[Root@future ~]#Cat. BASHRC #. bashrc# User specific aliases and FunctionsaliasRM='rm-i'aliasCP='cp-i'aliasMV='mv-i'# Source Global Definitionsif[-F/ETC/BASHRC]; Then    . /etc/BASHRCfi

/ETC/BASHRC:

Some environment variables have been set, but the Export command has not been executed to make them global variables. There is also an important word in/ETC/BASHRC. /ETC/BASHRC also executes files under the/ETC/PROFILE.D directory.

cat /etc//etc/ in/etc/profile# It's nota good idea to change This file unlessis doing you know. It's much better to create a custom.sh shell scripton make forin
     future updates.

Interactive shell

If your shell is not launched when you log into the system (such as typing bash at a command prompt), this shell is called an interactive shell. The interactive shell does not run as a login shell, but it also provides command-line prompts to enter commands.

If Bash is launched as an interactive shell, it does not go to the/etc/profile, but instead goes to the user's home directory to check. BASHRC exists. As mentioned above, the. bashrc file has two functions. Therefore, the generic/ETC/BASHRC boot file is executed by each interactive shell on the system.

Non-interactive shell:

This is the shell used by the system to execute shell scripts. When you run the script every time, you still run a specific startup file. As a result, the Bash shell provides bash_env environment variables. When the shell launches a non-interactive process, it checks the environment variable to see the startup file to be executed, if there is a specified

The content in the file is executed. In Linux distributions, the default environment variable is not set.

Other environment variable files:

~/.bash_logout: Execution on exit, the command to be executed when the exit is added to the file

/etc/issue Local Terminal Welcome information

/etc/issue.net Remote Terminal welcome information

1. Escape characters cannot be used in the/etc/issue.net file

2. Whether this welcome message is displayed is determined by the SSH configuration file/etc/ssh/sshd_config and added to the Banner/etc/issue.net line to be displayed and the SSH service needs to be restarted.

/etc/motd

This information can be displayed whether you are logged on locally or remotely.

Linux environment variable configuration file

Related Article

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.