Adding a Directory to Debian 12 System Path

In this guide, we want to show you a step-by-step guide for Adding a Directory to Debian 12 System Path. As all the Linux users know, the system path is a set of list directories. When you want to run a file, your system will use this system path to search for the file. It is a good way to not use the full path in your command.

Debian 12 Bookworm is the new release of Debian distribution. Now in this tutorial, we want to show you how you can add a directory to the Debian 12 system path and use a program in any location you want.

Steps To Adding a Directory to Debian 12 System Path

Before you start, you must have access to your Debian 12 as a root or non-root user with sudo privileges. You can use this initial setup on Initial Server Setup with Debian 12 Bookworm.

Now follow the steps below to complete this guide.

Step 1 – Check the Current System Path on Debian 12

In Linux distributions, Path is an environment variable. You can use this environment variable with the echo command to check your current system path on your server. To do this, run the command below:

echo $PATH

In your out, you will get something similar to this:

Output
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

As you can see from the output, each directory that is available in the current path is separated by a colon. When you want to run a command, the system will check these directories.

Step 2 – Add a Directory To the Debian 12 System Path

At this point, you can follow the steps below to see how you can add a directory to your current system path. To do this, you must edit the .profile file.

According to the official explanations, the .profile file contains your individual profile that overrides the variables set in the /etc/profile file.

So to define your directory, open the .profile file with your desired text editor, We use vi:

vi ~/.profile

As an example, we have a directory named /home/orca/test_directory that includes some apps we want to run in any location on Debian 12. So we must add the following line to the .profile file:

export PATH="$PATH:/home/orca/test_directory"

As you can see, you can define the new Path environment variable by using the export command that makes your variable available in the system path.

When you are done, save and close the file.

Finally, apply the changes by running the following command:

source ~/.profile

At this point, you can check your system path again by using the command below:

echo $PATH

You should see that the directory has been added and shown in the system path.

Conclusion

At this point, you have seen that you can easily edit your .profile file and define a new directory for your system path. Hope you enjoy this guide on Adding a Directory to the Debian 12 System Path. Need any help or a suggestion? Please comment for us.

You may be interested in these articles:

System Locale Setup on Debian 12 Bookworm Command Line

Reset Linux Root Password on Debian 12 Bookworm

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!