File structure cheat sheet / reference card
Is there somehting like a cheat sheet or reference card for the linux file/directory structure that I could buy or download that would help me locate things under linux file system? I don't want a book, just a quick glance reference. I'm not bad with linux, but everytime I use it I have to partially re-learn everything since I really only do anything in it once or twice a year.
Funnily enough, this was the first result I got when googling 'linux file system'
The above link doesn't quite explain some stuff correctly. Here's an alternative explanation I banged out:
Essential for System Startup
/boot - Contains linux kernel and System.map files
/bin - Contains some small binaries useful by all. ls, cp, mv et all are here.
/sbin - Similar to /bin, but contains binaries needed by system administrators. ifconfig, passwd, fdisk, mount etc. are here
/lib - Shared libraries for all the binaries in /bin and /sbin. This is a dumb idea methinks. Traditionally in *nix systems, programs in /bin and /sbin should be standalone with no need for shared libs. It used to be that way in Linux as well until fairly recently when they went for the /lib dir.
/etc - Contains all the configuration files. Binaries in /bin and /sbin read the files here when the system boots up.
These five directories are essential for boot up.
/home - This is the directory under which normal users are given their home directory (/home/UserA, /home/UserB etc.)
/root - This is the directory specifically for the root user.
/tmp - Special directory that is generally writeable by anyone. Most system daemons place a small file here to keep track of their state. This directory may be flushed on reboot.
/var - Used to keep frequently changed data. For instance, all mail is generally stored here, as are various log files and even www files for a webserver (depending on OS flavor of course)
/lost+found - If you reboot your system without shutting down cleanly, fsck will attempt to fix corrupted files and put them here.
/opt - Very rarely used these days. Used to be for third party programs, now usually replaced by /usr/local in most cases.
The /usr dir hierarchy
This gets its own section:
/usr/bin - Sort of like /bin, but it contains larger programs that won't fit in the /bin directory. Programs here can be used by all, but are not so frequently used. Programs here could include gcc, emacs, OpenOffice and so on.
/usr/sbin - Sort of like /sbin, but contains larger programs that won't fit in the /sbin directory. Programs here are used by administrators, such as adduser.
/usr/lib - You're getting the idea, aren't you.
/usr/src - Contains the source code that is needed to build the kernel. Only installed if you install the kernel source.
Now for the /usr/local directory. Notice that it has a similar hierarchy as /usr and / (/usr/local/bin, /usr/local/sbin, /usr/local/etc, /usr/local/src etc.)
The difference between /usr and /usr/local is that /usr has programs that are installed by the OS install disks and /usr/local has stuff that is installed separately by the admin. So, if you upgrade your OS, stuff in /bin, /sbin, /etc and /usr tree may be overwritten by the upgrade, but stuff in the /usr/local tree will NOT be touched. Hence, if you install your own version of apache with special compile options, you'd want to install it under /usr/local tree, so that when you upgrade your OS, it doesn't get overwritten by the system version of apache. All your custom third party programs that are compiled from source should be placed under /usr/local/src.
There you have it.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
October 6th, 2013, 11:51 PM
Thanks Scorpions4ever for your informative post.
Here are a few more up-to-date Linux cheat sheets I have come across. They have varying levels of detail -- pick the one that suits you. Download, print out, and stick on your cubicle wall for easy reference.
1) A nicely formatted, pretty one, for basic commands:
2) A popular (the author claims "over 3.5 million hits in nearly 5 years") pair of Linux cheat sheets:
3) SSH Cheat Sheet:
4) Bash (default shell on most Linux distributions) cheat sheet:
Hope this is helpful.