Today, I’m going to give you a quick guide on how to use the which
command in Linux. The which
command is very useful when you want to locate the path of a specific command.
Let’s say you have a command that you can execute in the shell because it’s in the shell path, but you’re curious about its location. In this case, you can use the which
command to find out where it is stored.
Here’s an example of how to use the which
command:
1 | $ which command_name |
Executing this command will return the path to the specified command. For example:
1 | $ which ls |
In the above example, we used which
to find out the location of the ls
command, and it returned /usr/bin/ls
.
It’s important to note that the which
command only works for executables that are stored on disk. It won’t work for aliases or built-in shell functions.
The best part is that the which
command is not limited to just Linux. You can use it on macOS, WSL, and anywhere you have a UNIX environment.
So, next time you’re curious about the location of a command in your Linux system, remember to use the which
command!
tags: [“Linux commands”, “shell path”, “which
command”, “executable”, “aliases”, “built-in shell functions”, “UNIX environment”]