15110 Fall 2011 [Cortina/von Ronne]

Support Information: Setting Up Directories

About Files and Directories

Most operating systems, including Linux, Mac OS X, and Windows, organize data into files and directories (a.k.a. folders). A file's contents is just a sequence of bits whose meaning depends on what format the file is in. Each directory contains a listing of the files that are inside the directory. Technically, the directory consists of a listing of the names of the files and how to get at the files contents, but you can just think of it as a container that holds named files and their contents.

Since the contents of each file is just a sequence of bits, the computer needs to apply rules to decode the contents of the file as, for example, a JPEG image, a Word document, a text file, etc. In many operating systems, file name extensions (the last part of the file's name, after the last period) are used to indicate the files format (that is, which set of rules should be applied to interpret the contents of the file). Windows and Windows programs tends to hide these extensions from the user, adding them and acting based on them automatically. In Linux, the filename extensions are treated mostly as a normal part of the name that the user can choose however they want. Most files, though, are given extensions that reflects their contents, and these extensions are used by programs and the user as advisory information on the likely contents of a given file.

A directory (= folders) can also contain other directories, which are often (but not always) referred to as subdirectories (nested folders). The directory in which a subdirectory is contained is referred to as that subdirectories "parent directory". The nesting of directories can is often thought of as forming a "tree" that branches out from a single "root" directory with smaller branches (subdirectories of the root directory) coming of it, even smaller branches (subdirectoreis of the subdirectories comming from the even smaller branches, and so on.

In Linux, the "/" (slash) character is used to separate a directory from its contents (In Windows, "\" (backslash) is used for this purpose.), and can be used to create "paths" that identify files stored on the computer. For example, the path /afs/andrew.cmu.edu/usr22/vonronne/public/15110/lb-check1.py denotes the file lb-check1.py inside the 15110 directory that is inside the public directory that is inside the "vonronne" directory that is inside the usr22 directory that is inside the andrew.cm.edu directory that is inside the afs directory inside the computer system's root directory.

(The systems at CMU are setup, using the Andrew File System (AFS), so that the afs directory inside root is shared, and will look the same, on any Linux machine running AFS. (The AFS subtree is also available on Windows machines, but it will have a drive letter instead of being found at /afs

In Linux, each user is normally given a "home directory" as a place for them to store files. The symbol "~" is used to refer to the current user's home directory. And for any user user, ~ refers to that user's home directory. So, for example, since the directory /afs/andrew.cmu.edu/usr22/vonronne/ is the user vonronne's home directory, it can be referred to as ~vonronne, and the file /afs/andrew.cmu.edu/usr22/vonronne/public/15110/lb-check1.py can be referred to as ~vonronne/public/15110/lb-check1.py. Furthermore, the user vonronne can also refer to the same file using the path ~/public/15110/lb-check1.py.

See also Computing Services' Using Unix & the Andrew System.

Navigating Directories and Managing Files from the Command-Line

Opening a Terminal

In addition to using the GNOME desktop environment, you can also interact with the systems in the Gates Hall Cluster using the "command line." If you're sitting at the machine, you get a "command line" using the "Terminal" program listed under the "Applications"/"System Tools" menu.

This will create a terminal window that contains a black space with a white prompt that says something like [vonronne@ghc15 ~]$ where the vonronne indicates the currently logged in user, the ghc15 the machine that user is sitting at, and the ~ indicates the "current directory", which many commands will operate on implicitly.

You can type commands after the prompt and upon hitting enter they will be executed. For example, if you enter the command ls, you will get a listing of the files in the current directory, which in this case would be vonronne's home directory.

Both the command line and the Gnome File Manger (what you get when you selection "Home" from the "Places" menu) can be used on the machines in the Gates Hall Cluster to create directories, move files between directories, etc.

A description of a few basic commands can be found as part of Using Unix & the Andrew System.

Example: Creating a 15110 directory in private

Here is an example command-line session of the user vonronne creating a directory for 15110 within the private directory in his home directory.

[vonronne@ghc15 ~]$ cd
[vonronne@ghc15 ~]$ ls
Desktop    OldFiles   bin           lb-check4.py  private     puzzle3.lb  www
Documents  Pictures   lb-check1.py  lb-check5.py  public      puzzle4.lb
Downloads  Templates  lb-check2.py  lb-check6.py  puzzle1.lb  puzzle5.lb
Music      Videos     lb-check3.py  lb-check7.py  puzzle2.lb  puzzle6.lb
[vonronne@ghc15 ~]$ cd private
[vonronne@ghc15 ~/private]$ ls
[vonronne@ghc15 ~/private]$ mkdir 15110
[vonronne@ghc15 ~/private]$ cd 15110
[vonronne@ghc15 15110]$ pwd
/afs/andrew.cmu.edu/usr22/vonronne/private/15110
[vonronne@ghc15 15110]$ cd
[vonronne@ghc15 ~]$ ls -l private
total 2
drwxr-xr-x 2 vonronne users 2048 Sep  7 13:04 15110

Example: Creating a Directory for Lab 2

[vonronne@ghc15 ~]$ ls private
15110
[vonronne@ghc15 ~]$ cd private/15110
[vonronne@ghc15 15110]$ mkdir lab2
[vonronne@ghc15 15110]$ cd lab2
[vonronne@ghc15 lab2]$ ls
[vonronne@ghc15 lab2]$ gedit lab2.txt