File System Layout

Like MS-DOS and most operating systems, Unix uses a set of subdirectories
for organization. To help keep some logical order, many system directories
exist, each with a name that implies what is held there. Knowing the layout
of a Unix system helps navigate the system, find the required binaries, etc.
For the most part, these directories will remain fairly consistant among
all flavors of unix. Directories like /bin, /etc/, and /sbin are
guaranteed to be found on all flavors. If not, the admin messed up something
during install or some new company has a wierd idea of what unix is ;)

  /bin  	(binaries) - essential system binaries
         	ls, cp, mv, chmod, cat, kill, gzip, and more

  /sbin 	(system binaries) - system binaries, daemons, and 
          	administrative programs.
          	fsck, mount, umount, adduser, shutdown, route, and more

  /dev		(devices) - device files represent physical and logical devices
         	on a unix system. Having files that represents physical devices
		allows for more flexible manipulation and easier notation.
		(the following designations are mostly found on linux unless otherwise 
		specified.)

		Examples of input/output devices on Linux.

		crw-rw-rw-   1 root     sys       14,   4 Jul 18  1994 /dev/audio
		lrwxrwxrwx   1 root     hide            4 Oct 29  1998 /dev/mouse -> cua0

		Examples of different drive devices on linux. hda1 designated an 
		IDE drive, fd1 a floppy, and sda a SCSI drive.

		brw-rw----   1 root     floppy     2,   1 May 14  1996 /dev/fd1
		brw-r-----   1 root     disk       3,   1 Apr 27  1995 /dev/hda1
		brw-r-----   1 root     disk       8,   0 Apr 29  1995 /dev/sda

		Examples of different drive devices on NetBSD.

		brw-r-----  1 root  operator   4,  0 Jul 31 17:03 /dev/sd0a
		brw-r-----  1 root  operator   4,  1 Aug  1 13:41 /dev/sd0b
		brw-r-----  1 root  operator  0,  0 Jul 31 17:03 /dev/wd0a
		brw-r-----  1 root  operator  0,  1 Jul 31 17:03 /dev/wd0b

		Examples of different drive devices on Solaris.

		brw-r-----   1 root     sys       32, 14 Aug  4 11:51
	        ../../devices/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0:g
	
		(ugly eh? :)

		Examples of virtual consoles (consoles at the physical machine)

		crw--w--w-   1 root     root       4,   1 Aug  2 11:16 /dev/tty1
		crw--w--w-   1 root     root       4,   2 Jul 31 15:40 /dev/tty2

		Examples of pseudo terminals. If you access the machine remotely, you 
		are allocated a pseudo terminal.

		crw-rw-rw-   1 root     tty        2, 177 Aug  4 20:18 /dev/ptya1
		crw-rw-rw-   1 root     tty        2, 197 May 20  1996 /dev/ptyb5

		Examples of serial ports on a Linux system. These correspond with
		COM1, COM2 etc in MSDOS.

		crw-rw----   1 root     14         5,  65 Jul 17  1994 /dev/cua1
		crw-rw----   1 root     tty        4,  64 Jul 17  1994 /dev/ttyS0

		Examples of printers under Linux.

		crw-rw----   1 root     daemon     6,   1 Apr 27  1995 /dev/lp1
		crw-rw----   1 root     daemon     6,   2 Apr 27  1995 /dev/lp2

		"devnull" is a virtual device for 'nothing'. Anything sent to this
		device will disappear. This often good for redirecting error output,
		or anything else you don't want to see.

		crw-rw-rw-   1 root     sys        1,   3 Jul 17  1994 /dev/null

		Devices are a funny thing. As time progresses, their use and 
		importance will become more and more clear.

  /etc		Contains many system configuration files.
        
		/etc/passwd - essential user information including user name,
                              user id, group id, home directory, and shell

		/etc/shadow - encrypted password, account expiration information

		/etc/group - user/group information

		'rc' files - system startup/shutdown scripts

		/etc/security/ - some unix flavors use this to store files
                                 relating to system security

  /home		(home directories) - where users store their files and do daily
	        activity from. for the average user, this will be the most
        	important directory they use

  /lib		(libraries) - shared library images. Many programs rely on
	        these. Libraries have common routines that can be used by
        	many programs. Instead of creating new libraries for every
        	single application, they share these. Unix library files are
        	akin to Windows .dll files.

  /proc		(processes) - 'proc' is a virtual file system. Files here
		are stored in memory, not on the drive. A user or admin
        	can get information on programs running through the proc files.

  /tmp		(temporary) - Many programs (and users) utilize this directory
		for writing files while running and remove them when done. Users
		with a quota (or limit on their disk space) can access this space
		for temporary storage. Beware! Admins like to delete stuff here
		when running low on diskspace. On some systems, this directory
		is completely erased during bootup.

  /var		(various) - mostly system subdirectories that used to reside
		in the /usr directory but have since been broken out to here.

		/var/adm - linked to /var/log in linux, 'adm' notation is used
                	   in other flavors of unix.

		/var/log - system logs that record user and system activity.
                	   Logs keep track of connections to the system, daemon
			   activity, file transfers, mail, and more.

		/var/spool - spool dir contains incoming mail, outgoing mail,
                	     cron jobs, and more.

		/var/man - various manual pages on system binaries

  /usr		(user) - Contains a wide variety of subdirectories full of user and
		administrative tools

		/usr/X11R6 - The X-Windows subdirectory - all X-Win programs and
			     config files

		/usr/sbin - much like /sbin, a bulk of system admin programs are
                	    located here

		/usr/bin - much like /bin, this contains the bulk of the unix
			   programs not found in other places

		/usr/etc - more configuration files for system utilities
			   and programs

		/usr/include - 'include' files for the C compiler - primarily
			       used for system programmers

		/usr/lib - more shared libraries for system applications

		/usr/man - more manual pages for system tools

		/usr/local - files not essential to the system or users, but
			     often the home of many extra utilities that give
			     the system a lot of its functionality. Programs
			     like 'ssh' and 'pgp' are typically installed here
			     by default.


Since writing this, Demonika has kindly pointed out that "man hier" will
give a similiar (and more thorough) list of the file system hierarchy.


jericho@attrition.org (c) copyright 1998, 1999 Brian Martin