How to customize Linux operating system environment variables

Source: Internet
Author: User

Linux is a multi-user operating system. After each user logs on to the system, there will be a dedicated running environment. Typically, the default environment for each user is the same, and this default environment is actually the definition of a set of environment variables. Users can customize their running environment by modifying the corresponding system environment variables.

Common environment variables

We are not unfamiliar with the environment variables such as path and home. In addition, there are some of the following common environment variables.

Histsize refers to the number of bars in which history command records are saved.

LogName refers to the current user's login name.

Hostname refers to the name of the host, which is usually obtained from this environment variable if the host name is to be used.

The shell refers to which shell the current user is using.

Lang/languge is a language-dependent environment variable, and users with multiple languages can modify this environment variable.

Mail refers to the current user's message storage directory.

PS1 is the base prompt, and for the root user is #, for the average user is $. PS2 is a secondary prompt, and the default is ">". You can modify the current command character by modifying this environment variable, such as the following command to modify the prompt to a string "Hello,my newprompt".

# ps1= "Hello,my newprompt"
hello,my newprompt

In addition to these common environment variables, many applications will add environment variables when installing, such as using Java to set up Java_home and Classpath, and installation Wubi Input method will increase the environment variable "xmodifiers= @im =fcitx" and so on.

customizing environment variables

Environment variables are closely related to the shell, and the user starts a shell after logging in to the system. It's usually bash for Linux, but it can be reset or switched to another shell. Environment variables are set through shell commands, and set up environment variables that can be used by programs run by all current users. For bash, the shell program can access the corresponding environment variables through the variable name, setting the environment variable by export. Here are several examples to illustrate.

1. Show Environment Variables Home

$ echo $HOME
/home/terry

2. Set up a new environment variable welcome

$ export Welcome= "hello!"
$ echo $WELCOME
hello!

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.