My personal Linux pet peeve is the complete anarchy around a user’s personal bin directory. I have to use and test on many different Linux distros so this annoys me more than most. Some people start with one major Linux distro and they stick with it all their lives. They don’t even change desktops. When you are writing software you can tell people “well it works on my system!” Well, you can, but that is the battle cry of an AGILE hack, not a professional. Nothing screams to the world “I didn’t get a degree” like that comeback.
Save This to a Text File
Or just bookmark this post.
if [ -d "$HOME/bin" ]; then
export PATH="$HOME/bin":$PATH
echo "added to PATH"
fi
Yes, this is another of my “I’m tired of having to find/create it each and every time posts. The YABUs (Yet Another uBUntu) and I suspect all Debian distros include something similar in the default login scripts. If $HOME/bin exists, it is added to the front of the PATH variable.
Where to put it
Yes, there is an obvious crude joke to be uttered there, please get it out of your system.
Ubuntu and the YABU clan have tried to solve this problem since at least 18.04 LTS.
They already look for both major locations with the .profile file found in your home directory. This file is executed as part of your login. For Manjaro and other Arch Linux based distros you need to paste this in the top of .bashrc found in your home directory. Yes, they have a .profile, but pasting the code there will not fix the PATH.
I’m not even certain where/if that gets executed by the login process.
When you use the more obscure Linux distros all bets are off. I don’t remember what one it was, but I seem to remember one distro not only had a non-common logon script name, it the personal bin directory was $HOME/.bin.
Like I said, anarchy.
Why this matters.
You may be too young to remember, but there was a time Linux came in boxes of floppy disks. Later it was boxes with manuals and CDs. We used to have to use LILO (later replaced by Grub) and, thanks to Microsoft, the FAT/MBR partition table could have only 4 primary partitions. Once “extended” partition support was begrudgingly added, the Linux world made certain it could boot from an extended partition. The BIOS would only boot a primary partition marked Active, but LILO/Grub could be stuffed into the MBR and pointed to one of our extended partitions.
Microsoft went to great pains to keep Linux and other operating systems off commercial computers. When you bought your new computer with Windows pre-loaded all four primary partitions were used. One of them would be your “recovery” partition to wipe the boot partition and re-install Windows. Another was a “tools” or “utilities” partition, and I forget what the third was.
Creation of extended partitions required one primary partition. You were screwed. To use Linux, you had to “take the plunge” and get rid of something.
We didn’t have virtual machines
Things like Oracle Virtual Box didn’t come around for a very long time. Computers were expensive and slow. An 80 MEG disk drive was considered massive. Depending on what OS you were running, you had to partition it as four 20 MEG drives (I kid you not). Backing up to a Colorado Jumbo 250 was slow. You were a serious geek if you had one of those!
The practice of creating one common /home user partition came about. This meant you didn’t have to continually copy your personal scripts and binaries to each and every booted OS.
SuSE was a bitch!
SuSE was a Linux distro that made it a personal mission in life to not play well with others. I’ve written about SuSE and /home before. Most of you take this for granted.
For the vast majority of Linux desktop distros, the first UID created is 1000 and its associated GID is 1000. You will notice my VM of Ubuntu 18.04 shows developer for the UID and roland for the GID. In large part because I copy stuff back and forth and because my full username did not match the username I chose to create. SuSE did not abide this convention. I do not remember if they used 100:100 or 200:200 or 2000:2000. What I remember is that it did not match. When you tried to share your /home partition this caused no end of grief. So much grief that SuSE quickly fell out of favor with desktop Linux users.
The RPM crowd was eventually beaten into submission.
Today we have VMs __and__ this issue
Yes, we have multi-Terabyte disks for under $100. Yes we have multiple virtual machine packages. No, for the most part distros don’t choose anything other than 1000:1000 for the first user. Yes, we still have the personal bin directory problem.
Why?
Because we zip/copy /home/username off to some NAS or external/shared media, spin up a new VM, mount said media and copy /home/username to a shiny new VM. Okay, we don’t copy all of the hidden directories because that would really hose things. We don’t copy .config or .local because the OS and applications store configuration information there and it will be different for different versions.
We copy all of the readily visible stuff. The safe stuff. Our /home/username/bin directory.
Too bad many Linux distros don’t play nice with this.