linuxnewbie.org.gif
Tuesday, 12-Dec-2000 10:32:05 EST
Newbized Help Files articles discussion board bookshelf sensei's log advertising info

Directory Navigation NHF V1.0

By Sterling (npilon@is2.dal.ca)


This is an incredibly basic NHF designed to give a general idea of the layout of the standard Linux filesystem. Since this varies quite a bit from distribution to distribution, not everything in here will hold true for all distributions. Since I know Debian, that's the one I'm providing the boot script structure for. Anyone who knows RedHat/Mandrake/SuSE/whatever can feel free to add data on how those distros do things (although it will invariably be inferior to Debian's methods ;).

Note on Unix programs: Windows programs generally put all or most of their files in one directory. Program x might be in c:\program_crud\X, for example, and Y might be in c:\games\Y. Unix uses a much more efficient (but also more confusing to us humans) system where, instead of dividing files by program, files are divided by purpose. Binaries go in one place, config files in another, and data in yet another... This can be quite confusing for a user migrating to Unix from Windows, and this NHF should help you locate stuff... Hopefully.


Directory Structure

/ - This is the root directory. Under windows, DOS, OS/2, and cousins, there's a seperate root directory for each drive or partition. Linux and other Unix variants put everything in one directory tree, and this is at the base. There's generally not much in here other than directories, although kernel images might be stored here too.

/boot - Some distros store kernel images and other miscellaneous files needed to boot here.

/tmp - Generally only temporary files needed at boot. Things that need temporary storage after boot generally use /var/tmp, but this isn't universal by any means.

/mnt - This is where directories go for mounting various miscellaneous filesystems. Sometimes, /cdrom and /floppy are used for mounting cdrom and floppy devices, but I'm not sure how many distros other than Debian do this. /mnt is also sometimes called /mount.

/lib - Libraries needed at bootup. Libraries not needed at bootup but needed after the system is running should go in /usr/lib. Kernel modules generally go in /lib/modules/<kernel-version>.

/dev - Device files go here. These are special files created by the Linux kernel that can be used by programs to control hardware devices. Note that network interfaces (eth0, ppp0, etc) don't exist here.

/proc - This filesystem doesn't actually exist on disk. It contains files that provide information about the state of the computer, including info on running processes, hardware states, and memory usage. Most of the files aren't easily read by humans, though.

/var - Contains data changed when the system is running normally. /var/tmp, for example, should be used for storing temporary files. Various processes and daemons dump logs here, and some important subdirectores are:

/var/lock - Lock files. These are created by programs when accessing a specific resource. They don't actually prevent access, so respecting a lock file is more of a politeness thing. Most programs do respect them, and thus you don't have to worry about them unless you're writing a program.

/var/log - Log files are generally written here. This directory may grow quite large, and so may require regular cleaning.

/var/run - Contains various bits of runtime information.

/var/lib - Contains various files needed while the system is running. One that will almost definitely be of interest to laptop users is /var/lib/pcmcia/stab, which contains some information about PCMCIA devices.

/var/spool - Mail, news, and printer queues get stored here.

/root - Home directory of the root user. Shouldn't be much stored here at all, as you should be using normal, unprivilaged users for anything that doesn't require root privilages.

/home - This contains the home directories of most of the users on the system. You can type cd to return to your home directory, and you can use ~/ as a shortcut to refer to your home directory. Personal config and data files for normal users go here.

/etc - Probably where you'll spend most of your time as root, this is where most system-wide configuration files are stored. Files for specific users are almost always stored in the user's home directory. The contents will vary depending on what you've got installed, but some subdirectories that are probably of interest are listed below.

/etc/X11 - This is where system-wide X11 configuration files are stored. XF86Config stores data used by the server to set up the environment. /etc/X11/fonts is where the fonts used by the server are stored, and window managers generally create subdirectories for their config files.

Boot related stuff for Debian:

/etc/init.d - Debian stores the actual scripts for starting daemons and services here. Not all of these are necessarily started at boot time, so don't remove any unless you're absolutely sure its safe. Most are created and removed by their associated packages, so you'll rarely have to do anything here.

/etc/rcS.d - These are soft links to scripts in /etc/init.d that are run during startup no matter what runlevel the system's booting into. The files start with an S followed by two digits - services are started in an order determined by these two digits. For example, S24foo is started before S42bar. The rest of the filename should be the name of the file in /etc/init.d the file is linked to.

/etc/rc0.d through /etc/rc6.d - These are soft links, just like in /etc/rcS.d, except they're only executed when entering the specified runlevel. 0 is shutdown and 6 is reboot. Anything starting with a K shuts down a process, and anything starting with an S starts one. Other than that, they follow the same rules as /etc/rcS.d. By default, as far as I can tell, Debian boots into runlevel 2.

/bin and /sbin - Programs and system programs needed when the system is booting, respectively. Most are also useful after the system boots up, but they're put here because they're generally needed before any other programs.

/usr - This is the really big directory. Almost everything goes under here, unless I mentioned it above, so I'm going to go into quite a bit of detail about subdirectories and so on.

/usr/X11R6, usr/X11, or /usr/Xfree86 - These are files used by X11, and the files under them are structured like the /usr directory.

/usr/bin - Binary files (program executables) that aren't needed during boot go here. This is probably where most of the programs you use during normal system operation reside.

/usr/sbin - These are system programs not needed during boot.

/usr/games - Game programs and (sometimes) data files and configuration stuff.

/usr/include - C and C++ header files. Probably not of much interest to you unless you're into programming with C and/or C++.

/usr/lib - Library and shared library files not needed at bootup.

/usr/info - Data files needed by the GNU info program.

/usr/man - Data files needed by the man program.

/usr/src - Source code files. The linux kernel source is usually in /usr/src/linux.

/usr/doc - Documentation files go under here. There's probably quite a lot here, and there are quite a few programs that just put copyright and changelog files here and document themselves through man or info. Of particular interest is the HOWTO directory where (probably) your distribution has placed a collection of HOWTOs from http://www.linuxdoc.org. These aren't quite as simplified as NHFs, but they're still quite good.

(The perceptive will notice that most directories in /usr/doc are actually links to the real location of the documentation...)

/usr/local - This directory contains things that are specific to the local system. Really only takes on any meaning if /usr is being mounted from a remote machine, VIA smb or nfs or some other networking filesystem. In that case, /usr/local would be a partition on the local machine, and the machine's user would put their programs there. This directory is usually structured like the /usr tree is.

/usr/shared - Shared files for programs go here. What a program puts here is, as far as I can tell, pretty much arbitrary, but sound files seem to be a fairly common thing to put here.

That's all the major directories I could pick out of my filesystem. If I've made any mistakes, left anything out, or whatever E-Mail me at the above address and I'll be glad to try and include it.


Resources Used

ls and cd - Get used to these programs. You'll use them a lot.

http://www.linuxdoc.org/LDP/sag/c218.html: The Linux System Administrator's Guide, Chapter 3: Overview of the Directory Tree. I recommend reading this entire guide if you're planning on administering a Linux system of any scale, but this is the section I used for this NHF when my own memory came up blank. Most of the info I got from my memory came from this guide, even.


Copyright (C) 2000 by Nick Pilon. Licensed under the terms of the GNU Free Documentation License. See http://www.gnu.org/copyleft/fdl.html for details.



Would you like to have your article published online? Send them in to newfiles@linuxnewbie.org
The Linux Channel at internet.com
Linux Planet
Linux Today
Linux Central
Linuxnewbie.org
PHPBuilder
Just Linux
Linux Programming
Linux Start
BSD Today
Apache Today
Enterprise Linux Today
BSD Central
All Linux Devices
SITE DESCRIPTIONS
[-What's New-]
Order a Linuxnewbie T-Shirt
Easy Webcam NHF
Directory Navigation NHF
Installing Snort 1.6.3 on SuSE 6.x-7.x
Customizing vim
The SysVinit NHF
Installing ALSA for the VT82C686 integrated sound
USB Creative Video Blaster II for Linux
Configuring the Intellimouse Explorer in XFree86 V4+
The beginnings of a distro NHF
Getting Past Carnivore?
Getting and Installing PGP
Getting your ATI Rage 128 Working
How to create a multiple partition system
Using Fdisk
Introduction to Programming in C/C++ with Vim
Adding a Hard drive in Linux -- In five steps
Installing ALSA for the Yamaha DS-XG Sound Card
Getting your Diamond Rio Mp3 Player to work with Linux
Bash Programming Cheat Sheet
Installing NVIDIA Drivers for Mandrake
Setting up Portsentry
Hard Drive Speed Tweak for Linux
Sensei's Log
Chat room
Join: Linuxnewbie.org SETI Black Belts!
Send in your news
Click the image to add Linuxnewbie.org to your MyNetscape Page
[-LNO Newsletter-]

[-Archive-]
The beginnings of a distro NHF
Connecting to the Internet using KPPP
Getting your SBLive to work
Unreal Tournament NHF
LWE Day 2 Pictures
LWE Day 1 Pictures
The LNO FAQ!
WoW (Words of Wisdom)
Other sites news
What is Linux?
What is Linux? part deux (ups & downs)
Search newsgroups
The List
ALS Report
Feedback Form
jobs.linuxtoday.com.gif
Match: Format: Sort by:
Search:
[-Quick Links-]

Copyright 2000 internet.com Corp. All Rights Reserved. Legal Notices Privacy Policy

internet.com.gif