The type and which commands in Linux serve different purposes:
-
type:- Provides information about how a command is interpreted by the shell.
- It can indicate if a command is a built-in shell command, an alias, a function, or an executable file.
- Example usage:
type ls
-
which:- Locates the executable file associated with a command in the directories listed in the
PATHenvironment variable. - It only returns the path of the executable file if it exists.
- Example usage:
which ls
- Locates the executable file associated with a command in the directories listed in the
In summary, type gives more detailed information about the command's nature, while which simply finds the path of the executable.
