View the current environment variable information and view commands in Linux

Source: Internet
Author: User

System environment variables are often used in web server configuration and programming. Therefore, it is necessary to understand the necessary knowledge about system variables. The following describes how to view and use linux system variables.

In Windows, the command for viewing environment variables is set, which outputs the current environment variables of the system.

In Linux, how does one check the environment variables in REDHAT? The command is:
Export
If you want to view the environment variable of a name, the command is echo $ environment variable name, for example:
Echo $ ORACLE_HOME
The command for Windows is:
Set environment variable name.

Add an article:

1. Check the environment variable display environment variable HOME in Linux
$ Echo $ HOME/home/redbooks

2. Check the environment variables in Linux and set a new environment variable hello.
$ Export HELLO = "Hello !"
$ Echo $ HELLO
Hello!

3. Run the env command to display all environment variables in Linux.
$ Env
HOSTNAME = redbooks.safe.org
PVM_RSH =/usr/bin/rsh
SHELL =/bin/bash
TERM = xterm
History Size = 1000
...

4. Run the set command to display all locally defined Shell variables in Linux.
$ Set
BASH =/bin/bash
BASH_VERSINFO = ([0] = "2" [1] = "05b" [2] = "0" [3] = "1" [4] = "release" [5] = "i386-redhat-Linux-gnu ")
BASH_VERSION = '2. 05b. 0 (1)-release'
COLORS =/etc/DIR_COLORS.xterm
COLUMNS = 80
DIRSTACK = ()
DISPLAY =: 0.0
...

5. Run the unset command to clear environment variables in Linux.
Set can be used to set the value of an environment variable. Run the unset command to clear the environment variable values. If no value is specified, the variable value is set to NULL. Example:
$ Export TEST = "Test ..." # Add an environment variable TEST
$ Env | grep TEST # This command is input to prove that the environment variable TEST already exists.
TEST = Test...
$ Unset $ TEST # Delete the environment variable TEST
$ Env | grep TEST # This command is not output, proving that the environment variable TEST already exists

6. Use the readonly command to set the read-only variables in Linux.
If the readonly command is used, the variables cannot be modified or cleared. Example:
$ Export TEST = "Test ..." # Add an environment variable TEST
$ Readonly TEST # Set the environment variable TEST as read-only
$ Unset TEST # This variable cannot be deleted
-Bash: unset: TEST: cannot unset: readonly variable
$ TEST = "New" # This variable cannot be modified.
-Bash: TEST: readonly variable

The environment variable settings are in the/etc/profile file.

  1. Linux traffic monitoring software tool series
  2. Linux network traffic monitoring tool installation and functions
  3. Basic implementation and usage of Linux Traffic Control
  4. How to view Linux Nic traffic and Its Features
  5. Linux Network Traffic Security Management Method

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.