Linux Users change Environment variables

Source: Internet
Author: User

I. Environment variables

After the user logs on to the Linux system, the operating system is automatically configured with the working environment-language, home directory, mailbox directory, command search path, terminal type, user name, command prompt, and so on. The user's working environment is defined by a series of environment variables. The format is as follows:

environment variable name = value

Environment variables consist of uppercase and lowercase letters, numbers, _, and general capitalization.

Common User Environment variables:

Lang=zh_cn. UTF-8, the language is defined as UTF-8

Homs=/home/zsan, User home directory

Logname=zsan, user name

Path=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/zsan/.local/bin:home/zsan/bin, define the command search path, Bash looks for programs in these paths for user-entered external commands, and then executes, usually bin files

Shell=/bin/bash Defining User Login Bash

Pwd=/home/zsan, dynamically tracks the user's current directory

Second, environment variable operation

displays the user's environment variable in the format of the command env or echo $< environment variable name >

env Display all environment variables

ECHO Displays specific variables: Echo $LANG

set environment variables with command export:

Export < variable name >= value

Such as:

The export lang=c definition language is English.

export hello= "HELLO World", use quotation marks when there are spaces in the value.

export path= $PATH: $HOME, in this example, refers to the value of a variable in the form of a "$ variable name" .

Remove environment variables with unset, such as

Unset HELLO

The concept similar to user environment variables is shell variables, each shell program has its own set of shell variables, user environment variables are exported command shell variables, is a subset of shell variables, shell variables are defined by set , unset deleted. variables defined using the export and set commands are temporary and are not available after the user logs off or restarts the computer. If you want the defined variable to take effect permanently, you usually add the variable to the end of "/etc/profile" or "~/.BASHRC", which takes effect for all users, which works for the user of the directory. Example:
echo "Export histsizw=5000" >>/etc/profile

Linux Users change Environment variables

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.