How to add a path to zsh or bash on Linux

July 11, 2021

If you just want to get straight to the point, here is the TLDR.

After installing programs on Linux you'll often find that you cannot execute them from your terminal.

I had this issue after installing httpie on my Linux system. Here is the error message I saw when trying to start http from the terminal.

zsh: command not found: http

The problem here is that the directory where this program is located is not in the PATH variable. This means that Linux cannot find the program since it does not know where to look for it.

Here is how I fixed this issue:

Find the path of the program

sudo find / -name 'http' -executable -type f

This will output a bunch of search results

find: ‘/run/user/1000/gvfs’: Permission denied

So on my system, I have three different search results...

How do I know which one is the correct one?

The standard directoy for executable programs is /bin. So I will just assume that the /home/username/.local/bin/http is the correct one.

Show our current PATH variable

So lets take a look at our current path.

echo $PATH

Here you can see all directories that I have in my PATH variable. The directories are divided by :.

So here is the full list displayed in an more eye friendly way:


So you'll notice that /home/username/.local/bin/http is missing from that list, therefore Linux is not able to find http.

Add a new directory to our PATH variable

Edit your .zshrc or your .bashrc file depending on what shell you use. And add the following line, where /home/username/.local/bin is the path you want to add.


As you can see we use the $PATH variable and the : to add to the already existing list of directories.

After that restart your terminal and test the command again.