What are environment variables?

Source: Internet
Author: User
What are environment variables? -- Linux general technology-Linux technology and application information. For details, refer to the following section. Linux is a multi-user operating system. Each user logs on to the system and has a dedicated runtime environment. Generally, the default environment of each user is the same. The default environment is actually the definition of a set of environment variables. You can customize your running environment by modifying the corresponding system environment variables.

Common environment variables such as PATH and HOME are familiar to everyone. In addition, there are some common environment variables.

HISTSIZE refers to the number of records that save historical commands.

LOGNAME refers to the login name of the current user.

HOSTNAME refers to the host name. If many applications use the host name, it is usually obtained from this environment variable.

SHELL refers to the Shell used by the current user.

LANG/LANGUGE is a language-related environment variable that can be modified by users in multiple languages.

MAIL refers to the MAIL storage directory of the current user.

PS1 is the basic prompt, Which is # for root users and $ for common users. PS2 is an auxiliary prompt. The default prompt is "> ". You can modify this environment variable to modify the current command line.

Getenv () is used to access an environment variable. The input parameter is the name of the variable to be accessed, and the return value is a string. If the accessed environment variable does not exist, NULL is returned.

Setenv () is a function used to set an environment variable in a program.

Unsetenv () is a function used to clear a specific environment variable.

~ /. Profile is a file in the user's home directory. Every time a user logs on, the ENV Environment variable settings will be executed here.

/Etc/profile is a global environment variable setting. As long as users log on to the system, they will execute the ENV Environment Variable setting.

~ /. Kshrc is in the user's home directory. Each time you execute the sub-shell under KSH, The ENV Environment variable settings are executed.

~ /. Dtprofile is under the user's home directory. Here, you can set some variables when you enter CDE. If you have not entered the system through CDE, this file will not be generated, only when you have used CDE to enter the system will one automatically generate one. dtprofile file, and you can also set the variables in it. If the DTSOURCEPROFILE variable in this file is set to true, it will read. if this variable is not set in the profile file or is set to false, it will not be read. profile. To enable the configuration in the. profile or. kshrc file to take effect immediately, run the following command:

~ /. Profile
~ /. Kshrc

The profile corresponding to the Bourne shell or Kron shell is the. profile file in the user's home directory.

The profile corresponding to the C shell is the. login file under the user's home directory.

The profile corresponding to Bash is the. bash_profile file in the home directory.

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.