Introduction to Unix

Part 1: Navigating directories

First we download the file called "Fisher.zip" from Carmen.

By default, the file gets downloaded in the "Downloads" directory. We will go there and "unzip" it.

This directory contains a sample from the Fisher corpus. The Fisher corpus is a collection of short phone conversations between people who typically do not know each other. Participants are assigned a random topic to talk about.

We will explore the data at the command line. To do so, we open a shell.

On a Mac: - Open the Terminal application - Go to "Shell" > "New Window" > "New Window with Settings - Basic"

On a Windows: - Open the PowerShell

This gives you a shell in which we can type. Here is the prompt I see (yours will be different):

dhcp48:~ mcdm$

Let's explore some Unix commands.

ls

What does this command do? Try it. You need to type it and hit "return".

It lists the contents of the directory we are in. By default, the Unix login session begins in your home directory.

man ("Get-Help" for PowerShell)

If you want more information about a command, you can look in the manual. For example, to get information about the "ls" command, just type

$ man ls

NAME
    ls -- list directory contents

SYNOPSIS
    ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]

DESCRIPTION
    For each operand that names a file of a type other than directory, ls displays its
    name as well as any requested, associated information.  For each operand that names a
    file of type directory, ls displays the names of files contained within that direc-
    tory, as well as any requested, associated information.

    If no operands are given, the contents of the current directory are displayed.

To quit the manual, type "q" (for quit).

cd

This command changes your current directory location. Using it, we can navigate the directory hierarchy. Our Fisher directory has been downloaded into the "Downloads" folder, so let's go there.

$ cd Downloads
$ ls

Remember, "ls" lists the directory content. You should see the Fisher directory there. What's in it?

$ cd Fisher
$ ls

What do we see?

We see that "Fisher" contains two directories, named "058" and "065".

Go to one of these directories.

$ cd 058
$ ls

We see a bunch of files in there. What's in the other directory? We can go there directly. We know that the directory hierarchy looks like this:

Downloads
        Fisher
                058
                        fe_03_05851.txt
                        fe_03_05852.txt
                        etc.
                065

Right now we are in the directory called "058". To go to the other directory ("065"), we need to go back up to "Fisher" and then go into "065". Conveniently "cd .." moves to the parent of the current directory. So we can do

$ cd ..
$ cd 065

Or in one command:

$ cd ../065

What follows the command is the path. "pwd" will give you the whole path of the directory you are currently in.

Just typing "cd" makes you go back to your home directory.

Go into the "065" directory again (if you are not there anymore). How do we go back to the Downloads folder from there?

$ cd ../../