$
Learn Linux handbook
en
XP:0
Quest 117Locator
+150 XP

Finding Commands (which)

Launch Interactive Terminal for This Quest→No installation required • Runs fully in browser

Concept & Overview

Now that you are familiar with active environment variables like PATH (which stores the directories where Linux looks for commands), how do you find the exact file path of the program that runs when you type ls or grep? We use which to locate command binaries.

- The which command searches the folders listed in your $PATH variable and prints the absolute path of the binary executed when the command is run (e.g. which ls outputs /bin/ls).
- This is useful to find where a tool is installed or resolve conflicts between multiple versions of the same tool.

Let's find our tools. Run which ls to see where the ls executable is stored on the system. Then, find the path of the grep command by running which grep.

Command Syntax Reference

Command / SyntaxDescription
which lsFind absolute path of ls
which grepFind absolute path of grep

Verification Objectives

These conditions will be automatically verified when you run commands inside the interactive terminal simulator:

  • ○
    Run the "which" command on ls
  • ○
    Run the "which" command on grep

Ready to complete Quest 117?

Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.