Unix Files and Directories
This lesson focuses on the Unix file system, and how to manipulate
files and navigate directories. We will begin by looking at basic
Unix commands for manipulating files and directories. In Unix, a file
can be one of three types: a text file (such as a letter or a
program), an executable file (such as a compiled program), or a
directory (a file ``containing'' other files).
When you consider that there are thousands of users of the local
workstation network, you will realize that the computers must keep
track of tens or hundreds of thousands of files. Unix uses
directories to organize these files, much like a filing cabinet uses
drawers and folders to keep track of documents.
The Unix file system is organized around a single structure of
directories, where each directory can contain more directories (often
called subdirectories) and/or files. The entire file system, often
spanning many machines and disks, can be visualized as a tree.
Picture this tree as growing upside down, with the root at the top and
the leaves toward the bottom. The leaves are all text and executable
files, while the root, trunk, limbs, branches, and twigs are all
directories.
The file system is called the directory tree, and the directory at the
base of the tree is called the root directory. Every file and
directory in the file system has a unique name, called its pathname.
The pathname of the root directory is /.
As a Unix user, you are given control over one directory. This
directory is called your home directory, and it was created when your
account was established. This directory is your personal domain, over
which you have complete control. You are free to create your own
subtree of files and directories within your home directory. To
determine the pathname of your home directory, enter the following
command in an XTerm window. The first part of the command
makes sure that you are indeed connected to your home directory; the
second command displays its name.
cd; pwd
Everyone has a different home directory, but two things are certain.
The pathname of your home directory will start with a slash
(everything is rooted in the root directory) and it will end with your
user name. For example, suppose that a user jones has a home
directory /home/jones. From this, we can tell that the root
directory / contains a subdirectory called home,
which contains a subdirectory called jones.
Every directory has a pathname that shows the
sequence of directories that lead from it back to the root.
Below, you will learn how to explore the file system at large as well
as how to create directories and files inside your own small piece of
it. Be sure to try out the example commands as you learn about
them. Otherwise, you won't learn very much.