Unix Reference

The file system is a tree

Video

The unix file system is simply a tree, with the root of the tree labeled "/" (forward slash). Files and directories (also called "folders") make up the nodes of the tree, and directories can contain more files and directories.

For example, you may have a directory on your computer called "cs107", which has some files and directories in that directory. If you run the tree command, you will get a list of the files and directories in a tree format:

$ tree cs107 -F
cs107
├── 
│   ├── main*
│   ├── main.c
│   ├── main.cpp~
│   └── readme.txt
├── assign1/
│   ├── file1.txt
│   ├── file2.txt
│   ├── folder1/
│   │   └── myProgram.c
│   └── folder2/
└── assign2/
    ├── docs/
    └── readme.txt

6 directories, 8 files

(Note: in the above listing, names that end with / are directories, names that end with * are executable (runnable) files)

When you log into the myth computers, you are assigned a home directory, which looks something like this: /afs/.ir/users/c/g/cgregg

You have access to read, write, and delete files inside your home directory, but you can't read another person's directory unless you have permission.

For cs107, you will have read access to a number of class-related directories, but you won't be able to modify the files in those directories. Instead, often we will ask you to copy the files into a directory you will create inside your own home directory.

Your home directory is also known as ~ (tilde), and you can refer to your home directory simply by the tilde character. See the cd command for more information about using your home directory.

There are two special files for every directory, called . and ..

. refers to the current directory. This makes it easy to refer to your current directory instead of typing a long line such as /afs/.ir/users/c/g/cgregg/107/assign0. If you are already in that directory, you simply use . to refer to that directory. We often use the single dot to enable us to run a file that is in the current directory. So, if you were in the assign0 directory and had a program called hello that simply prints out hi there in that directory, you would use the following command to run it:

$ ./hello $

The double-dot (..) directory refers to the parent of the current directory.

Let's try navigating to a few directories. Log onto a myth and try the following commands. We will use the cd (change directory) commands to move between directories and the pwd (present working directory) command to print out the current directory.

$ pwd $

$ cd .. $

$ pwd $

$ cd ~ $

$ pwd $

$ cd . $

$ pwd $

Note that cd . will not change directories and will keep you where you are.

Back to contents