search
HomeComputer TutorialsComputer KnowledgeThe ten most commonly used environment variables in Linux

The ten most commonly used environment variables in Linux

Feb 19, 2024 pm 04:00 PM
environment variablespathLinux operating systemusr

The ten most commonly used environment variables in Linux

The Linux operating system provides a variety of environment variables for configuring and managing system behavior. This article will introduce the 10 most common environment variables in Linux, and give sample code and corresponding analysis.

1. PATH

The PATH environment variable determines the directory where the system looks for executable files. When you enter a command in the terminal, the system retrieves the executable file in the directory specified in the PATH variable.

Sample code:

echo $PATH

Output:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Analysis:

In the above example, we used the echo $PATH command to display the value of the PATH environment variable. The output is a colon-separated list of paths that the system uses to find the executable file.

2. HOME

The HOME environment variable defines the user's home directory path and is often used by applications to determine the user's default working directory.

Sample code:

echo $HOME

Output:

/home/username

Analysis:

In the above example, we used the echo $HOME command to print the value of the HOME environment variable. The output is the current user's home directory path.

3. USER

USER environment variable contains the current user name.

Sample code:

echo $USER

Output:

username

Analysis:

In the above example, we used the echo $USER command to print the value of the USER environment variable. The output is the current username.

4. LANG

LANG environment variable determines the locale used by the system by default. It affects character encoding, date format, currency symbol and other related settings.

Sample code:

echo $LANG

Output:

en_US.UTF-8

Analysis:

In the above example, we used the echo $LANG command to print the value of the LANG environment variable. The output specifies that the system's default locale is American English and uses UTF-8 character encoding.

5. PWD

The PWD environment variable stores the path of the current working directory.

Sample code:

echo $PWD

Output:

/home/username/Documents

Analysis:

In the above example, we used the echo $PWD command to print the value of the PWD environment variable. The output is the path to the current working directory.

6. SHELL

SHELL environment variable specifies the default Shell interpreter for the current user.

Sample code:

echo $SHELL

Output:

/bin/bash

Analysis:

In the above example, we used the echo $SHELL command to print the value of the SHELL environment variable. The output is the current user's default shell interpreter path.

7. TERM

TERM environment variable defines the current terminal type and is used to control terminal display settings.

Sample code:

echo $TERM

Output:

xterm-256color

Analysis:

In the above example, we used the echo $TERM command to print the value of the TERM environment variable. The output results specify that the current terminal type is xterm-256color.

8. DISPLAY

DISPLAY environment variable specifies the display device of the current X server.

Sample code:

echo $DISPLAY

Output:

:0

Analysis:

In the above example, we used the echo $DISPLAY command to print the value of the DISPLAY environment variable. The output specifies that the current X server's display device is: 0.

9. EDITOR

EDITOR environment variable defines the text editor used by the current user by default.

Sample code:

echo $EDITOR

Output:

vim

Analysis:

In the above example, we used the echo $EDITOR command to print the value of the EDITOR environment variable. The output results specify that the default text editor used by the current user is vim.

10. LD_LIBRARY_PATH

LD_LIBRARY_PATH environment variable specifies the path where the dynamic linker searches for shared libraries at runtime.

Sample code:

echo $LD_LIBRARY_PATH

Output:

/usr/local/lib:/usr/lib:/lib

Analysis:

In the above example, we used the echo $LD_LIBRARY_PATH command to print the value of the LD_LIBRARY_PATH environment variable. The output is a colon-separated list of paths where the dynamic linker looks for shared libraries.

in conclusion

This article introduces the 10 most commonly used environment variables in Linux and provides sample code, output and analysis. These environment variables play an important role in configuring and controlling system behavior. By understanding and skillfully using these environment variables, you can better manage and customize your Linux system.

The above is the detailed content of The ten most commonly used environment variables in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Notion Download, Install, Update, and Reset on Windows/Mac - MiniToolNotion Download, Install, Update, and Reset on Windows/Mac - MiniToolMay 09, 2025 am 12:54 AM

The Notion is a popular productivity program used for note-taking and organizing your thoughts, projects, and information. If you have not tried it yet, you should give it a chance. This article about Notion download on php.cn Website will give you a

How to Fix SSL Certificate Error in FireFox/Chrome? - MiniToolHow to Fix SSL Certificate Error in FireFox/Chrome? - MiniToolMay 09, 2025 am 12:53 AM

SSL certificate error is a common error when using a browser. Why does it occur and how to fix it on Windows 10/11? Follow the suggestions in this post on php.cn Website, you can resolve it easily.

Fix Windows Defender Exclusions Not Working Windows 11/10 - MiniToolFix Windows Defender Exclusions Not Working Windows 11/10 - MiniToolMay 09, 2025 am 12:52 AM

Do you know what is the Windows Defender exclusions? Do you have any idea how to exclude a folder from Windows Defender Windows 11/10? What if Windows Defender exclusions not working? Read this post given by php.cn to get the answers.

Windows 10 22H2 First Preview Build: Windows 10 Build 19045.1865 - MiniToolWindows 10 22H2 First Preview Build: Windows 10 Build 19045.1865 - MiniToolMay 09, 2025 am 12:51 AM

Microsoft has just released Windows 10 build 19045.1865 to the Release Preview Channel. This is the first preview build for Windows 10 22H2. php.cn Software will show you some related information about this build in this post.

Steam Not Downloading at Full Speed? A Quick Guide Here!Steam Not Downloading at Full Speed? A Quick Guide Here!May 09, 2025 am 12:50 AM

Steam gains large popularity among game players all around the world for its rich variety of games. However, have you ever encountered Steam not downloading at full speed? Why is Steam not downloading at full speed? If your Steam download speed drops

Windows 8 vs Windows RT: What Are the Differences Between Them? - MiniToolWindows 8 vs Windows RT: What Are the Differences Between Them? - MiniToolMay 09, 2025 am 12:49 AM

With the release of Microsoft's Surface tablet and Windows 8, many users wonder differences between Windows 8 and Windows RT. Now, this post from php.cn is what you need. Now, you can continue to read to get more details about Windows 8 vs Windows RT

How to Enable or Disable the Desktop Search Bar on Windows 11? - MiniToolHow to Enable or Disable the Desktop Search Bar on Windows 11? - MiniToolMay 09, 2025 am 12:47 AM

Microsoft is planning to introduce more and more new features to Windows 11. The desktop search bar is one of the new features that have been announced. However, it is only available on a few Windows 11 PC. But you can manually enable it. php.cn Soft

Lenovo Camera Driver for Windows 11/10, Watch EssentialsLenovo Camera Driver for Windows 11/10, Watch EssentialsMay 09, 2025 am 12:46 AM

If you want to let your camera run perfectly on your Lenovo laptop, keeping it up to date is of great importance. How can you download, install or update Lenovo camera driver for Windows 11/10? It is an easy task and follow the guide below from php.c

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools