Raspberry Pi_Eng_10.7.1 “which” Command – Check Path Name of Executable File


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


10.7   Commands Related to Program Execution

 

10.7.1  "which" Command - Check Path Name of Executable File

 

The "which" command tells you what program is actually being used when executing certain command on the system. In fact, many programs are installed in many places in the system, so it is often difficult to judge which program is actually used. The "which" command is used in this case.

 

[Command Format]

which  exec-command 

 

[Command Overview]

   It tells the location of the program to be actually executed for the command executed on the system.

   User privilege          -- Normal user.

 

[Detail Description]

   None

 

[Main Option]

-a   

print all matching pathnames of each argument

 

[Used Example]

First, let's look at the program used for the "mkdir" command.

 

pi@raspberrypi ~/testdata $ which mkdir

/bin/mkdir

 

This result means that running the "mkdir" command on your system will use the program in "/bin/mkdir".


 

Now, let's check if the program is in that location. If you run the following command with the "ls" command, you can see that the "mkdir" file exists in the specified directory.

 

pi@raspberrypi ~/testdata $ ls /bin/mkdir -l

-rwxr-xr-x 1 root root 38596 Jan 28  2013 /bin/mkdir

 

Here is to check the file path for "vncserver" program.

 

pi@raspberrypi ~/testdata $ which vncserver

/usr/bin/vncserver

pi@raspberrypi ~/testdata $