How to view the Linux PATH environment variable

08-01-2023

This article mainly introduces the relevant knowledge about how to view the Linux PATH environment variable. The editor will show you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article on how to view the Linux PATH environment variable can help Everyone solves the problem.

The Linux PATH environment variable is a parameter that determines which directories the Shell will search for commands or programs. Its content is composed of a bunch of directories. Each directory Separate them with a colon: . When a Linux command is executed, Linux will search for the executable file of the command in turn according to the directories contained in the PATH environment variable. Once found, it will be executed normally; otherwise, it will prompt that the command cannot be found.

What is an environment variable

Linux is a multi-user operating system, each user has his own proprietary operating environment. The environment used by the user is defined by a series of variables called environment variables. System environment variables are usually in uppercase.

Each user can modify their own environment variables as needed to meet their own requirements. The common environment variables are as follows:

< td align="left">Affiliate prompt, the default is
Serial numberVariableDescription
1PATHdetermines which directories Shell will look for command or program , this variable is a variable
< strong>2TERMSpecify System terminal
3SHELLCurrent user Shell type< /td>
4HOMECurrent user home directory
5 LOGNAMEThe login name of the current user
6USER< /code>Current username
7HISTSIZE Historical commands number of records
8< strong>HOSTNAMErefers to the name of host
9LANGUAGELanguage related environment variable, multilingual can modify this environment variable
10MAIL Current user's mail storage directory
11PS1basic prompt:
(1)< code>root user is #
(2) normal user is $
12PS2
< strong>13LS_COLORS< code>lscommand result colordisplay

Linux PATH environment variable

Linux PATH environment variable

The content of the PATH environment variable in Linux is composed of a bunch of directories, and each directory is separated by a colon: . When a Linux command is executed, Linux will search for the executable file of the command in turn according to the directories contained in the PATH environment variable. Once found, it will be executed normally; otherwise, it will prompt that the command cannot be found.

Description

That is to say, when the user enters an external command in the shell command line interface, the shell must search the system to find the corresponding program. The PATH environment variable defines the directories in which commands and programs are looked up.

If the location of the command or program is not included in the PATH variable, the shell cannot find it without using an absolute path. If you want to execute a program anywhere in the virtual directory structure, the way is to add the directory where the program is located to the PATH environment variable, or put the program in /link (ln) to a directory that already exists in the PATH .

Check the PATH environment variable

Input on the command line

echo $PATH

< /code>

Or enter:

export

Example 1: Check the environment variable echo $ PATH

Example 2: Check the environment variable export

The content about how to view the Linux PATH environment variable is introduced here , thank you all for reading. If you want to know more industry-related knowledge, you can pay attention to the industry information channel of Yisu Cloud. The editor will update different knowledge points for you every day.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us