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

Role

HOME

User's home directory "Home"

SHELL

the current shell that's the program .

Histsize

History command record number of bars

MAIL

Mail Box File

Lang

Language data

RANDOM

Random numbers

PS1

Bash prompt

Histfilesize

History number of command stores

PATH

Find the execution file in the current directory

EDITOR

Default text Editor

View the user's home directory by variable:

[Email protected] ~]# echo $HOME

/root

[Email protected] ~]# Su-linuxs

[Email protected] ~]$ echo $HOME

/home/linuxs

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

/home/workdir

[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"

/home/workdir

[Email protected] ~]$ CD $WOD

[Email protected] workdir]$ pwd

/home/workdir

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

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.