Beginner LevelLinux Commands & SysAdmin
How do which, whereis, and type locate command binaries in PATH?
❓ Interview Prompt: Compare which (locates executable path in $PATH) vs whereis (locates binary, source, and man pages) vs type (identifies shell built-ins vs binaries).
Finding command locations relies on three distinct utilities:
•
'which command': Searches directories listed in '$PATH' and returns the full absolute path of the executable invoked by the shell.
•
'whereis command': Locates executable binary, source code files, and manual man pages.
•
'type command': Reveals whether a command is a shell built-in ('cd', 'alias'), alias, or external disk binary.
Code Implementation Example
bash
# Find absolute path of python3 executable in $PATH
which python3
# Check if 'cd' is a shell built-in or binary
type cd
# Locate binary, source, and manual page for git
whereis git💡Locating binary paths and inspecting command types using which and type.
🎯 Interview Key Takeaway
Use which to find the active executable path in $PATH, and type to check if a command is a shell built-in.
#which#whereis#type#PATH#Beginner
Back to all Linux Commands & SysAdmin Questions→