# How to add a directory to your PATH

DevFeed: [How to add a directory to your PATH](<https://devfeed.tech/articles/how-to-add-a-directory-to-your-path-21118.md>)

Original publisher: [Read original article](<https://jvns.ca/blog/2025/02/13/how-to-add-a-directory-to-your-path/>)

Author: Julia Evans

Published: 2025-02-13T12:27:56Z

Content type: tutorial

Language: en

Sources: [Julia Evans](<https://devfeed.tech/sources/julia-evans.md>)

Topics: [Shell](<https://devfeed.tech/topics/shell.md>), [Terminal](<https://devfeed.tech/topics/terminal.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Scripting, bash](<https://devfeed.tech/topics/scripting-bash.md>), [Zsh](<https://devfeed.tech/topics/zsh.md>), [friendly interactive shell](<https://devfeed.tech/topics/fish.md>), [Linux](<https://devfeed.tech/topics/linux.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [config](<https://devfeed.tech/tags/config.md>), [files](<https://devfeed.tech/tags/files.md>), [flow](<https://devfeed.tech/tags/flow.md>), [gotchas](<https://devfeed.tech/tags/gotchas.md>), [history](<https://devfeed.tech/tags/history.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [linux](<https://devfeed.tech/tags/linux.md>), [mac](<https://devfeed.tech/tags/mac.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [terminal](<https://devfeed.tech/tags/terminal.md>)

## AI overview

A practical guide to adding a directory to PATH. It explains how to identify whether the shell is bash, zsh, or fish, find the relevant shell configuration file, determine which directory should be added, update the configuration, restart the shell, and troubleshoot common PATH-related problems.

## Source excerpt

I was talking to a friend about how to add a directory to your PATH today. It's something that feels "obvious" to me since I've been using the terminal for a long time, but when I searched for instructions for how to do it, I actually couldn't find something that explained all of the steps - a lot of them just said "add this to ~/.bashrc", but what if you're not using bash? What if your bash config is actually in a different file? And how are you supposed to figure out which directory to add anyway? So I wanted to try to write down some more complete directions and mention some of the gotchas I've run into over the years. Here's a table of contents: step 1: what shell are you using? step 2: find your shell's config file a note on bash's config file step 3: figure out which directory to add step 3.1: double check it's the right directory step 4: edit your shell config step 5: restart your shell problems: problem 1: it ran the wrong program problem 2: the program isn't being run from your shell problem 3: duplicate PATH entries making it harder to debug problem 4: losing your history after updating your PATH notes: a note on source a note on fish_add_path step 1: what shell are you using? If you're not sure what shell you're using, here's a way to find out. Run this: ps -p $$ -o pid,comm= if you're using bash, it'll print out 97295 bash if you're using zsh, it'll print out 97295 zsh if you're using fish, it'll print out an error like "In fish, please use $fish_pid" ($$ isn't valid syntax in fish, but in any case the error message tells you that you're using fish, which you probably already knew) Also bash is the default on Linux and zsh is the default on Mac OS (as of 2024). I'll only cover bash, zsh, and fish in these directions. step 2: find your shell's config file in zsh, it's probably ~/.zshrc in bash, it might be ~/.bashrc, but it's complicated, see the note in the next section in fish, it's probably ~/.config/fish/config.fish (you can run echo $__fish_config_di