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:


and this is a little demo:

enter image description here

  • 3
    On the contrary, /usr/bin is effectively never a good choice for users to put stuff. – Konrad Rudolph Apr 4 at 21:01
  • Issue man hier. There you can read which directories can be used. – Shiplu Mokaddim Apr 5 at 13:44

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 Apr 4 at 11:31
  • 5
    Maybe it's picky, should it be /usr/local/sbin since it's a system administration script? – steeldriver Apr 4 at 12:37
  • @N0rbert thank you very much for your official reference! ;) – maxwatt Apr 4 at 21:08
  • 1
    @steeldriver effectively /usr/local/sbin seems to be the better choice! – maxwatt Apr 4 at 21:13

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 | |
  • 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 4 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 4 at 21:17
  • 1
    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 5 at 4: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 5 at 21:31

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