Intermediate
Linux & Shell Scripting
Q74 / 100
What is the difference between "type" and "which" when locating a command?
Correct! Well done.
Incorrect.
The correct answer is A) "type" reports how a command name would be interpreted by the shell (alias, function, builtin, or external file), while "which" searches $PATH for an external executable matching the name, often missing aliases, functions, and builtins
A
Correct Answer
"type" reports how a command name would be interpreted by the shell (alias, function, builtin, or external file), while "which" searches $PATH for an external executable matching the name, often missing aliases, functions, and builtins
Explanation
Because "which" only checks $PATH for executables, it can give misleading results for names that are actually shell aliases or functions; "type" correctly reflects what would actually run.
Progress
74/100