*nix File System

"Please leave a message at the beep, we will get back to you when your support contract expires."

Moderators: phlip, Moderators General, Prelates

User avatar
someguy
Posts: 486
Joined: Sun Sep 16, 2007 11:43 pm UTC

*nix File System

Postby someguy » Sun Jan 18, 2009 7:27 pm UTC

('File system' may not be the right term. Read on.)

Hello everyone. I'm trying out Linux... AGAIN... this time Xubuntu 8.10 as a persistent USB install. Works well so far, I've been able to install Opera and I'm surfing the 'net as if nothing had changed.

BUT. There's one thing. One of the things that have held me back every time I've tried to use any flavor of Linux for an extended period of time is that I don't understand how its file structure is laid out. I've always used Windows, I'm somewhat knowledgeable about its ins and outs, ie. I know what many of the folders inside the %Windir% directory are for, what's inside them, where to go searching for 'x' (a missing DLL, whatever) when I'm troubleshooting something, etc.

Not so with Linux. So I was hoping maybe a few of you could point me to a few places where I could read up on this (yes, I do know about Google, but still...). I'd very much appreciate it.

Marginally related: what's with the double caps I always get when I switch over to Linux? I admit that I've a bad habit of clicking CAps LOck (see what I mean?) on and off when I need to type an uppercase letter, but I never get double caps in WINdows (triple caps! HA!). IS this a parameter that needs to be lowered or increased somewhere? IT feels as though it weren't releasing the CAps key fast enough (doesn't happen if I type more slowly.)

THanks!
aleflamedyud wrote:Plenty of people have confidence without any base of actual virtue or accomplishment beneath it. We call these people "douchebags".


User avatar
Area Man
Posts: 256
Joined: Thu Dec 25, 2008 8:08 pm UTC
Location: Local

Re: *nix File System

Postby Area Man » Sun Jan 18, 2009 8:11 pm UTC

Bisquick boxes are a dead medium.

User avatar
felixalias
Posts: 159
Joined: Sun Sep 21, 2008 10:55 pm UTC
Contact:

Re: *nix File System

Postby felixalias » Sun Jan 18, 2009 8:21 pm UTC

This is probably a horrible description in some way, but basically:

/boot: This is where kernel images along with bootloader configuration are stored (usually)

*/bin (/bin, /usr/bin): These are binaries meant to be executed by the normal user. /bin is generally for 'core' binaries, such as 'mv', 'cp', and /usr/bin is meant for more optional binaries, such as 'audacity' or 'gnome-calculator'.

/dev: This is where udev creates entries for your devices.

/etc: This is where the vast majority of your configuration files live.

*/lib: This is where the libraries are stored (similar to DLLs, they have the extension .so instead). Again, like with /bin and /usr/bin, very core libraries (libc) are in /lib, whereas less essential ones are in /usr/lib (libSDL.so).

/lib/modules: If you are messing around with kernel drivers, this is the place you want to be.

/lib/firmware: Also a place of note. Firmware blobs are kept here.

*/sbin: Binaries usually meant to be executed by the superuser (insmod). Often binaries that have some root-required functions are stored here (A good example would be ifconfig, you don't need to run it as root for basic diagnostic).

/tmp: Temporary files here.

/var: Variable data; similar to temporary files, except usually meant for things such as logs (/var/log)

/mnt OR /mount: Mounted filesystems, like a CDROM drive.

http://www.debianadmin.com/linux-direct ... rview.html can explain what I've left out (I think it leaves out a few itself, though)

As for the capslock.. I have no idea, I make use of my shift key ;)

User avatar
someguy
Posts: 486
Joined: Sun Sep 16, 2007 11:43 pm UTC

Re: *nix File System

Postby someguy » Sun Jan 18, 2009 8:25 pm UTC

Thanks for taking the time to type that in. I'll take a few close looks at it.
aleflamedyud wrote:Plenty of people have confidence without any base of actual virtue or accomplishment beneath it. We call these people "douchebags".


Ubik
Posts: 1016
Joined: Thu Oct 18, 2007 3:43 pm UTC

Re: *nix File System

Postby Ubik » Sun Jan 18, 2009 8:28 pm UTC

I'm not surprised that others posted before me, but I'm not throwing this away. Hopefully this adds something new.

There is a Wikipedia article that has a nice list of main directories of *nix systems: Filesystem Hierarchy Standard

Some main points as a list:

  • There is no separate drives like in Windows, all partitions and disks are in the same hierarchy.
  • Therefore there's also no drive letters, everything just starts from /
  • The way files are usually used in *nix systems is in a way reverse version of the Windows style. In Windows most of the file system is unrestricted, you can put files almost everywhere except for some special directories (for example c:\Windows and c:\Program Files) which are restricted and more privileges are needed to use them. In *nix system most of the file system is not writable for regular users and is reserved for the system. Users are encouraged to use only their home directory, which usually is /home/username.
  • Linux is not perfectly consistent on this, but most things are files, even some things you might not at first consider to be files. Check directory /dev - from there you can find your hard drives as files named /dev/hda or /dev/sda or something similar.
  • The Wikipedia article has more comprehensive list, but I'll try to make a list of the actually important main directories:
    /boot - This directory contains kernel files and in Xubuntu and many other Linux distributions, it also contains boot loader configuration.
    /home and /home/username - As I already told, you should keep your personal files in your home directory. Your personal configuration files are kept in hidden files and directories in your home directory. If you keep a backup of this place, you have a lot covered.
    /etc - Pretty much all of the system-wide configuration files are here. Most of them are plain text files which can be edited with a text editor. You might need to do things here occasionally, and for that you need to use sudo to gain more privileges.
    /dev - Contains devices - normally you don't need to do things here by yourself.
    /var - This directory contains log-subdirectory where log files are kept. The files here change a lot, they are variable.
    /tmp - Temporary files are often stored here.
    /mnt and /media - Under there directories, other file systems are often mounted. If you insert a CD, it will most likely appear in directory /media/cdrom.
    /bin and /usr/bin - These directories contain program executables. Former contains "core" programs and latter contains those executables that are not completely necessary for the system to work.
    /lib - Shared libraries, "dll:s of Linux" are here
  • I already mentioned hidden files. In *nix systems filenames that begin with a dot are considered hidden.
  • In command line you can usually point to your home directory with a single "~".
  • Programs are not usually in a single directory, they are spread all over the file system. Package manager helps you with this, you rarely need to put any program files in place manually.

Edit: Oops, forgot some important directories. (Yay for even more redundancy!)

User avatar
someguy
Posts: 486
Joined: Sun Sep 16, 2007 11:43 pm UTC

Re: *nix File System

Postby someguy » Sun Jan 18, 2009 9:00 pm UTC

Area Man wrote:and re: caps lock - http://capsoff.org/

thanks for that. I've disabled it altogether, maybe it'll help 'retrain' my typing.
aleflamedyud wrote:Plenty of people have confidence without any base of actual virtue or accomplishment beneath it. We call these people "douchebags".


User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: *nix File System

Postby '; DROP DATABASE;-- » Mon Jan 19, 2009 5:55 am UTC

I've never really been clear on the difference between /var and /tmp. It seems like /tmp is for files that themselves are volatile (i.e. likely to be deleted at any moment), whereas /var is for files whose contents are volatile (not a lot of files being created or deleted, but frequently modified). Is that about right?
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: *nix File System

Postby Carnildo » Mon Jan 19, 2009 7:27 am UTC

More or less. Rule of thumb for /tmp is that if you want to open a file, modify it, close it, and expect it to still be there, don't put it in /tmp. /var is for frequently-modified system files, but it's also for short-lived files that nonetheless need to reliably exist for a while, such as the mail queue or the print queue.

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: *nix File System

Postby '; DROP DATABASE;-- » Mon Jan 19, 2009 9:15 am UTC

So basically, any file in /tmp may theoretically be deleted as soon as it's closed? That makes sense.
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

User avatar
Jorpho
Posts: 6279
Joined: Wed Dec 12, 2007 5:31 am UTC
Location: Canada

Re: *nix File System

Postby Jorpho » Mon Jan 19, 2009 4:43 pm UTC

felixalias wrote:/mnt OR /mount: Mounted filesystems, like a CDROM drive.
/media seems to be increasingly common these days. Such a tricky business.

User avatar
tendays
Posts: 957
Joined: Sat Feb 17, 2007 6:21 pm UTC
Location: HCMC

Re: *nix File System

Postby tendays » Mon Jan 19, 2009 9:54 pm UTC

'; DROP DATABASE;-- wrote:I've never really been clear on the difference between /var and /tmp. It seems like /tmp is for files that themselves are volatile (i.e. likely to be deleted at any moment), whereas /var is for files whose contents are volatile (not a lot of files being created or deleted, but frequently modified). Is that about right?

If /bin contains programs and /etc configuration, I see /var as containing data not belonging to a particular user (as opposed to /home). I keep my databases in there, my web sites, my subversion repositories, etc. Those are not really volatile. But things like /var/log and, even more /var/run are indeed more short lived. To confuse things more there's also a /var/tmp but I don't really see the point of that one. Maybe to have temporary files in the same partition as other /var things, if /var is a partition...

When I backup my system I backup /etc, /home and /var (configuration, user files, and data). I obviously don't backup /tmp so that's a big difference between /tmp and /var).
<Will> s/hate/love/
Hammer wrote:We are only mildly modly. :D
Beware of the shrolymerase!

User avatar
Jorpho
Posts: 6279
Joined: Wed Dec 12, 2007 5:31 am UTC
Location: Canada

Re: *nix File System

Postby Jorpho » Mon Jan 19, 2009 10:14 pm UTC

Let's not forget the confusion of /usr/local/bin and /usr/local/sbin .

One thing in particular that confuses me: is everything outside of /home supposed to be read-only by everyone except root? If not, what exactly should be writable?

User avatar
Area Man
Posts: 256
Joined: Thu Dec 25, 2008 8:08 pm UTC
Location: Local

Re: *nix File System

Postby Area Man » Mon Jan 19, 2009 10:53 pm UTC

Jorpho wrote:Let's not forget the confusion of /usr/local/bin and /usr/local/sbin .

One thing in particular that confuses me: is everything outside of /home supposed to be read-only by everyone except root? If not, what exactly should be writable?


/tmp and /var/tmp are writable and have the "sticky"-bit set.

/usr/local/{s}bin is empty, check the standard:
http://www.pathname.com/fhs/pub/fhs-2.3.html
Bisquick boxes are a dead medium.

Ubik
Posts: 1016
Joined: Thu Oct 18, 2007 3:43 pm UTC

Re: *nix File System

Postby Ubik » Mon Jan 19, 2009 10:54 pm UTC

Jorpho wrote:One thing in particular that confuses me: is everything outside of /home supposed to be read-only by everyone except root? If not, what exactly should be writable?

The tmp directories are probably the only ones that are writable by everyone. Rest of the non-/home directories are usually not writable for regular users, but many directories in /var are owned by special users that are used to run services. Web-related files can belong to apache or httpd (though not all of them, it's safer if web server can't overwrite your code files) and user mysql owns MySQL database files and so on.

Edit: tmp-ninja'd!

sakeniwefu
Posts: 170
Joined: Sun May 11, 2008 8:36 pm UTC

Re: *nix File System

Postby sakeniwefu » Tue Jan 20, 2009 1:10 am UTC

felixalias wrote:/etc: This is where the vast majority of your configuration files live.

Don't believe this, it's an elaborate troll. :wink:
Most of *your* configuration files, along with a few GBs of data from applications you uninstalled months ago is hidden in your /home.
Do ls -a and feel the horror. 8)

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: *nix File System

Postby Carnildo » Tue Jan 20, 2009 3:31 am UTC

Jorpho wrote:One thing in particular that confuses me: is everything outside of /home supposed to be read-only by everyone except root? If not, what exactly should be writable?


/bin, /boot, /dev (mostly), /etc, /lib, /sbin, and /usr are root-only. /tmp and /var/tmp are "sticky": anyone can create files and set the permissions on those files however they want; only the creating user (or root) can delete a file. /var and its subdirectories contains directories that are writable by only a single daemon user or system account. /mnt and /media vary depending on the mounted volumes. /opt is a free-for-all. OS-specific directories such as /proc and /sys are usually root-only.

10nitro
Posts: 192
Joined: Mon Nov 03, 2008 8:46 pm UTC
Contact:

Re: *nix File System

Postby 10nitro » Tue Jan 20, 2009 4:06 am UTC

*slightly off-topic*
Why does Apache use /var/www/ by default? To me, it seems that Apache generally deals with documents.
~ Luke Shumaker
FRC1024 Programmer
IT technician, GNU/Linux admin, comp. security guy
Eagle Scout
http://lukeshu.ath.cx

User avatar
Jorpho
Posts: 6279
Joined: Wed Dec 12, 2007 5:31 am UTC
Location: Canada

Re: *nix File System

Postby Jorpho » Tue Jan 20, 2009 4:07 am UTC

Area Man wrote:/usr/local/{s}bin is empty, check the standard:
http://www.pathname.com/fhs/pub/fhs-2.3.html
Oh, standard! *chortle*

User avatar
hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: *nix File System

Postby hotaru » Tue Jan 20, 2009 5:55 am UTC

Area Man wrote:/usr/local/{s}bin is empty, check the standard:
http://www.pathname.com/fhs/pub/fhs-2.3.html

wrong.
http://www.pathname.com/fhs/pub/fhs-2.3 ... LHIERARCHY
bin Local binaries
...
sbin Local system binaries

Code: Select all

factorial product enumFromTo 1
isPrime n 
factorial (1) `mod== 1

User avatar
Area Man
Posts: 256
Joined: Thu Dec 25, 2008 8:08 pm UTC
Location: Local

Re: *nix File System

Postby Area Man » Tue Jan 20, 2009 7:52 am UTC

hotaru wrote:wrong.

Wrong?
Was my explanation too succinct for you? I didn't say they always have to remain empty.
/usr/local/bin and sbin are empty unless (naturally) you put some files in there (or the dirs can just be symlinks); whatever distro you're using should not be touching them.
Some(/most?) software which you compile from source may want to install itself there by default if you don't override it with --prefix during config.

What's the confusion, anyway? Any sbin directory contains programs to be used only by root; regular users should not even have anything containing "sbin" in their $PATH.
Bisquick boxes are a dead medium.

User avatar
someguy
Posts: 486
Joined: Sun Sep 16, 2007 11:43 pm UTC

Re: *nix File System

Postby someguy » Tue Jan 20, 2009 8:23 am UTC

(Still here and reading all your posts. Thanks everybody. I'm attending a course Mon-Fri and haven't had time to sit down with this yet.)
aleflamedyud wrote:Plenty of people have confidence without any base of actual virtue or accomplishment beneath it. We call these people "douchebags".


User avatar
tendays
Posts: 957
Joined: Sat Feb 17, 2007 6:21 pm UTC
Location: HCMC

Re: *nix File System

Postby tendays » Tue Jan 20, 2009 3:33 pm UTC

Area Man wrote:Any sbin directory contains programs to be used only by root; regular users should not even have anything containing "sbin" in their $PATH.
Some network tools like traceroute, ifconfig and iwconfig are in sbin ... I guess they're there because they are more powerful when ran as root or something. Though it's debatable for traceroute as it's similar to ping but ping is in bin...
(Just checked - actually traceroute is in sbin with ubuntu, and in bin with debian).
<Will> s/hate/love/
Hammer wrote:We are only mildly modly. :D
Beware of the shrolymerase!


Return to “The Help Desk”

Who is online

Users browsing this forum: No registered users and 5 guests