Lab 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.
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
What we know
TO DO
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:
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.
- You will log in with your UW Net ID and password
The menu that comes up next (pictured below) is the entry point into your email or file server space on Dante.
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.
List the contents of your home directory
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:
Make folders
Move folders
Transfer folders or files to and from other areas within your account.
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.
Change directories to FIT100 and check the contents.
After making sure that the FIT100 folder is there, type:
cd FIT100
Use your ls command again to see the folders that are inside of your FIT100 folder/directory.
Change directories (again) to your Labs directory.
cd Labs
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:
Using the change directory command to move into the Assign_1 directory
Run the program Pico
The Unix shell has a text editor that you can use (it is just like using Notepad).
Call up the editor by typing pico in the command line
Enter in the following text and then exit and save the file as lab2.txt
Use <Ctrl>x to Exit
Save modified buffer? Yes
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.
Press Enter or Tab to save
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:
cd ~/FIT100/Projects/Project3
Further Exercises
Use the cd command to move from your current location in folder Assign_1 to the new location of the Project3 folder.
Look at the Unix command at the end of this assignment and do the following:
Copy the lab2.txt file to your Project3 folder
Move lab2.txt from Project3 folder to the Project1 folder
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.
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!!!
**********************************************
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:
cd ~/FIT100/Pro
cd ~/FIT100/Projects
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:
Type in the shortcut command to change directories to your root and
press <Enter>.
cd
**********************************************
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.