linux[Basic]-12-Important environment variables [01]

Source: Internet
Author: User

Important Environment variables

There are many environment variables in the Linux system, we can use Env to view his

Variables are made up of fixed "variable names" and user-defined "variable values".

Variable name



User's home directory "Home"


the current shell that's the program .


History command record number of bars


Mail Box File


Language data


Random numbers


Bash prompt


History number of command stores


Find the execution file in the current directory


Default text Editor

View the user's home directory by variable:

[Email protected] ~]# echo $HOME


[Email protected] ~]# Su-linuxs

[Email protected] ~]$ echo $HOME


Set a variable "Workdir" so that each user executes

"CD $WORKDIR" are logged into the/home/workdir directory.

[Email protected] ~]# mkdir-p/home/workdir

[Email protected] ~]# Workdir=/home/workdir

[Email protected] ~]# CD $WORKDIR

[Email protected] workdir]# pwd


[Email protected] workdir]# Su-linuxs

Last Login:thu-17:26:01 CST on pts/0

[Email protected] ~]$ CD $WORKDIR

[Email protected] ~]$ echo "$WORKDIR"

[Email protected] ~]$ # because of the scope of the variable

So you can use the Export command to promote local variables to global variables.

Format: Export variable name [= Variable value]

[Email protected] linuxs]# export WOD

[email protected] linuxs]# su Linuxs

[Email protected] ~]$ echo "$WOD"


[Email protected] ~]$ CD $WOD

[Email protected] workdir]$ pwd


linux[Basic]-12-Important environment variables [01]

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: 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.