Software & AppsOperating SystemLinux

How To Add ~/.local/bin to Your PATH in WSL Ubuntu 18.04

Ubuntu 7

In this tutorial, we will guide you through the process of adding ~/.local/bin to your PATH in WSL Ubuntu 18.04. This task is crucial for developers who want to run scripts or programs that are located in ~/.local/bin directory without having to type the full path to the executable.

Quick Answer

To add ~/.local/bin to your PATH in WSL Ubuntu 18.04, open the .bashrc file in a text editor, scroll to the bottom, and add the line: export PATH="$HOME/.local/bin:$PATH". Save the changes, either restart your terminal or run source ~/.bashrc to apply the changes. This allows you to run executables from ~/.local/bin without specifying the full path.

What is PATH?

PATH is an environment variable in Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.

Why Add ~/.local/bin to PATH?

Adding ~/.local/bin to your PATH is convenient because it allows you to run executables from that directory no matter what your current working directory is. This can be particularly useful if you have scripts or programs in ~/.local/bin that you want to be able to run from anywhere.

Step-by-Step Guide

Open Terminal

Open your terminal by pressing Ctrl + Alt + T or by searching for it in the Ubuntu dashboard.

Navigate to Home Directory

Navigate to your home directory by running the following command:

cd ~

The cd command changes the current directory. The ~ symbol represents the home directory of the current user.

Open .bashrc File

Open the .bashrc file in a text editor. In this example, we’ll use nano, but you can use any text editor you prefer:

nano .bashrc

The .bashrc file is a script that runs every time you open a new terminal window. It’s used to configure your terminal session.

Add ~/.local/bin to PATH

Scroll to the bottom of the file and add the following line:

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

This line adds ~/.local/bin to the beginning of your PATH. The $HOME variable is a reference to your home directory, and $PATH is your current PATH.

Save and Exit

Save the changes by pressing Ctrl + X, then press Y to confirm the save, and finally press Enter to exit.

Apply Changes

To apply the changes, either restart your terminal or run the following command in the current terminal session:

source ~/.bashrc

The source command reads and executes commands from the file specified as its argument in the current shell environment.


After following these steps, ~/.local/bin will be added to your PATH, allowing you to run executables from that directory without specifying the full path. This is a small but significant enhancement to your workflow, especially if you frequently use scripts or programs located in ~/.local/bin.

Remember, the .bashrc file is specific to the Bash shell. If you are using a different shell, such as Zsh, you may need to modify a different configuration file, such as .zshrc, instead. For more information about PATH and other environment variables, you can visit the Ubuntu documentation.

We hope you found this tutorial helpful. If you have any questions or run into any issues, please feel free to leave a comment below.

How do I check my current PATH in WSL Ubuntu 18.04?

You can check your current PATH by running the following command in your terminal: echo $PATH. This will display a list of directories separated by colons, indicating the current PATH.

Can I add multiple directories to my PATH?

Yes, you can add multiple directories to your PATH by separating them with colons. For example, if you want to add ~/.local/bin and /usr/local/bin to your PATH, you would use the following line: export PATH="$HOME/.local/bin:/usr/local/bin:$PATH".

How do I remove a directory from my PATH?

To remove a directory from your PATH, you need to edit the .bashrc file again and remove the corresponding line that adds the directory to the PATH. After saving the file, you will need to either restart your terminal or run source ~/.bashrc for the changes to take effect.

Can I add directories to my PATH that are not in my home directory?

Yes, you can add directories to your PATH that are located outside your home directory. Simply replace ~/.local/bin in the command with the full path to the directory you want to add. For example, if you want to add /opt/bin to your PATH, you would use the following line: export PATH="/opt/bin:$PATH".

Will adding directories to my PATH affect system-wide executables?

No, adding directories to your PATH only affects the current user’s environment. System-wide executables are typically located in directories that are already in the system’s default PATH. If you want to add directories for all users, you will need to modify the system-wide configuration file instead.

Leave a Comment

Your email address will not be published. Required fields are marked *