Ubuntu /bin and /sbin symlink to /usr/bin

Today I wanted to write about a quick Linux and Docker/containers tip. I might write more of these, as I have gathered a non-trivial amount of Linux and Ubuntu tips, tweaks and miscellaneous things (plus some related adventures at work) that might be worth sharing.

Since Ubuntu 20.04 (and earlier at Debian), /bin and /sbin are symlinks to /usr/bin. While this sounds nice and simple, it is good to be aware of this change when migrating containers from Ubuntu bionic to focal, because, if they copied any binary or script to /bin, now they will error.

The error if attempting to move stuff to /bin, while hinting the issue, is not 100% clear. It'll be something along the lines of:

ERROR: cannot copy to non-directory: /var/lib/docker/overlay2/<a-big-hash>/merge/bin

If you inspect the contents of the layer, or just do a quick test like RUN ls -al /bin before moving your script(s), you will notice the presence of the symlink instead of either nothing or a folder.

The solution is simple, just move the scripts to /usr/bin instead. And for clarity, change your script invocations to also run /usr/bin/<script-name>.sh and the like. Although /bin/<script-name>.sh will still work, it might not be clear why there are multiple, different paths.

Ubuntu /bin and /sbin symlink to /usr/bin published @ . Author: