Files, Directories, and the Root of All Things

There's a saying in the Linux world that "everything is a file" (a comment attributed to Ken Thompson, the developer of UNIX). That includes directories. Directories are just files with files inside them. All these files and directories are organized into a hierarchical file system, starting from the root directory and branching out.

Note

graphics/arrow_icon.gif

Folders and directories are the same thing. The terms can be used interchangeably, but I will be calling them directories. If you are more comfortable thinking of them as folders, don't worry. Depending on the application, you'll see both terms used.


The root directory (referred to as slash, or /) is actually aptly named. If you consider your file system as a tree's root system spreading out below the surface, you start to get an idea of just what things look like.

Under the root directory, you'll find folders called usr, bin, etc, tmp, and so on. Open up Konqueror by clicking on the icon in your taskbar that has a house in front of a folder. This brings up Konqueror in file manager mode (remember that Konqueror is also a Web browser). If your navigation panel isn't up (Konqueror's left side panel), press <F9> to open it (Figure 5-1). To either the right or left of the navigation panel (this is all configurable, remember), you'll see a row of tabs. Click on the root directory tab, the one that looks like a small folder. Here's a hint: If you move your mouse over the tabs and pause, a tooltip will pop up to let you know you are in the right place. When the file system tree appears (over on the left side), click on the top folder, Root Directory, then look at the names of those folders.

Figure 5-1. Konqueror's file manager view with navigation panel (left) open.

graphics/05fig01.jpg

These are all system directories, and they will contain all the programs that make your Linux system run, including documentation, devices, and device drivers. For the most part, you aren't going to be touching these files. Accidentally changing things around in this part of your system probably isn't a good thing, which is why everyone logs in with their own accounts.

One of the directories under the root is called home and inside that directory, you'll discover other directories, one for each login name on your system. These are the individual home directories and it is where you'll find your personal files and directories. If you want to store personal documents, music files, or pictures, this is the place. Once in Konqueror, you can jump to your home directory by clicking the house icon or clicking Go on the menu bar and selecting Home URL. This is your $HOME.

Quick Tip

graphics/arrow_icon.gif

My use of $HOME isn't just to be silly. The system can recognize some things based on environment variables, symbolic names that can refer to text, numbers, or even commands. In the DOS/Windows world, you had similars, for instance, the PATH in your AUTOEXEC.BAT file. $HOME is an environment variable assigned to every person who logs in. It represents a person's home directory. If you want to see all the environment variables assigned to your session, shell out and type the following command.

env


Try this. Over on the left side of the tree view, you'll see a little plus sign beside the home directory. Click on the plus sign, and the tree view will expand to show your own personal directory. Notice that the plus sign has become a minus sign. If you click it again, the directory view collapses. With the home directory expanded, click on your personal directory. You should see a few items appear in the right side view, including one icon labeled Desktop. For an example, see Figure 5-2. On the left side, /dev is expanded, and the right side view shows the same directory collapsed.

Figure 5-2. Expanding and collapsing directories.

graphics/05fig02.jpg

Before you do anything else, I want you to look down in your taskbar at the bottom of the screen. Do you see the desktop icon there, just to the right of the big K? It looks like a desktop blotter with a lamp above it . Move your mouse cursor over it, and the tooltip will display Show Desktop. Click it, and your desktop appears, free of windows. Click it again, and everything returns to normal.

Quick Tip

graphics/arrow_icon.gif

If the Show Desktop icon isn't there, you can easily add it. Right-click on the big K, select Panel Menu | Add | Special Button | Desktop Access. The button will appear in your taskbar.


The reason I am having you do this is that I want you to take note of what icons are on your desktop. Now go back to your Konqueror session and click on the Desktop icon in the right (or main) window. All the icons on your desktop show up there. Now why is that, you ask? Because even those icons on your desktop are files or directories. Cool? Let's move on.

Shell Out

graphics/arrow_icon.gif

Open a Konsole by clicking the terminal icon in your panel (the one with the shell). At the shell prompt, type ls Desktop. The ls command will list the contents of your Desktop directory. Compare what you see there with the icons currently on your graphical desktop. Do the names look familiar? When you are done, type exit to close the Konsole.


Directories (and subdirectories) will usually show up as folders, although this isn't a hard and fast rule because you can customize this. Nevertheless, some directories have different icons right from the start?the Desktop icon you just visited and the Trash can being two notables.