this post was submitted on 28 Apr 2025
60 points (96.9% liked)

Linux

53664 readers
1210 users here now

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

Related Communities

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

founded 5 years ago
MODERATORS
 

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.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 1 day ago (2 children)

Put them wherever you want, don't let Poettering dictate what you do with YOUR system. It is better NOT to put them in system directories since those will get overwritten by upgrades.

[–] [email protected] 1 points 20 hours ago

thats fair, but that shouldn't make you avoid sensible freedesktop dirs just out of spite.

[–] [email protected] 1 points 1 day ago (2 children)

It is better NOT to put them in system directories since those will get overwritten by upgrades.

That's a purely Atomic thing, isn't it?

[–] [email protected] 1 points 14 hours ago* (last edited 14 hours ago)

Package managers tend to assume they are the only ones touching files in /usr/share. You will find if you try to change any files there, the next update may delete or download a new version of the file, stomping your changes. Instead your local changes should go in /usr/local (if you want something system-wide) or ~/.local (if it only applies to a specific user).

Ex. If you made a custom .desktop file to show up in your app launcher, or a custom .xsession file to show up in a login manager.

[–] [email protected] 1 points 20 hours ago

not necessarily, package managers tend to overwrite existing files on the same path, if you end up having installing such a package. but that shouldn't apply to /usr/local