5

I have developed my own Bash Script (to undo the last APT commands), and now I'm looking for the best directory to install it.

Is the /usr/bin always the best choice?

Just for information this is my script:

https://gitlab.com/fabio.dellaria/apt-rollback

and this is a little demo:

enter image description here

New contributor
maxwatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • On the contrary, /usr/bin is effectively never a good choice for users to put stuff. – Konrad Rudolph 36 mins ago
5

If you intend to make it available to all users, you should place it to /usr/local/bin, excerpt from below answer.

/usr/local/bin is for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into /usr/bin because future distribution upgrades may modify or delete them without warning.

Taken from usr-bin-vs-usr-local-bin-on-linux

|improve this answer|||||
  • 1
    Use refspecs.linuxfoundation.org/FHS_3.0/… as reference. – N0rbert 10 hours ago
  • 3
    Maybe it's picky, should it be /usr/local/sbin since it's a system administration script? – steeldriver 9 hours ago
  • @N0rbert thank you very much for your official reference! ;) – maxwatt 29 mins ago
  • @steeldriver effectively /usr/local/sbin seems to be the better choice! – maxwatt 24 mins ago
1

For the case you're asking about, I agree with Liso's answer saying /usr/local/bin (or perhaps /usr/local/sbin), because your script kind of needs to act on the entire system.

But for completeness I want to add that if you would like to install a script under your own account without root access (which can be a good alternative for programs that are not related to system administration), I would suggest putting it in $HOME/.local/bin. As noted in an answer on Unix & Linux SE, this directory is specified by the systemd file-hierarchy spec as the equivalent of /usr/bin or /usr/local/bin for individual users' programs. It seems to be catching on for Linux systems that don't use systemd as well.

|improve this answer|||||
  • I need to install it as Root user, with Admin rights, because it is a System Admin Tool, so I think the best choice would be /usr/local/sbin, isn't it? :) – maxwatt 22 mins ago
  • @maxwatt Well I'll leave it up to Liso's answer and the comments on it to decide between /usr/local/bin and /usr/local/sbin. But I do agree that it wouldn't make a whole lot of sense to install your particular script in ~/.local/<anything>. I just finished editing to say that this makes more sense for other programs which are not system administration tools. I'm sure someone will come across this question in the future in the context of a different program that is not an administration tool. – David Z 20 mins ago

Your Answer

maxwatt is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.