Solved: ~/bin vs. ~/.local/bin for user bash scripts?

a year ago by wolf to c/linux

For one user account, I want to have some bash scripts, which of course would be under version control.

The obvious solution is just to put the scripts in a git repository and make ~/bin a symlink to the scripts directory.

Now, it seems on systemd systems ~/.local/bin is supposedly the directory for user scripts.

My question, is mostly, what are the tradeoffs between using ~/bin and ~/.local/bin as directory for my own bash scripts?

One simple scenario I can come up with are 3rd party programs which might modify ~/.local/bin and put their own scripts/starters there, similar to 3rd party applications which put their *.desktop files in ~/.local/applications.

Any advice on this? Is ~/.local/bin safe to use for my scripts or should I stick to the classic ~/bin? Anyone has a better convention?

(Btw.: I am running Debian everywhere, so I do not worry about portability to non systemd Linux systems.)

Solved: Thanks a lot for all the feedback and answering my questions! I'll settle with having my bash scripts somewhere under ~/my_git_monorepo and linking them to ~/.local/bin to stick to the XDG standard.

load all comments
AkatsukiLevi 53 points a year ago

I use ~/.local/bin since by linux standard, ~/.local is a user-level /usr/local, which is a override level of /usr

~/bin ends up cluttering the home folder

path: 0 16733750, hotness: undefined, score: 53, children: 16
Max_P 30 points a year ago

Another reason to use ~/.local is you can do things like

./configure --prefix=$HOME/.local
make -j$(ncpu)
make install

And then you get your .local/bin, .local/share, .local/include, .local/lib and such, just like /usr but scoped to your user.

and it should mostly just work as well.

path: 0 16733750 16735128, hotness: undefined, score: 30, children: 2
AkatsukiLevi 8 points a year ago

And if there's other users in the machine, it doesn't fuck things up for others Or if it ends up messing something up, it is user-scoped, so its a lot easier to fix than a bricked system

path: 0 16733750 16735128 16737628, hotness: undefined, score: 8, children: 0
atzanteol 0 points a year ago

Prefix can be just $HOME as well.

path: 0 16733750 16735128 16743149, hotness: undefined, score: 0, children: 0
BaconIsAVeg 6 points a year ago
path: 0 16733750 16736861, hotness: undefined, score: 6, children: 3
Ferk 3 points a year ago

it may as well be a system managed folder at that point.

In a way it is. But user-level system, as opposed to root-level system.

path: 0 16733750 16736861 16745864, hotness: undefined, score: 3, children: 0
AkatsukiLevi 2 points a year ago

At that point I'd poke around what's in there, cuz there's absolutely a mess in there

path: 0 16733750 16736861 16737596, hotness: undefined, score: 2, children: 1
wolf 5 points a year ago

Another follow up question: Is there any documentation for the linux standard/convention of ~/.local/bin? My initial search about this resulted in nothing which I would call authoritative/definitive.

path: 0 16733750 16734189, hotness: undefined, score: 5, children: 2
Sonotsugipaa 14 points a year ago path: 0 16733750 16734189 16734405, hotness: undefined, score: 14, children: 1
just_another_person 3 points a year ago

Mostly this, but also, if you're going to manage many scripts in a system for many users, revision control doesn't help that. Either look at packaging them properly for your distro, or using something Ansible to distribute and manage their versioning on the system to make things easier on yourself.

path: 0 16733750 16733890, hotness: undefined, score: 3, children: 4
AkatsukiLevi 2 points a year ago

Me, packaging company software to Alpine Packages so that I can just apk add stuff

path: 0 16733750 16733890 16737611, hotness: undefined, score: 2, children: 3
wolf 2 points a year ago

Thanks! Do you just put the whole .local/bin under source control, do you link your scripts from somewhere else?

path: 0 16733750 16733865, hotness: undefined, score: 2, children: 0
linux
linux

@lemmy.ml

login for more options
65939
9043
4766

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

go to feed...