Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To see your current Linux PATH, run printf '%sn' "$PATH". To add a directory only to the current shell, export a value that preserves the existing entries, such as export PATH="$HOME/bin:$PATH". To make the change persistent, put that export in the startup file read by the shell and startup mode you actually use—usually ~/.bashrc for an interactive Bash terminal or ~/.zshrc for interactive Zsh—then source the file and verify command resolution.

What PATH means in Linux

PATH is an environment variable containing an ordered, colon-separated list of directories. When you type a command without a slash, the shell checks those directories from left to right for an executable with that name. The first matching executable wins, so directory order controls which version runs when several directories contain the same command.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, with this value:

/usr/local/bin:/usr/bin:/bin

the shell checks /usr/local/bin first, then /usr/bin, and finally /bin. A program in /usr/local/bin therefore takes precedence over a same-named program in /usr/bin. A command containing a slash, such as ./build.sh or /opt/tools/report, is addressed directly and does not require PATH lookup.

PATH is inherited by child processes. An export in one terminal affects that shell and programs launched from it; it does not retroactively alter terminals, desktop applications, services, or shells that were already running.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

View the current PATH exactly

Use a quoted expansion so the complete value is printed as one argument and shell word splitting cannot change what you see.

  • printf '%sn' "$PATH" prints the value with predictable formatting and is the clearest diagnostic.
  • echo "$PATH" is convenient for a quick check.
  • printenv PATH asks the environment for the exported PATH variable.

These commands show the PATH of the shell in which they run. They do not necessarily show the value used by a different terminal, graphical application, service, or login session.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Display one directory per line

A colon-separated value is easier to audit when split into entries. The following Bash-friendly command replaces colons with newlines for display:

printf '%sn' "$PATH" | tr ':' 'n'

Use the unsplit form when you need to preserve the exact value for copying or comparison. The one-per-line form helps you spot duplicate directories, unexpected additions, or an empty entry.

Recognize an empty PATH entry

Two adjacent colons, a leading colon, or a trailing colon represents an empty entry. In common shells, an empty PATH element can make the current working directory part of command search. That behavior can run a file from the directory you happen to be in, so do not leave empty elements unless you deliberately understand and want that effect.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Change PATH for the current shell

An exported assignment changes the current shell environment and is inherited by programs started afterward. It does not edit a file and disappears when that shell ends.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepend a directory for priority

export PATH="$HOME/bin:$PATH"

This puts $HOME/bin first. Use it when you want programs in that directory to override same-named programs found later in PATH. The existing value is retained after the new directory.

Append a directory without changing existing precedence

export PATH="$PATH:$HOME/bin"

Appending leaves all existing directories ahead of $HOME/bin. This is appropriate when the new tools should be available but should not replace an existing command with the same name.

Do not overwrite the inherited value accidentally

This command is destructive:

export PATH="$HOME/bin"

It removes every previously listed directory, including locations containing standard utilities. Retain the old value with :$PATH as shown above. If you have already overwritten PATH, start a fresh shell or temporarily restore a known system value before editing the correct startup file.

Set PATH for one command only

An inline assignment changes the environment passed to one invocation and leaves the parent shell untouched:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
PATH="$HOME/bin:$PATH" program

This is useful for testing a different tool version, running a build with a controlled search path, or avoiding a permanent configuration change. The assignment must appear before the command on the same line.

Choose the right startup file

Persistence depends on which shell starts your terminal and whether that shell is a login shell. Editing a file that your current shell never reads will appear to have no effect.

Situation Usual file or location What to do Scope
Interactive Bash, non-login terminal ~/.bashrc Put the export there, then run source ~/.bashrc. One user, interactive Bash sessions that read this file
Bash login shell ~/.bash_profile, otherwise ~/.bash_login, otherwise ~/.profile Edit the first readable file in that order. If it should share interactive settings, make sure it sources the file containing your PATH line. One user, Bash login sessions
Interactive Zsh ~/.zshrc Add the export and run source ~/.zshrc. One user, interactive Zsh sessions
System-wide policy /etc/profile or a script in /etc/profile.d/ Change only with administrator authority and after considering every user and login environment. Users affected by the system’s login configuration
One invocation No startup file Use PATH=... program on the command line. That command and its child processes

Other shells have their own startup rules. Identify the shell and mode before choosing a file rather than assuming that Bash configuration applies everywhere.

Make a PATH change permanent in Bash

Interactive Bash terminal

  1. Open the user Bash startup file: nano ~/.bashrc, vim ~/.bashrc, or your preferred editor.
  2. Add an export that preserves the current value. For priority, use export PATH="$HOME/bin:$PATH"; to append, use export PATH="$PATH:$HOME/bin".
  3. Save the file without changing the spelling or capitalization of the directory.
  4. Apply it to the current shell: source ~/.bashrc. The equivalent POSIX-style command is . ~/.bashrc.
  5. Verify the resulting value and the command you intend to run.

A newly opened interactive Bash terminal will read the file automatically when that terminal launches Bash in the usual non-login mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bash login shells

For an interactive login shell—such as many SSH sessions, a virtual console, or an explicit bash --login—Bash reads /etc/profile, then the first readable user file in this order: ~/.bash_profile, ~/.bash_login, or ~/.profile. It does not read all three; the first readable one stops the search.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Inspect which of those files exists:

ls -l ~/.bash_profile ~/.bash_login ~/.profile 2>/dev/null

Put the PATH export in the file that this login shell actually reads. A common arrangement is to keep interactive settings in ~/.bashrc and have the login file source it. If your login file does not already do so, a guarded snippet avoids an error when the file is absent:

if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
fi

Do not add a second source line when one is already present, or the file may be read twice. After editing the login file, either start a new login shell or source the exact file in the current shell.

System-wide Bash configuration

Administrators can establish policy in /etc/profile or a script under /etc/profile.d/. This affects other users and may be overwritten by system administration or package updates, so use it only when the directory genuinely belongs in a shared environment. A user-level file is safer for personal tools.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make a PATH change permanent in Zsh

For an interactive Zsh terminal, edit ~/.zshrc:

export PATH="$HOME/bin:$PATH"

Apply the change immediately with:

source ~/.zshrc

Then open a new Zsh terminal to confirm that the startup file loads as expected. If a terminal is launching another shell, the Zsh file will not control that process; identify the running shell first.

Verify that the intended program is found

Printing PATH proves that the variable changed, but it does not prove that a particular command is executable or that the shell will choose the version you expect.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
  • command -v program prints the command selected for execution, or nothing when it cannot be found.
  • type -a program shows the command type and all matching locations visible through PATH, which is useful for finding duplicates.
  • Run the program’s own version or help option after resolution, for example program --version, when that option is supported.

Use a full path when you need an unambiguous test, such as /opt/tools/program. If command -v still reports an older location after a change, the shell may have cached a command location. Start a fresh shell; in Bash, hash -r clears hashed command paths before testing again.

Check the candidate directory and file

Confirm that the directory exists and that it contains an executable file with the exact command name:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ls -ld "$HOME/bin"
ls -l "$HOME/bin/program"

A directory can be present in PATH while the desired file is missing, named differently, or not marked executable. PATH does not grant execute permission.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot a PATH change that “disappears”

Follow this order so each test answers one specific question.

  1. Identify the shell process. Print the user’s configured default with printf '%sn' "$SHELL". When necessary, inspect the current process with ps -p $$ -o args=; $SHELL can name the default shell even when the current process is different.
  2. Print the exact value. Run printf '%sn' "$PATH" in the failing terminal, not only in a terminal where the command works.
  3. Check the directory and executable. Verify the candidate directory exists and contains an executable file with the expected name and case.
  4. Check resolution. Run command -v name and type -a name. These reveal whether another directory wins or whether no match exists.
  5. Refresh command lookup. Start a new shell. If the current shell cached a location, use its hash-refresh facility; Bash provides hash -r.
  6. Inspect the files actually read. For Bash, distinguish login from non-login startup and apply the documented order of /etc/profile followed by the first readable user login file. For Zsh, inspect ~/.zshrc for an interactive shell.
  7. Source the exact file after editing. Run source ~/.bashrc, source ~/.zshrc, or the applicable profile, then repeat the PATH and command-resolution checks.
  8. Account for process inheritance. Applications that were already running keep the environment they inherited. Close and relaunch the application, terminal emulator, or service that needs the new PATH.

Typical symptoms and causes

Symptom Likely cause Action
The change works until the terminal closes. The export was entered interactively but not placed in a startup file. Add it to the file read by the shell and mode you use, then source that file.
The new terminal ignores the edited file. You edited a file that this shell does not read, or the terminal starts a login shell instead of a non-login shell. Identify the process and inspect Bash’s login-file order; use the matching file or source chain.
A command still resolves to the old location. An earlier PATH entry wins, or the shell cached the old location. Use type -a, adjust prepend/append order, and refresh the command hash.
Basic commands such as ls are not found. PATH was overwritten without retaining $PATH. Open a new shell or temporarily restore a known system PATH, then correct the export.
The directory appears in PATH but the command is unavailable. The file is absent, has a different name, or lacks execute permission. Inspect the directory and file with ls -l and correct the file or permissions.
A command from the current directory runs unexpectedly. An empty PATH element is making the current directory searchable. Remove accidental leading, trailing, or doubled colons unless this behavior is intentional.

Prepending versus appending: choose deliberately

The position of a new directory is a policy decision, not just a formatting preference.

  • Prepend with export PATH="new-directory:$PATH" when your tools must take precedence over system or older versions.
  • Append with export PATH="$PATH:new-directory" when existing system commands should continue to win.
  • Use a one-command assignment when the priority is for a single build, test, or script and should not affect later commands.

Whichever form you choose, preserve the inherited value, quote the expansion, and use an absolute or correctly expanded directory such as $HOME/bin. A literal ~ inside quotes does not expand to your home directory, while $HOME does.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Safe editing and maintenance practices

  • Keep one intentional PATH assignment per startup file when possible; repeated additions can create long lists and duplicate entries.
  • Use comments in your own configuration to identify why a directory is needed, especially when it belongs to a language runtime or project toolchain.
  • Review the order whenever installing another version of a program. The first matching executable, not the newest installation, is what runs.
  • Test in a new shell after editing, because sourcing a file changes only the current shell and its descendants.
  • Use user-level files for personal tools and reserve system-wide files for an administrator-approved policy.
  • Be cautious about adding writable or untrusted directories ahead of system directories; command-name collisions can execute unintended programs.

Quick reference

Goal Command or location Effect
Print PATH printf '%sn' "$PATH" Shows the current shell’s complete value
Prepend for this shell export PATH="$HOME/bin:$PATH" Current shell and children; new directory has priority
Append for this shell export PATH="$PATH:$HOME/bin" Current shell and children; existing entries keep priority
Run one command with a temporary PATH PATH="$HOME/bin:$PATH" program That invocation and its children only
Persist for interactive Bash ~/.bashrc Interactive Bash sessions that read the file
Persist for interactive Zsh ~/.zshrc Interactive Zsh sessions
Check selected command command -v program Shows the command Bash or Zsh will resolve
List all matches type -a program Reveals duplicates and their order
Reload a file source ~/.bashrc or source ~/.zshrc Updates the current shell only

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.