An ad-free and cookie-free website.
Learn to find command locations at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux which Command Summary with Examples (3:36)
Our eighteenth word, or command to memorize is
which from the category
which allows you to locate commands.
||Print all matches|
Recall from the last video (tutorial) how we saw two versions of the
file command in the Linux filesystem?
Well, I wanted to use the
command to kick off a discussion about how Linux goes about finding
Before we start, it helps to think about commands as mini programs and
most follow this structure:
command -option(s) argument(s).
which command has
1 option and the argument is the command you'd like
Unlike many other commands,
not have a double-dash
which simply returns the location
of the argument, assuming it's an
executable, searching the what's called the PATH. And
the PATH is a list of directories Linux will search
when you enter a command. One caveat, on many distributions,
which ignores the 60 or so shell
So why is
which an important command?
which offers a quick answer if
you are searching for command locations.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, let's type
man which, for
two reasons, first because we don't have a double-dash-help option and
second I wanted a throwback to those corny Manwhich commercials from
the 1980s. ;)
Next, let's use multiple arguments, one for the shell builtin command
type, and another executable like
Notice how the builtin
type is ignored?
An inconvenience you are now aware of.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
which has limited value, but
offers an opening to the PATH variable, coming up next.
Okay, thanks for visiting today. I hope this was a fun introduction
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
The best way to leave feedback and ask questions is on YouTube. Subscribe there and follow @factorpad on Twitter for new content reminders.
filecommand, hit Back.
echocommand, click Next.
A newly-updated free resource. Connect and refer a friend today.