GNOME 1.4 User's Guide
<<< Previous | Appendix A. If you are new to Linux/UNIX | Next >>>

# Directories and paths

## Directory structure

Now, let's discuss the concept of directories. A directory is a collection of files. It can be thought of as a "folder" that contains many different files. Directories are given names, with which they can be identified. Furthermore, directories are maintained in a tree-like structure; that is, directories may contain other directories. The top level directory is called the "root directory" and denoted by `/`; it contains all the files in your system.

### Pathnames

A pathname is a file's "full name"; it contains not only filename but also its location. It is made up of the filename, preceded by the name of the directory containing that file. This, in turn, is preceded by the name of directory containing that directory, and so on. A typical pathname may look like `/home/sasha/talk.txt` which refers to the file `talk.txt` in the directory `sasha` which in turn is a subdirectory in `/home`.

As you can see, the directory and filename are separated by a single slash (/). For this reason, filenames themselves cannot contain the / character. MS-DOS users will find this convention familiar, although in the MS-DOS world the backslash (\) is used instead. The directory that contains a given subdirectory is known as the parent directory. Here, the directory `home` is the parent of the directory `sasha`.

Each user has a home directory, which is the directory set aside for that user to store his or her files. Usually, user home directories are contained under `/home`, and are named for the user owning that directory, so that the home directory of user sasha would be `/home/sasha`.

## Relative directory names

At any moment, commands that you enter are assumed to be relative to your current working directory. You can think of your working directory as the directory in which you are currently "located". When you first log in, your working directory is set to your home directory — for user sasha, it would be `/home/sasha`. Whenever you refer to a file, you may refer to it in relationship to your current working directory, rather than specifying the full pathname of the file.

For example, if your current directory is `/home/sasha`, and you have a file there called `talk.txt`, you can refer to it just by its file name: a command like emacs talk.txt issued from the directory `/home/sasha` is equivalent to emacs /home/sasha/talk.txt (`emacs` is an extremely powerful editor for text files; new users may prefer something simpler, such as `gnotepad`, but for power user, `emacs` is indispensable).

Similarly, if, in `/home/sasha` you have a subdirectory called `papers` and, in that subdirectory, a file called `fieldtheory.txt`, you can refer to it as `papers/fieldtheory.txt`.

If you begin a filename (like `papers/fieldtheory.txt`) with a character other than /, you're referring to the file in terms relative to your current working directory. This is known as a relative pathname. On the other hand, if you begin a filename with a /, the system interprets this as a full pathname — that is, a pathname that includes the entire path to the file, starting from the root directory, /. Use of the full pathname is known as an absolute pathname.

## Pathname conventions

Here are some standard conventions you can use in paths:

`~/` — user's home directory

`./` — current working directory

`../` — parent of the current directory

For example, if sasha's current directory is `/home/sasha/papers`, he can refer to the file `/home/sasha/talk.txt` as `~/talk.txt` or as `../talk.txt`.

<<< Previous | Home | Next >>>
Files and filenames | Up | Permissions