[SOLVED] Where to keep program files I append to $PATH
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There is /usr/local/bin/ or /usr/local/sbin/ if you don't want ~/bin/ in your home directory. You'll need root access to copy programs there but then once there they should be read-only and owned by root. That is so that no one else can modify them.
See "man 7 hier" for a dry overview of where things should generally go.
My question is this: By convention or best habit, what is the best place to keep the physical location of the files that you append to PATH? For instance let's say I have the open-source Runescape program RuneLite.Appimage I don't want this file cluttering up my home folder, so where should I keep the file location before I go and add it to my PATH?
No way anyone here can answer that. It's up to YOU where you want to keep things and how you want to organize your own system. Personally, I keep things in /usr/local/bin, but that is *MY* preference. They can go anywhere; you can make a bin directory in your home folder and put things there. There is no 'best' answer.
One thing which is "off" is your description, "files that you append to PATH".
You do not add files to your PATH variable, instead you add directory paths to your PATH variable.
The /usr/local tree is very much for this purpose, it typically will already be in your PATH variable. You'll just need to place your programs in there and give them the same permissions, ownership, and group, as other programs you see in that tree. Otherwise you can make a bin tree somewhere off of your login, and make sure you update your .bashrc so that it appends that directory tree to your PATH variable.
You say you don't want it cluttering up your home folder, one tact is to make the directory hidden be prefixing the name with a dot, as noted by dugan. But personally I do not feel it clutters up one's home folder, in fact I typically do establish a set of sub-directories for various purposes in my home. Some for test or sample code, some for real project work, and definitely one to hold my programs and scripts that I use regularly, and which are ones that I have developed for long term utility use.
One thing which is "off" is your description, "files that you append to PATH".
You do not add files to your PATH variable, instead you add directory paths to your PATH variable.
The /usr/local tree is very much for this purpose, it typically will already be in your PATH variable. You'll just need to place your programs in there and give them the same permissions, ownership, and group, as other programs you see in that tree. Otherwise you can make a bin tree somewhere off of your login, and make sure you update your .bashrc so that it appends that directory tree to your PATH variable.
You say you don't want it cluttering up your home folder, one tact is to make the directory hidden be prefixing the name with a dot, as noted by dugan. But personally I do not feel it clutters up one's home folder, in fact I typically do establish a set of sub-directories for various purposes in my home. Some for test or sample code, some for real project work, and definitely one to hold my programs and scripts that I use regularly, and which are ones that I have developed for long term utility use.
That is amazing point that for some reason I did not consider or did not think was possible. Thanks Rtmistler, and thanks, dugan! What I'll do is create a hidden directory in the home folder and append that directory to path.
Now I have one more question.
1. Any idea what I should call that hidden directory? Names are important and I want to name things in a standardized and methodical way. How things are done by the Linux community at large is important to me.
There is /usr/local/bin/ or /usr/local/sbin/ if you don't want ~/bin/ in your home directory. You'll need root access to copy programs there but then once there they should be read-only and owned by root. That is so that no one else can modify them.
See "man 7 hier" for a dry overview of where things should generally go.
Thanks Turbocapitalist! man hier is a very useful manual page and I will be accessing it frequently until I absorb the majority of its info.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
IMHO, "$HOME/bin" isn't exactly "clutter" and it's an oft-encountered standard location that many sites I've worked on include in a user's PATH by default. So it certainly wouldn't be weird to go with that location. (You want to see clutter? Try issuing "cd; ls -a" to see all the subdirectories and files that applications automatically put in your home directory.)
"$HOME/.local" on my desktop system already exists and seems to contain a LOT of things that aren't my script/programs but things that other software has placed there. "$HOME/.local/bin" contains Python3-related things and "$HOME/.local/share" (share? Sharing with who?) has a TON of things under it that appear to be state information used by a slew of applications ("recently used files", that sort of thing)---not a place where I'd want my software to reside -- and in my PATH -- where a typo could cause something I'm not even aware exists to be executed and do $DIETY-only-knows what.
When doing backups, there's much under "$HOME/.local" I'd prefer to not be backing up as I'm reasonably certain it's not being terribly critical. "$HOME/bin" on the other hand... that where the good stuff is located.
I keep shell scripts in ~/bin. Some are in /root/bin
Web scripts are in directories in the DocumentRoot, of course...but they don't need to be included in PATH...
1. Any idea what I should call that hidden directory? Names are important and I want to name things in a standardized and methodical way. How things are done by the Linux community at large is important to me.
Name it as you wish.
The more standard thing is for people to have a bin sub directory off their home, named "bin", and $HOME/bin is included in their PATH.
This seems to be too much concern about how to manage your personal scripts and programs. One is never perfect at the outset, you'll likely devise another scheme as you move forwards in how you set up your systems. Do what works for you and don't worry about what everyone else does.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.