Which vs. Whereis: Understanding Linux Command Location Tools
The 'which' and 'whereis' commands in Linux are both used for locating executable files or commands, but they have distinct differences:
-
Functionality:
- 'which' primarily locates executable files or commands.
- 'whereis' searches for executable files, source code files, and help documentation.
-
Search Scope:
- 'which' searches only within the paths specified by the system's PATH environment variable.
- 'whereis' explores the system's default paths and specific predefined directories.
-
Search Speed:
- 'which' is generally faster than 'whereis' as it focuses solely on executable files and commands.
- 'whereis' requires searching for multiple file types, resulting in a broader and potentially slower search.
-
Output Information:
- 'which' outputs the path of the first matching result.
- 'whereis' presents the paths of all found matches.
In summary, 'which' is ideal for finding executable files or commands, while 'whereis' excels at locating executable files, source code files, and help documentation.
原文地址: https://www.cveoy.top/t/topic/qsbX 著作权归作者所有。请勿转载和采集!