Fucking Linux – How Does That Work?

I’ve used Linux here and there for almost a decade now. Whilst it makes a lot more sense now than it did at first I still find some of it baffling. Sure, I know what bash is; I know how to ls, cp, man, cp and rm. I even know how to partition my drives appropriately for a new installation. But earlier today I was installing Ruby and realised I still feel a bit like a Windows user in a foreign land. Where were the files for ruby actually being created? Where is my Program Files folder? And what the hell is /etc?

So I started looking at the Linux file system and tried to put it into words for a Windows user. Here are some basic answers that might come in handy. They might not be 100% technically accurate – and I know there are parts that will make people who do understand it properly wince – but it will hopefully give you (a Windows user) a better idea of the big picture than a technical description would. And from there you will know how to find out more accurate and detailed information. At least that’s the plan.

Note
One thing you have to understand before reading on is that Linux and Windows are different. If you try and treat one like the other you will probably run into trouble. A lot of this article is therefore kind of lies-to-children.

The Directory Structure

The most noticeable difference between Windows and Linux is that Linux doesn’t use drive letters. All connected media forms part of the overall file-system. This means you can have all your programs on one hard disk and all your files (E.g. /home) on another disk and it will all look like the same system. The reason for this is that Unix – which Linux is based on – was originally designed for large mainframe computers that were used simultaneously by multiple users across a whole company. In this way someone could replace the drive that held /home from a backup and nobody would notice a difference.

/ (Just a slash. AKA root.)
This is as high as you can go. This is the root directory of the whole file system. Comparable to a combination of “C:/” and “My Computer” on Windows (remember: Linux works differently!)

/home
This is where everyones personal files are stored. Each user has a folder inside this. E.g. /home/mrchimp Analogous to “C:/users/mrchimp/” or “C:/Documents and Settings/mrchimp/“.

/media
This is where CDs, and other removable media appear when inserted/connected to your machine.

/tmp
Temporary files. This gets emptied when you reboot.

/sbin
Essential system binaries that are required to boot e.g. init, ip, mount.

/bin
Essential command binary files (think EXEs and DLLs) e.g. cat, ls, cp.

/lib
Libraries essential for the contents of /bin and /sbin.

/boot
Files used to boot the system. Stores any boot loaders such as GRUB or LILO.

/dev
Stores “device files”. These are special files which are kind of like links to hardware that are stored as files. E.g. /dev/hda – points to the first hard disk; /dev/fd – points to the floppy disk. /dev also holds pseudo devices such as /dev/null which accepts and discards input and produces no output or /dev/random which produces a stream of random data.

/etc
Originally this folder was for “everything else”, hence the name. These days however it’s used for host-specific system-wide configuration files. Think “Editable Text Configuration” and you’ll be on the right lines. This is a low-risk folder – you might break things but they’ll probably be fixable – think editing a .ini file in Windows.

/usr
This is probably the closest thing to a Program Files folder that you will find but that’s probably misleading to say it like that. This is where the read-only program files go, kind of like the EXEs and DLLs that you would install on Windows. See also /var.

/var
This is (sort of) where the rest of your program files go, namely the files which are expected to change while the program is being run – e.g. logs, caches, draft emails etc.

Advertisements

About Mr Chimp

I make music, draw pictures, browse the internet, programme, and make sweet, sweet cups of tea until the early hours.
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

5 Responses to Fucking Linux – How Does That Work?

  1. Skilldrick says:

    This is really useful, I’m always getting confused with all these directories. The additional thing that confuses me is that /usr has almost all the same subdirectories as / has, so I’m never sure whether a binary belongs in /bin, /sbin, /usr/bin, /usr/sbin, or something underneath /home. Gah.

    Useful link: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

  2. Skilldrick says:

    The other thing I meant to say was that I’ve often heard /etc pronounced as “etsy”. I think that’s how you can tell a true Unix hacker (it’s like a not-very-secret handshake)…

  3. Mr Chimp says:

    From a technical standpoint the structure of the Linux file system makes a lot more sense than the Windows one but from a user’s point of view the Windows file structure is more intuitive.

    “‘Program Files’, hmmm, I think that probably holds the files for my programs. ‘Documents and settings’? Don’t tell me! I’ll work it out…”

    “/etc? Probably holds…um…stuff. Probably files and data and that. Ah /bin! That’ll be where my deleted files go……oh.”

    Ah, I meant to include that link in the post. Time to edit…

  4. John McNair says:

    I was looking at this just the other day as well! Handy to know but I can’t help but get the feeling I’ve only just scratched the surface….

  5. Mr Chimp says:

    Yeah, I wouldn’t say this is all you need to know about Linux. Not by a long way!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s