Directories

Directories on Linux are different than directories on Windows. Or rather, Windows has only recently begun to come around to the Linux view of how directories should be structured. In particular, there is clear evidence of the Linux way of thinking in the recent effort on Microsoft's part to put an emphasis on directories with names like "My Programs," "My Documents" and "Documents and Settings." I will not try to decide whether or not the attempt on the part of the stalwarts in Redmond is successful -- or perhaps not so successful. I will only say that it is an attempt to treat directories in manner reminiscent of the directory structure on Linux.

On Linux, your disk is divided up into various directories that provide specific services. You will never understand Linux unless you begin to associate at least the majority of these directories with specific types of files. This is not a trivial task, but it is one that must be mastered if you want to feel at home in the Linux OS.

Let's start by dividing the OS into those that you, as a user own, and those that are owned by the OS. The home directory contains directories that can hold users text, source and office files.

/bin: Essential binaries for booting the system

/sbin: Essential binaries for maintaining the system

/etc: Configuration files used in system administration. As close as you can find to a "Windows Registry" in Linux.

/proc: Dynamic information about the file system and other key components are kept here. These are not ordinary files.

Exploring the proc directory

/dev: Devices. Though different from the proc files, these are again not ordinary files.

/var: Files that change a lot at runtime, such as logs and mail boxes.

/usr: A major directory containing many subdirectories. Here you will find key programs used not just by administrators, but by users. Documentation for many Linux tools is also found here. Be sure to visit /usr/doc, /usr/man, /usr/lib, /usr/bin and /usr/include. Also, check out /usr/bin/X11. The man directory contains manual pages.

/usr/local: The same general structure as /usr, but contains files of a more temporary nature. Don't miss /usr/local/man.

Directories and Partitions: As you get more experienced with Linux, you may begin partitioning your harddrive in such a ways as to meld with the directory scheme outlined above. For instance, create a partition called /home, and Linux will use that partition for your user directories. You can reformat the drive that holds the core of the US without changing the structure of your home directories. /usr is another good candidate for this treatment.

Example Program

Overview

const
  BUFSIZE = 1024;
var
  Buf: PChar;
begin
  // Non Portable
  GetMem(Buf, BUFSIZE);
  ListBox1.Items.Add(getcwd(Buf, BUFSIZE));
  FreeMem(Buf, BUFSIZE);
  // Portable
  ListBox1.Items.Add(GetCurrentDir());
  // Explore path constants
  ListBox1.Items.Add('_PATH_DEFPATH = ' + _PATH_DEFPATH);
  ListBox1.Items.Add('_PATH_STDPATH = ' + _PATH_STDPATH);
  ListBox1.Items.Add('_PATH_BSHELL = ' + _PATH_BSHELL);
  ListBox1.Items.Add('_PATH_CONSOLE = ' + _PATH_CONSOLE);
  ListBox1.Items.Add('_PATH_CSHELL = ' + _PATH_CSHELL);
  ListBox1.Items.Add('_PATH_DEVDB = ' + _PATH_DEVDB);
  ListBox1.Items.Add('_PATH_DEVNULL = ' + _PATH_DEVNULL);
  ListBox1.Items.Add('_PATH_DRUM = ' + _PATH_DRUM);
  ListBox1.Items.Add('_PATH_KLOG = ' + _PATH_KLOG);
  ListBox1.Items.Add('_PATH_KMEM = ' + _PATH_KMEM);
  ListBox1.Items.Add('_PATH_LASTLOG = ' + _PATH_LASTLOG);
  ListBox1.Items.Add('_PATH_MAILDIR = ' + _PATH_MAILDIR);
  ListBox1.Items.Add('_PATH_MAN = ' + _PATH_MAN);
  ListBox1.Items.Add('_PATH_MEM = ' + _PATH_MEM);
  ListBox1.Items.Add('_PATH_MNTTAB = ' + _PATH_MNTTAB);
  ListBox1.Items.Add('_PATH_MOUNTED = ' + _PATH_MOUNTED);
  ListBox1.Items.Add('_PATH_NOLOGIN = ' + _PATH_NOLOGIN);
  ListBox1.Items.Add('_PATH_PRESERVE = ' + _PATH_PRESERVE);
  ListBox1.Items.Add('_PATH_RWHODIR = ' + _PATH_RWHODIR);
  ListBox1.Items.Add('_PATH_SENDMAIL = ' + _PATH_SENDMAIL);
  ListBox1.Items.Add('_PATH_SHADOW = ' + _PATH_SHADOW);
  ListBox1.Items.Add('_PATH_SHELLS = ' + _PATH_SHELLS);
  ListBox1.Items.Add('_PATH_TTY = ' + _PATH_TTY);
  ListBox1.Items.Add('_PATH_UNIX = ' + _PATH_UNIX);
  ListBox1.Items.Add('_PATH_UTMP = ' + _PATH_UTMP);
  ListBox1.Items.Add('_PATH_VI  = ' + _PATH_VI);
  ListBox1.Items.Add('_PATH_WTMP = ' + _PATH_WTMP);

{ Provide trailing slash, since mostly used for building pathnames. }
  ListBox1.Items.Add('_PATH_DEV = ' + _PATH_DEV);
  ListBox1.Items.Add('_PATH_TMP = ' + _PATH_TMP);
  ListBox1.Items.Add('_PATH_VARDB = ' + _PATH_VARDB);
  ListBox1.Items.Add('_PATH_VARRUN = ' + _PATH_VARRUN);
  ListBox1.Items.Add('_PATH_VARTMP = ' + _PATH_VARTMP);