9. Shell Environment

Source: Internet
Author: User
Tags aliases echo command egrep

printenv– Print Some or all of the environment variables

set– set shell options
export-Export the environment variables so that the program that is executed later knows.
alias– create command aliases

1.shell Environment: The shell maintains a large amount of information in the shell session, known as the shell environment

What is the basic data type of 2.shell?

1) Shell variable: A small amount of data stored by bash.

2) Environment variables: all other data

Also stores some programmable data, named aliases and shell functions (involving shell scripts)

First, check the environment variables

The SET command can display both shell and environment variables, while printenv only displays environment variables.

1. Because the environment variable content list is quite long, it is best to pipe the output of each command to the less command:

[Email protected]:~$ printenv | Less  will open a new file showing all the environment variables

The 2.printenv command can also list values for a specific variable:

[Email protected]:~$ printenv Userxiaohui

3. When you use a set command with no options and parameters, both the shell and environment variables are displayed, and the defined shell functions are displayed. Unlike the printenv command, the output of the set command is politely arranged in alphabetical order:

[Email protected]:~$ Set | Less

4. Use the echo command to view the contents of a variable

[Email protected]:~$ echo $HOME/home/xiaohui

5. If a member in the shell environment is not displayed either with the SET command or the PRINTENV command, the variable is an alias. Enter the alias command without parameters to view them

[Email protected]:~$ aliasalias Alert='\'s/^\s*[0-9]\+\s*//;s/[; &|] \s*alert$//' \') 'alias egrep='egrep--color=auto  'alias fgrep='fgrep--color=auto'... ...

Second, how to build the shell environment?

When we log into the system, we start the Bash program and read a series of configuration scripts called startup files that define the default shell environment that can be shared by all users.

Then read more of the startup files located in our own home directory, which define the user's personal shell environment.

The exact boot order depends on the type of shell session you want to run. There are two types of shell sessions: one is a logon shell session and the other is a non-logon shell session.

The logon shell session prompts the user for a user name and password; For example, we start a Virtual Console session. When we run a terminal session in GUI mode, the non-login shell session appears

A city the contents of the startup file

9. Shell Environment

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.