Path
What is PATH in Linux?
The PATH is an environment variable that tells Linux where to look for executable programs. When you type a command, Linux searches through the directories listed in PATH to find the program to execute.
Check PATH
oroutput example:
Adding a new PATH temporarily
To add a new directory to PATH for your current terminal session:
Adding a PATH permanently
- Edit your shell's configuration file:
-
For Bash:
-
Add this line at the end of the file:
-
Save and apply changes:
-
Validate newly appended PATH:
Common PATH locations
/bin: Essential user commands/usr/bin: Most user commands/usr/local/bin: User-installed programs/sbin: System administration commands/usr/sbin: Additional system admin commands
Tips for Beginners
- Never remove default PATH directories
- Keep custom scripts in
~/binor/usr/local/bin - Use absolute paths when adding new directories
- Separate multiple paths with colons (:)