Winter 2002
 FIT 100: Fluency with Information Technology

Lab 2

Creating Directories and Navigating Directory Structures in a Command Line Environment
(or, Where am I, where are my files, and how do I put my files somewhere else? Part 2)

Introduction

This lab requires you to work within your Dante but in a command line environment using a different application - Tera Term.

The first lab covered SFTP (secure file transfer), creating and moving directories, and understanding where we were at all times when moving and saving files. The SFTP client you used, SSH Secure Shell, has a Graphical User Interface (GUI). In a GUI you manipulate images or icons and click on buttons to use the software. A command line interface requires you to know and use a fixed set of commands in order to manipulate files and folders and to move them from location to location. Your maneuverability in this environment depends mostly on the keyboard, not on the mouse.

Today's lab will explore the ways to manipulate and move files using UNIX commands. You will be doing similar tasks to Lab 1, but with a different interface and you will work completely within your remote account on Dante using Tera Term.

What is Tera Term Pro?

Tera Term Pro is a software terminal emulator that supports VT100 emulation, telnet, SSH, kerberos, and serial port connections. It comes with a scripting language and can be used across Ethernet networks or dial-up connections.” ~UW Computing and Communications

Objectives

  1. To explore the difference between a command line and a GUI interface.
  2. To become comfortable with using the command-line prompt to navigate directory structures and access directories stored in various locations on a remote computer.
  3. To understand the concept of directory location and its impact on retrieval.
  4. To understand that there are many ways to access remote directories.
  5. To understand that functionality [the ability of an mechanism to perform the operation for which it was created] is separate from the interface.

What we know

TO DO

  1. Log in to your dante account using TeraTerm and get to a command prompt.

One way to move files between directories inside your account on Dante is by using command language. This is one way to get to the Unix Shell command line interface:

  1. Find the icon for Tera Term (Dante) on the desktop in front
    of you. It is also located in the Start button menu in the lower left.

     

  2. You will log in with your UW Net ID and password



  3. The menu that comes up next (pictured below) is the entry point into your email or file server space on Dante.

  4. Press <S> for the shell. You are now located in the root (home) directory of your Dante account. The name of that directory is your UW Net ID

In Lab 1, you created a folder called Labs inside of a folder called FIT100. Even though this was done using a different client and interface, you can see those folders here because you are looking into the same file space.

  1. List the contents of your home directory

  1. type in the ls command and hit return to see if FIT100 is there, and view the contents of your remote account. 

**NOTE** The contents of your account will be different from what is shown below.

**Notice that this environment demands your understanding of the Unix commands. **

These commands can:

See the the end of the lab for a basic list of Unix commands. **

If you get lost and need to find out where you are in your remote directory, go to the help section at the end of this lab.

  1. Change directories to FIT100 and check the contents

  1. After making sure that the FIT100 folder is there, type:

cd   FIT100

  1. Use your ls command again to see the folders that are inside of your FIT100 folder/directory.

  1. Change directories (again) to your Labs directory.

cd   Labs

  1. Create a directory called Assign_1 in Labs with the following command:

mkdir Assign_1

You’ve created a directory named Assign_1 inside Labs which sits inside of FIT100 which sits at the root of your Dante account.

So the structure of your folders for FIT100 in your remote account should now be:

  1. Using the change directory command to move into the Assign_1 directory

  2. Run the program Pico

The Unix shell has a text editor that you can use (it is just like using Notepad).

  1. Call up the editor by typing pico in the command line

  1. Enter in the following text and then exit and save the file as lab2.txt

  1. Use <Ctrl>x to Exit

  2. Save modified buffer? Yes

  3. File Name to write: lab2.txt

    This environment doesn’t recognize spaces. It is best not to include spaces in your file or folder names.
     

  4. Press Enter or Tab to save

  1. List the contents of the folder Assign_1.

From the command prompt, enter the proper command to list the contents of Assign_1 folder.  There should now be a file called lab2.txt

To go back into the file to edit it at some later date, simply call the editor and give the file name after it:

pico lab2.txt

To save changes to a file without exiting, use ^O, which writes the changes to the file.

Moving from here to there in one step

A benefit of using the command line interface is that you can go from the root of your directory structure all the way to the deepest folder with one command if you choose. Up until now, you have moved up and down your account one level at a time using the cd command. Now we will move from inside the Assign_1 folder and go into one of our Project folders in one step.

If I want to move from the Assign_1 folder location to the Project3 folder that is sitting inside of FIT100/Projects. I would enter the following:

Further Exercises

  1. Use the cd command to move from your current location in folder Assign_1 to the new location of the Project3 folder.

  2. Look at the Unix command at the end of this assignment and do the following:

  1. In the next lab, be able to show the instructor the full path to your Assign_1 folder. Then use the ls command to show the lab2.txt inside.

Supplemental Questions

Answers to these questions may be requested by the TA to turn in the lab.

  1. which commands did you type to perform the two tasks in Item 11?
  2. which directory were you in when running each of the two commands?
  3. what commands would you type if you were in your home directory?
  4. how would you copy lab2.txt to the desktop of your computer?

Understanding the concepts covered in this assignment

Congratulations! You have made directories and moved files using the command line interface!!!!!!!

You can now create folders and move content between folders in your account on Dante using the command line. This is a very helpful resource when you need to be able to access and work on documents at a variety of locations but may not have a disk to transport the work.

You want to become comfortable in the environment introduced in this lab and the last one. It will save you headaches in the weeks to come!!!

**********************************************

HELPFUL HINTS

Remember to type a space after commands such as cd, cp and mv.

When typing a directory or file name in these commands, you can type in just the beginning of the name and press the ESC key. The computer will expand that to the complete name (if possible and unambiguous). For example, if I type:

and hit ESC, I will get:

When you get lost

As we go through all of this new material it is very easy to get confused and often times to get lost. When that happens in the command line environment the easiest thing to do is go back to your root directory. From there you can navigate back through your directories to find the place you need to be again.

If you get lost, or take a wrong turn as we go through this lab, simply get yourself back to the home directory, the root, of your account with the following step:

**********************************************

Common Unix Commands

[ See more commands at: http://www.washington.edu/computing/unix/unixqr.html ]

Exit the shell back to the main Tera Term menu:
exit
logout

Change current directory (folder):
cd
  directory
            The directory can be specified either with relative or absolute path.

cd   ~
              
go to your home directory

cd   ..
              
go to the enclosing directory (or, move back one level at a time)

Copy a file:
cp
file directory
        Copies a file to a different directory

cp file1 file2
        Copies file1 into file2

cp -i file1 file2
        Inquires before overwriting an existing file

Changing permission status for a file or directory:
chmod code file
chmod code directory

To keep a file private: chmod 600 <file>
To give everyone read permission: chmod 644 <file>

List contents of the current directory
ls

Get Manual pages:
man topic

Get the Unix manual pages for a particular topic
man ls retrieves manual page for the ls command

Create a new directory
mkdir directory
        directory path can be relative or absolute.

Move a file:
mv
file directory
        Moves a file to a different directory

mv file1 file2
        Renames file1 into file2

mv directory1 directory2
        Moves the entire directory1 to directory2 if such existed, otherwise renames directory1 into directory2

mv -i file1 file2
        Inquires before overwriting an existing file

Remove a directory:
rmdir
directory

If the directory contains any files, you will not be able to delete it. This is a nice safety feature, isn't it?

Remove a file:
rm file

rm -i file
        Inquires before removing

Show the current directory:
pwd

The path displayed by this command will most likely start with a couple of random words (e.g., /ua103/d347) followed by your UWNetID. That triple is your home directory, ignore it. It is the rest of the path that you care about.