From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

The PATH and command execution

The PATH and command execution - Linux Tutorial

From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Start my 1-month free trial

The PATH and command execution

Bash has some pre-specified locations to look for commands in. These locations are stored in a variable called path. When you type in a command, Bash will look for the command in each of the directories in the path variable and execute the first one it finds. This means if you have the same command in more than one directory, the one that it finds first will get executed. We can look at the path variable using the echo command. In a terminal type in echo, space, dollar sign, capital P-A-T-H, and hit enter. Each directory has been limited by a colon and Bash looks from the left to the right. This variable will have different contents depending on the user, and the users can add directories to their copy as well. If you want to search for a command in the path without using the more complex find or locate commands, just use the which command. Type in which, space, and then the command. In this case I'll use tar. And…

Contents