by freedomben · 5y ago · 0 comments
Backtrack used to do something like this and while it was easier compared to a lot of other debian/ubuntu based things, I still ran into some pain points.
A great command to keep handy is
ls -la `which <program>`
That will usually find you the binary right away, and if it's a symlink or something you'll see it in the ls output. It's especially useful to me because (generally speaking) I put stuff I build myself in ~/bin rather than `/usr/local/bin` so I can quickly tell if I'm using my own build or the package manager's.Edit: FHS == Filesystem Hierarchy Standard - https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Many scripters who need wide compatibility of "which" fall back to the builtins `type` and `command` as they resolve any bash aliases set and give you a more truthful (sic) output than relying on `which` and bash is bash on all platforms:
# command -v which
/usr/bin/which
# type which
which is hashed (/usr/bin/which)
$0.02 for your next adventure down the `which` rabbit hole. :)When wide compatibility is needed it is best to avoid bash specific solutions.
[0] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c...
akira@akira:~ which which
which: shell built-in command kaneda@tetsuo:~ which type
kaneda@tetsuo:~ type type
type is a shell builtin
kaneda@tetsuo:~ command -v type
type
This was on Ubuntu, the which script doesn't resolve type or command silently, while on say Arch it's verbose ("can't find type in (paths ... ...)" so even a failure-to-find emits differently for the `which` crowd.You can read about it at a meta level over here, each distro has it's own wiki/working page if you Google around: https://www.freedesktop.org/wiki/Software/systemd/TheCaseFor...
Most uses of Linux are single-user, running as a server, or even more just a container.
But even if you consider the above to be a single-user setup (which is reasonable) I still think there's value in consistency. I personally get a ton of value from having CentOS and RHEL systems being laid out the same as my Fedora Laptop and Desktop system, and having all that knowledge transfer both ways. Being able to add a user to a "single user" setup too is very useful. It would suck if adding a second user required completely changing everything about the filesystem.
/lib for libraries
/usr/include for C includes
/etc for configsFTA you linked:
> Most Linux distributions follow the Filesystem Hierarchy Standard and declare it their own policy to maintain FHS compliance. GoboLinux and NixOS provide examples of intentionally non-compliant filesystem implementations.
Debian and Ubuntu adhere to FHS; they're not more difficult in this regard than Arch or Fedora (or distributions based on these). GoboLinux and NixOS don't because they serve a higher goal. GoboLinux for user-friendliness/explorability and has backwards compatibility (which is hidden via optional kernel extension), NixOS aims to solve dependency hell (among various other goals). Learning curves are an obvious drawback.
> ls -la `which <program>`
Backticks should be avoided; use ls -la $(which <program>) instead (avoid the $ in Fish).