1

I have a few programs (python, bash, etc., some are my own, some are third-party) that I want to be able to use anywhere. Hence, i thought about putting them somewhere in my $PATH. I recently switched from Ubuntu, where it is somewhat standard practice to put these things in /usr/local/bin. However, now on Manjaro, I get an error message that says Permission denied. As I understand, the problem is that on Arch-based OS, the directory /usr/local/bin is also used by the package manager, pacman (I read this somewhere but can't find the source anymore).

In summary, what I need is:

  • a directory on my $PATH where I can save all these scripts

  • the possibilty to have version control in that directory

I am aware that I could just make some directory somewhere on my hard drive and add that to my $PATH, but I'm wondering if there is a common practice in place.

EDIT: This is my $PATH variable:

/home/douglas/bin:/home/douglas/bin:/home/douglas/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

Does someone know why /home/douglas/bin appears twice?

  • There is no standard but ~/bin and ~/.local/bin are common. You shouldn’t ask two questions but that some directories appear twice means that the file which exports PATH got sourced twice. Consider putting environment variables in .profile not .bashrc. See also How to correctly add a path to PATH?. – Devon Aug 25 '20 at 17:58

1 Answers1

1

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s09.html#purpose24

If you want to have scripts available for all users on the system put it there. pacman will not overwrite existing files and exits the installation on conflicts.

This is the main question: Do you want scripts/programs available for one specific user only, or for all users on the system?

A proper systemwide implementation for all users and for software with version control (each having a .git or .svn directory) could be put in /opt/<packagename>. (If you install java, you may find /etc/profile.d/jre.sh)

The shell environment would be extended with a file in /etc/profile.d/<packagename>.sh which is executed by /etc/profile whenever a login shell is started. <packagename>.sh would contain environment data like PATH=${PATH}:/opt/<packagename>/bin/

For a single user only put the path of the clone in ~/.profile and clone it where ever you want it to be in your /home/<username> directory.

Michael D.
  • 2,830