Lab 2 - Directories, Files and SFTP CSE/INFO 100, Winter 2006 Lab

Lab 2: Directories, Files, and SFTP

Key Words: file, directory, folder, directory structure, local computer, remote computer,dante, SFTP, root directory, home directory, public_html, student_html, upload, download.

Objectives

In this lab, you will learn how to store on and retrieve files from a remote computer named dante. By doing so, you will also learn how to upload files to your personal webpage, which will be visible to anyone who accesses your website.

For this course, you are required to publish all of your completed assignments (homeworks, labs, and projects) on the web, with certain exceptions. This means that you will be required to place all of your files on dante and have your web publishing area activated. If your web publishing area is not activated or if you do not know if it is activated, complete Lab 1 before continuing with this lab.

In general, you should not use floppy disks for your assignments. They are unreliable and have a tendency to become unreadable when you need them the most! Instead, use a reliable remote computer (such as dante) to store your important data. You have been given 100 MB of disk space on dante, which should be more than sufficient for this course.

Navigate through a Directory Structure on the Local Computer

You can think of a file as a single document stored in a computer. For instance, song.mp3 might be the filename of a music file, term-paper.doc might be the filename of a Microsoft Word file. To organize files, you can store a set of them inside a directory (also called a folder). This is analogous to storing different paper documents inside a real folder, like you might do with your class handouts. To be able to find directories and files on your local computer, you must understand how to navigate through the computer's directory structure. This section explains how to navigate through a Windows environment on the local computer.

The local computer is the computer your keyboard is physically attached to.

  1. Open Windows Explorer (not Internet Explorer). You will use Windows Explorer on the local computer to navigate through its directory structure.

    You can open Windows Explorer using one of the following methods:

  2. Go to a directory such as C:\Documents and Settings\YourUWNetID\My Documents, substituting your UWNetID where applicable. If you are not on a UW lab computer, you may open some similar folder instead.

    Side note: When you see a directory path such as "C:\Documents and Settings", this refers to the directory named Documents and Settings on a hard disk drive named C.

  3. Create a new directory. From the menu bar at the top of the window, select File>New>Folder. Call your new directory EraseMe.

    Creating a new
directory

  4. Double click your newly created directory EraseMe to open it. The directory should be empty inside.
  5. Open Notepad. Notepad can be found from the Start menu under Programs>Accessories>Notepad.
  6. Write the following lines in Notepad:
    This is a test file for Fit 100 Lab 2.
  7. Select File->Save As.... Navigate to your EraseMe directory. Open it. You will save this file inside this directory. In the text box labeled File name, type testFile.txt.
  8. The following is a visual representation of C:\Documents and Settings\sbfan\EraseMe\testFile.txt on a local computer. Check to make sure what you've done matches what's shown here (substituting your own UWNetID instead of sbfan, of course, etc.)
    Windows Explorer showing the directory structure
    Windows Explorer showing the
directory structure
    The beginning, or top, of a directory structure is called the root directory. In this case, the root is C:. (The Desktop is actually a directory on the hard disk drive named C. You know it is a drive because it has a colon (:) after it. My Computer is not a directory and, therefore, can not be the root of a directory structure. It is Microsoft Windows method for grouping together the different parts of the local computer.) Other root directories on the local computer are A: (for the floppy disk drive) and D:, if it exists.
  9. You have now successfully created a file and saved it within a directory.

Navigate through a Directory Structure on a Remote Computer

In this section we will learn about remote computers. The computer you are physically sitting in front of right now is your local computer. It's the one you've just been navigating around. It's probably sitting on your desk, or under your table. However, there are lots and lots of other computers out there, which you can access through the Internet. These are remote computers. One of these computers is named dante.

dante belongs to the University of Washington, and it's a computer that the University allows all its students to access through the internet. You can navigate through dante and store your files there just like you did on your local computer. Each student has his own individual space on dante to put his or her files, so that they won't overlap with other people's files.

Why use dante? Because it's a convenient place for you to store your files and be able to access them from anywhere on the planet where you have internet access. You can work on your assignments in the lab at school, store them on dante, then go home and retrieve them from dante, and work on them some more and store them back on dante, then go to your friend's house and retrieve them from dante and work on them there...you get the picture. This eliminates the need to carry around a floppy disk, USB keychain drive, or having to email your files to yourself to keep a record of them.

You can access dante using a method called the Secure File Transfer Protocol, or SFTP for short. SFTP allows you to connect to any SFTP-enabled remote computer (such an dante) and lets you securely transfer files between these remote computers and your local computer. To use SFTP, you need an SFTP program. There are many SFTP programs out there, we will be using one called, simply, "SSH Secure File Transfer". (A newer version of the same program is called SSH Tectia Client, which you will find on the UWICK Kit.)

Note: To set up SFTP from home, follow the directions in Veneta's ePost message on "Setting up SFTP" at the Class Bulletin Board.
  1. Start SSH Secure File Transfer SFTP icon, which uses SFTP.
  2. Click on the Quick Connect button.

  3. A window named Connect to Remote Host will pop up. For the host name, enter dante.u.washington.edu. This is the address where dante is located. For the user name, enter your UW NetID. If your UW NetID was smith, you would enter the following:

    SFTP
connect dialog

    Enter your password in the next pop-up window to finish connecting to dante.

  4. You should now see a divided window showing some files and/or directories. The local computer's files and directories are shown on the left while the remote computer's files and directories are shown on the right. At the top and the bottom of the window you can see which computer you have connected to, in this case, dante. In the smaller window on the right, you can see the entire directory path of your current location on the remote computer, e.g., /nfs/guido08/smith. (When you first connect, you will always start in your home directory, which should have the same name as your UW NetID.) There is a similar small window on the left, which corresponds to the directory path of your current location on the local computer. It should currently be empty.

    SFTP dialog

    The gray bar located at the bottom of the window is the status bar. It tells you if you are connected to a remote computer, which computer you are connected to, etc.

    You can learn what an icon represents by positioning the mouse over the icon.

  5. The files and directories inside your home directory are only visible to you. This is a safe place to keep your assignments and files, not just for this class, but for any other classes as well. However, there's an exception to this. Inside your home directory there is a special directory that is web-accessible.

    We are now going to work with the web-accesible directory within your home directory.

    IMPORTANT: If you have both a student_html and a public_html, then use student_html in this class. If you only have public_html, then use public_html.

    Your public_html or student_html directory is a web accessible directory. This means that anyone can view the contents of this directory through the web using a web browser. So this directory is where we are going to put all the files you wish to be displayed on the web; this is basically your own personal website (remember the website we activated in Lab 1? The file you saw then is located here.)

    For anyone to look at your website, they simply need to open a web browser and go to http://students.washington.edu/yourUWNetID (replacing yourUWNetID with your own UWNetID, of course). This URL maps to the public_html (or student_html) that you see inside your home directory using SFTP. That means that whatever you see inside your public_html or student_html directory will show up at http://students.washington.edu/yourUWNetID

    Your assignments will go here so that they will be visible on the web for your TAs to grade.

    Open your public_html directory or your student_html directory on the remote computer by double clicking on it. If this directory is empty, the right window should become empty.

    If you go down into the wrong directory, you can go up and out of it by clicking on the Up icon .

  6. Create a new directory named fit100 inside of your public_html (alternatively student_html) directory. You can use one of following methods:

    Your fit100 directory is the directory where you should put all of your assignments for this course.

  7. Create a directory inside of your fit100 directory named lab2 (since the lab is called Lab 2). Thus, your home directory should have the public_html (or student_html) folder, and inside it, there should be the fit100 folder, and inside that, there should be the lab2 folder.

    Your directory structure should be as described above

  8. You can see your files online in a web browser as well. Open up Firefox or Internet Explorer, and type in your UW homepage URL, followed by fit100 (http://students.washington.edu/yourUWNetID/fit100). You should see a list of everything you have inside your fit100, which right now will be only your lab2 folder. You can click on it to see what is inside the folder (which now should also be nothing). To go back up the directory structure, just click Parent Directory.

    Compare the image below to the image in the previous step. Notice that they are showing the exact same thing. http://students.washington.edu/sbfan/fit100/lab2 is actually located in sbfan's home directory, sbfan/student_html/fit100/lab2, but you don't see the student_html part in the URL. It's just included by default when you go to http://students.washington.edu/yourUWNetId/.

Move Files from the Local Computer to a Remote Computer and Vice Versa

To make your assignments web accessible, which is required for all completed assignments in this course, you must place them in your web accessible directory on dante.

This section covers how to upload and download files and directories to and from a remote computer.

Upload means to transfer files/directories from your local computer to a remote computer (local –> remote). Download means to transfer files/directories from a remote computer to your local computer (remote –> local).

  1. Go into your lab2 directory on dante, which should be in your fit100 directory.
  2. Using the left half of SSH Secure File Transfer, navigate to where you placed testFile.txt on your local computer by double clicking on the appropriate directories. (Start by double clicking on My Computer.) Your file should be located in the EraseMe directory.
  3. Upload your testFile.txt file to your lab2 directory on dante. This can be done by using one of the following methods: You can upload entire directories using the same method.
  4. By uploading your file, you have sent a copy of your file from the local computer to a remote computer. If you look in the Transfer tab in the SSH Secure File Transfer window, you will see the status of your file transfer.
  5. Download testFile.txt from the remote computer back to your local computer. This time, place it in a different directory on your local computer, for example, directly in the root directory of C:\
  6. Using SSH Secure File Transfer, practice creating, renaming, and deleting directories on both the local and remote computers, as well as uploading and downloading files and directories. Also practice looking at them on the web. These are skills you will need throughout the rest of this class, so make sure you've got it down.
  7. Make sure that http://students.washington.edu/myUwNetId/fit100/lab2/testFile.txt is visible and accessible. You will need this file to do Homework 2 later. Make sure the spelling and punctuation matches EXACTLY (except for the myUWNetId obviously). This is how your TA will check to see that you've done the lab.

When you are done, close all SSH windows to log out from the remote computer. Finally, log off the local computer before leaving.

IMPORTANT!!!! When logging off the local computer in the lab, any work you've saved on that computer will be GONE. So, make sure to save everything to dante, and triple-check to be sure that the most current version of your work is there, before you leave. Many a student have lost their work because they forgot to re-upload their work to dante after they made changes to the file on the local computer. Don't let that happen to you.

Check List

You will not need to turn in this lab for a grade. However, you will need to use your testFile.txt in homework 2, and you must be able to perform the skills you learned in this lab in future assignments.