User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Get a new folder in the the PATH

Mon Apr 01, 2019 3:03 pm

I have installed some programs in /usr/pgms/MyStuff which I would like to run from the command line without first cd-ing the that folder or including the full path on the program command. In addition I want those programs to be available to other users on this Pi.

For example, I want to run test.py from the command line. It fails to find the program unless I first run the
cd /usr/pgms/MyStuff
command.

I'm sure there is an easy way since all of the apt-get installed programs are universally available and those via cloning from a GIT site are also universally available to all users. I've Googled it and am not finding anything useful to this novice user.

Can someone help?....RDK

User avatar
rpdom
Posts: 14429
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Get a new folder in the the PATH

Mon Apr 01, 2019 3:09 pm

One of the traditional places to put your own programs in Debian based systems is /usr/local/bin. That directory is already in the PATH.

User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Get a new folder in the the PATH

Mon Apr 01, 2019 3:38 pm

OK, but if I want to keep them all together in the current directory. Is there a way, as per my original post?....RDK

scotty101
Posts: 3597
Joined: Fri Jun 08, 2012 6:03 pm

Re: Get a new folder in the the PATH

Mon Apr 01, 2019 3:43 pm

Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Get a new folder in the the PATH

Mon Apr 01, 2019 4:16 pm

OK, I saw that reference, but mostly it confused me!! There are/were too many answers and they often seemed to be in conflict. Mostly I want one simple answer. But, I will go back for another look....ROK

k-pi
Posts: 896
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Get a new folder in the the PATH

Mon Apr 01, 2019 7:01 pm

export PATH=$PATH:/path/to/your/dir
That should attach it to your running session.

(It should also work if you add it to the end of your .profile file.)

User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Get a new folder in the the PATH

Tue Apr 02, 2019 5:20 am

OK, I edited /etc/profile and when I echo $PATH it shows the change. However, I not sure this will affect other users on the Pi....RDK

Return to “Beginners”