12

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

maxwatt
  • 488

2 Answers2

13

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

Liso
  • 15,377
  • 3
  • 51
  • 80
7

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.

David Z
  • 10,301
  • 1
    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 Apr 04 '20 at 21:15
  • 1
    @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 Apr 04 '20 at 21:17
  • 2
    Since it's Ask Ubuntu here, it's safe to assume everyone uses systemd, as it's the default init system since 14.10. – iBug Apr 05 '20 at 04:40
  • @iBug Good point, I forgot that. Although, considering how often I wind up on this site when I'm researching a question that has nothing to do with Ubuntu, I do still think there's some value in mentioning other configurations in an answer as well. (Not that it really matters here; the systemd file-hierarchy standard for home directories is independent of whether you use systemd as an init system, as far as I know.) – David Z Apr 05 '20 at 21:31