Environment-what is stored in the environment?

Source: Internet
Author: User
Although shell stores two basic types of data in the environment, there is basically no difference between the two types in bash.

Introduction

Although shell stores two basic types of data in the environment, there is basically no difference between the two types in bash.

The two data types are environment variables and shell variables.

Shell variables are a small amount of data stored by bash. Environment variables are other variables.

In addition to variables, shell functions also store some programming data, that is, aliases and shell functions.

========================================================== ======

Check environment

To understand the content stored in the environment, you need to use the set command or printenv program integrated in bash.

The difference is that the set command displays both shell variables and environment variables, while printenv only displays environment variables.

Because the content of the environment may be lengthy, it is best to redirect the output of these two commands to the less command in the form of pipelines.

For example

[Allyes_op @ allyes ~] $ Set

BASH =/bin/bash

BASH_ARGC = ()

BASH_ARGV = ()

BASH_LINENO = ()

BASH_SOURCE = ()

BASH_VERSINFO = ([0] = "3" [1] = "2" [2] = "25" [3] = "1" [4] = "release" [5] = "x86_64-redhat-linux-gnu ")

========================================================== ======

View the value of a single variable

[Allyes_op @ allyes ~] $ Echo $ BASH

/Bin/bash

[Allyes_op @ allyes ~] $

========================================================== ======

View aliases

[Allyes_op @ allyes ~] $ Alias

Alias l. = 'ls-d. * -- color = tty'

Alias ll = 'ls-l -- color = tty'

Alias ls = 'ls -- color = tty'

Alias vi = 'vim'

Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'

[Allyes_op @ allyes ~] $

========================================================== ======

Some interesting environment variables

EDITOR

Program name used for text editing

SHELL

Shell name of the local machine

HOME

Path name of the local main directory

LANG

Defines the character set of the local language

OLD_PWD

Previous working directory

PAGER

Program name used for paging output

PWD

Current working directory

USER

User name

 

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