Feeling lost?
You can verify the location of commands, and distinguish between different types of commands (executable binaries and scripts vs. shell built-in commands vs. aliases) with a variety of analysis commands.
For common UNIX, esp. POSIX compliant shells like ash, bash, dash, ksh, posh, zsh and WLS, try:
command -v <name>
type <name>
which <name>
where
echo "$PATH"
- (with root privileges)
find / -name <name> -print 2>/dev/null
Note that UNIX commands and dot sourcable environment scripts, are not normally available to operate unless invoking the name relative to a file path, e.g. ./<name>
For Command Prompt, try:
where <name>
echo %PATH%
- Explorer -> Search
Note that MS-DOS Batch scripts (*.bat
, *.cmd
) may not be accessible to all shells.
For PowerShell, try:
Get-Command <name>
echo $env:Path
- Explorer -> Search
Note that PowerShell scripts (*.ps1
) often require a wrapping command powershell -Command <name>
, when accessing from other shells like Command Prompt, WSL, etc.
When in doubt, design scripts as (ideally fully static) compiled, binary executable programs, for better portability across shells. Go, Rust, C, and C++ have relatively high potential for portable shell usage, as long as the programs and dependencies call portable API's, such as standard library calls.