Linux environment variables

Source: Internet
Author: User

1. Use the ENV command to display all environment variables

  $ env

hostname=redbooks.safe.org

Pvm_rsh=/usr/bin/rsh

Shell=/bin/bash

Term=xterm

histsize=1000

...


2. Use the SET command to display all locally defined shell variables

$ set


3. Use the unset command to clear environment variables

Set sets the value of an environment variable. Clear the value of the environment variable with the unset command. If no value is specified, the value of the variable is set to NULL. Examples are as follows:

$ export test= "TEST ..." #增加一个环境变量TEST

$ env|grep Test #此命令有输入, proving that the environment variable test already exists

Test=test ...

 $ unset $TEST #删除环境变量TEST

$ env|grep Test #此命令没有输出, proving that the environment variable test already exists


4. Use the echo command to view a single environment variable. For example:

 Echo $PATH

5. Common environment variables

PATH determines to which directories the shell will look for commands or programs

Home Current User Home directory

Histsize Number of historical records

LOGNAME The current user's login name

HOSTNAME refers to the name of the host

Shell Current User shell type

Languge language-related environment variables, multiple languages can modify this environment variable

Mail storage directory for the current user of mail

PS1 basic prompt, for root user Yes #, for normal user is $


6. Set a new environment variable Hello

$ export hello= "hello!"

$ echo $HELLO

Hello!

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