Skip to content

How to Add Files to Linux Path

Introduction

In Linux, the PATH is an environment variable that contains a list of directories separated by colons. When you run a command in the terminal, the system looks in each of these directories for the executable file associated with that command. If the file is not in one of these directories, you’ll get an error message saying that the command was not found. In this blog post, we’ll discuss how to add a file to the Linux PATH so that you can run it from anywhere in the terminal.

Add the File to PATH

Once you have located the file, you can add it to the Linux PATH by editing the .bashrc file in your home directory. Open the .bashrc file in a text editor and add the following line at the end:

export PATH=$PATH:/path/to/file

Replace /path/to/file with the directory path where the file is located. Save and close the file.

Apply the changes

To apply the changes, you can either log out and log back in or run the following command:

using source

source /etc/rc.d/init.d/functions

using dot

. /etc/rc.d/init.d/functions

Verify the Changes

To verify that the file has been added to the Linux PATH, you can run the following command:

echo $PATH

This command will print the list of directories in the PATH variable, separated by colons. Make sure that the directory containing the file you added is listed.

Feedback