Windows
Linux
Terminal & Shell Scripting
Terminal
Windows path equivalent in Linux
Shows or modifies the list of directories the shell searches when you type a command.
Windows
→
path
Linux equivalents
echo $PATH / export PATH
echo $PATH / export PATH
echo $PATH / export PATH
Overview
What this command does
Shows or modifies the list of directories the shell searches when you type a command.
Migration tip: PATH directories are colon-separated in Linux (not semicolons).
~/bin and ~/.local/bin are common places to put your own scripts — add them to PATH in ~/.bashrc.Practical tasks
Common use cases
View or modify the command search path
Shows or modifies the list of directories the shell searches when you type a command.
echo $PATH
Show current PATH
export PATH=$PATH:/new/dir
Add directory to PATH (this session)
which command
Check if command is in PATH
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
echo $PATH
export PATH=$PATH:~/bin
echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
source ~/.bashrc
Walkthrough
Examples with explanations
# Windows: path
echo $PATH
# /usr/local/sbin:/usr/local/bin:/usr/bin:/bin
# Add a directory:
export PATH=$PATH:~/bin
# Make permanent (add to ~/.bashrc):
echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
source ~/.bashrc
Reference
Common options and variations
| Command or option | Use |
|---|---|
echo $PATH | Show current PATH |
export PATH=$PATH:/new/dir | Add directory to PATH (this session) |
which command | Check if command is in PATH |
hash -r | Clear command location cache after PATH change |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | echo $PATH / export PATH |
Same command on this distribution. |
| Fedora | same command | echo $PATH / export PATH |
Same command on this distribution. |
| Arch | same command | echo $PATH / export PATH |
Same command on this distribution. |
Keep learning