Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One thing I was wondering recently is what are all the files in a tar.gz that I install. I’ve been messing with my remarkable tablet lately, and it’s a stripped down Linux environment. When I use wget to get packages, I get a usr folder with a bunch of stuff. I’m not really sure how to install thereafter? There’s no package manager. What’s the structure behind: usr/, bin/ etc/ lib/ and moving those to usr/local? Any resources?


Distributed binary packages (.deb, .rpm), are just a compressed file "like" a tar.gz with a little bit of metadata too.

> What’s the structure behind: usr/, bin/ etc/ lib/ and moving those to usr/local

A brief resume of the filesystem structure purposes is documented in "man hier" in any non stripped down linux (or online).

When you compile source code to binary format, there is a default PREFIX (i.e. /usr). So libraries will be installed to /usr/lib and binaries to /usr/bin...

Build systems, let you change such PREFIX, so you can build a program telling it to live under /usr/local, or any other root directory like /opt/myprog-version...

Then. if you build another program, that depends on the libraries of the previous program, you may need to tell where to locate such libraries if they are not in the default place, each program build flags may vary, but for example in ruby you can pass it to ./configure --with-openssl-dir=/opt/myopenssl-X.Y


Thanks for the tip about "man hier" :)


There's also file-hierarchy(7) which is more systemd-centric.


Sometimes the tar files are just archives that get extracted at /, which is a fairly primitive but functional way to distribute packages.

For a description of the directories, see: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

Note that these directories do not actually have many hard and fast rules... while you can't change /proc, you can argue all you like over whether something goes in /bin or /sbin, or argue whether it should go in /usr. There are a ton of differences in the details.



This looks great!!


I missed that you were talking about non-x86, if you just go up a few levels you can see the docs for other platforms.


The tar, assuming it comes with a Makefile, should have a Make install command or equivalent. On Debian/Ubuntu based systems, the convention is to use checkinstall to keep track of installation. Another new trend in recent years is to install third party packages to /opt.


Ah I see. In my case I was installing precompiled binaries for an armv7 architecture.


For the most part, you can read the Filesystem Hierarchy Standard to get an idea of what all the different directories do: https://www.pathname.com/fhs/

Distros mostly keep to this, but they implement their own details and you should look into each distribution to know exactly what goes on in any particular one.


Yeah - I was kind of reverse engineering the one on the tablet which is a custom thing on ArmV7 so it was kind of like a guessing game


The Filesystem Hierarchy Standard describes a lot of how Linux filesystem is laid out. Wikipedia has an OK intro https://en.m.wikipedia.org/wiki/Filesystem_Hierarchy_Standar...

For user applications the XDG Base Directory specification is also useful https://specifications.freedesktop.org/basedir-spec/basedir-...


If you are wondering what all those files in /bin are, some of them exist, because they are part of the POSIX standard and have to be present in every POSIX compliant system. A good overview over these commands can be found here:

https://shellhaters.org/

The links lead directly into the POSIX documents, which can be quite handy when you write shell scripts, because there you can read which options should be the same on every POSIX compliant OS.


If you want to install such a package into its own prefix (not directly to /) the convention is typically to use /opt/$SOFTWARENAME. So one would have bin,lib etc under that directory. If the software is not designed to be relocatable like this, one may have to set up PATH, LD_LIBRARY_PATH, etc so that it can find its executables, libraries etc


In general you should do your absolute best to avoid downloading and running binaries.

It's insecure and it's very prone to error on Linux. There's almost always a better way (and anyone who says differently is probably trying to sell something to someone.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: