This post is from a low-reputation account and contains an unverified outbound link. Be cautious before clicking external links.

How to Use the which Command on Linux

nishalm(4)
Published in
#dlike
Words
113
Reading
1 min
Listen
Play
7y

Shared From Dlike

When you try to run a program or command from the terminal window, the shell (usually, Bash on modern distributions) has to find that command and launch it. Some commands, such as cd, history, and pwd, are built into the shell, Well, Bash uses the path, which is actually a collection of paths, each of which points to a directory. It then searches each of those directories for an executable that matches the command or program 

 use echo to check the $PATH environment variable and see the directories in your path.

The "echo $PATH" command in a terminal window.

The output list separates each path with colons (:). On the computer we’re using, Bash will search the following directories in this order:

  • /usr/local/sbin
  • /usr/local/bin
  • /usr/sbin
  • /usr/bin
  • /sbin
  • /bin
  • /user/games
  • /usr/local/games
  • /snap/bin

Shared On DLIKE



How to Use the which Command on Linux | Ecency