Cover page images (keyboard)

Lab 1 - Linux at UMBC

Sue Evans <bogar@cs.umbc.edu>



Hit the space bar for next slide

Overview

Before we start, please make sure that your computer is booted into Linux; you may need to reboot.

Hello, and welcome to CMSC 201 for Spring 2011. We will be covering the following topics in this week's lab:

  1. TA Introduction:
    • My name.
    • My email address.
    • My office location and office hours.
  2. The Linux/Unix Environment.
  3. Exercises:
    • Unix Commands. Setup CMSC 201 directories
    • Following 201 Email rules
    • Logging Out. How to logout/lock your workstation.

The following subjects will not be emphasized in the lab discussion, but you should be sure to read these sections on your own time.

  1. Getting Help: Where to go for assistance.
  2. Student Accounts: Importance of using your account.
  3. Logging in from home: Where to go for help.











General Information


  1. What good is a TA in this course ?

  2. Contact Information

  3. How are the weekly labs graded ?

    Mastery of the lab Score
    complete
    3
    incomplete
    2
    not even close
    1
    absent
    0


    We will use the best 10 out of 12 lab scores to calculate your lab grade.
    Each of the 10 labs is worth 1% of your 201 grade.
    Since you get to drop 2 lab grades, we will not be offering make-up labs.

  4. Most of the labs will have the required part, a bonus part and a challenge part. You can earn 1/2 point of extra credit for doing the bonus part. This doesn't sound like a lot, but due to the grading scale and weightings, doing the bonus parts of all the labs can significantly improve your course score. You must complete the bonus step within the lab class time in order to receive the extra credit.
  5. You MUST attend the lab you are registered for in order to receive credit for that lab.












Linux/Unix

There are several flavors of Unix : IRIX, Solaris, Linux, etc. For this class your programs must run on the gl.umbc.edu machines which run linux. If you are in the lab and are running linux, when you log into your account you will be running linux on your own local workstation. The version of linux running in the labs is exactly the same as the one running on the gl machines. If you are logging in from another computer that's running linux, like your laptop, when you ssh into gl.umbc.edu you will be logged onto one of three machines

linux1.gl.umbc.edu, linux2.gl.umbc.edu, or linux3.gl.umbc.edu
depending on the load of each machine.

Your directory, where all of your files are stored, can be accessed by all of the UMBC lab machines as well as by linux1, linux2 and linux3.

All of the work for this class should be done within your umbc account.

Unix Commands

Unix commands are different from MS-DOS commands. Here are some basic guides to some of the most useful commands.



Unix Books

Some people would rather have a book for reference. These are out there, but you can probably just search the web for information relating to UNIX and find just what you need.

Figure 1:Think Unix.
Image of Cover of Think Unix

Figure 2: Learning the UNIX Operating System.
Image of Cover of Learning the UNIX Operating System












Unix/Linux Commands

As described in the previous slide, you may run linux on your local workstation or log onto gl.umbc.edu. For today's lab we're going to login as you would from home.

You'll have to use the ssh command to log into gl.umbc.edu.

  1. Right-click on the desktop background to open a terminal.
  2. At the linux shell, type ssh gl.umbc.edu.
  3. Then type your password to login.

When you first login to your account you will be in your home directory. To see the names of the directories and files that are already in your home directory, type ls:

linux3[1]% ls
Desktop  Mail  mail
linux3[2]%

ls stands for ``list'', it lists the items in the current directory. You should see mail and possibly some other files and directories. Directories are like folders in Windows. You should create directories as needed to keep your files orderly. Make a directory called 201 by typing the command mkdir 201. Then, type ls and you'll see the name of the directory you've just created.

linux3[2]% mkdir 201
linux3[3]% ls
201  Desktop  Mail  mail
linux3[4]%

To change into the 201 directory, type cd 201. Now type ls.

linux3[4]% cd 201
linux3[5]% ls
linux3[6]%

Notice ls did not give any output. That means that there are no files in this directory. Now make a directory for your homeworks in this 201 directory, by typing
mkdir homeworks. Then type ls to see the results.

linux3[6]% mkdir homeworks
linux3[7]% ls
homeworks
linux3[8]%  

Since there will be 8 homeworks, we should make a directory for each of them in the homeworks directory. First we'll have to change into the homeworks directory.

linux3[8]% cd homeworks
linux3[9]% mkdir hw1
linux3[10]% mkdir hw2
linux3[11]% mkdir hw3
linux3[12]% mkdir hw4
linux3[13]% mkdir hw5
linux3[14]% mkdir hw6
linux3[15]% mkdir hw7
linux3[16]% mkdir hw8
linux3[17]%  ls
hw1  hw2  hw3  hw4  hw5  hw6  hw7  hw8
linux3[18]%  

Now we want to go back up to the 201 directory. Typing cd .. will move us up one level in the directory tree, which will take us up to the 201 directory. We'll want to make a projects directory too.

linux3[18]% cd ..
linux3[19]% mkdir projects
linux3[20]% ls
homeworks   projects
linux3[21]%

The cp command allows you to make a copy of a file or directory and give it a different name. You can even copy files from Mrs. Evans' directory into yours. Let's get a copy of her file called original.py .
Type cp /afs/umbc.edu/users/b/o/bogar/pub/original.py .
The first argument to the cp command is the path to and name of the source file to be copied. The second argument is the path to and the name of the destination file. In this case, we can use the short-cut . (dot), which means to copy the source file into the current directory and give it the same name as the source file.

linux3[21]% cp /afs/umbc.edu/users/b/o/bogar/pub/original.py .
linux3[22]% ls
homeworks   original.py   projects
linux3[23]% 

Thankfully, making copies within your own directories is less complicated. Let's make a copy of this file and call it copy.py Type cp original.py copy.py Then, type ls to see that you have two files now, one called original.py and one called copy.py

linux3[23]% cp original.py copy.py
linux3[24]% ls
copy.py	 homeworks   original.py   projects
linux3[25]%

The mv command allows you to move a file and/or change a file's name.
Type mv copy.py same.py. Then, type ls to see that the files are now called original.py and same.py.

linux3[25]% mv copy.py same.py
linux3[26]% ls
homeworks   original.py   projects   same.py
linux3[27]%

The rm command allows us to remove or delete a file. Type rm same.py You may be prompted to make sure that you really do want to delete this file. Answer with a lower case y. If you then type ls, you will notice that the file same.py no longer exists.

linux3[27]% rm same.py
rm: remove `same.py'? y
linux3[28]% ls
homeworks   original.py   projects
linux3[29]%

We have used the cd command before to move into subdirectories by typing cd and the directory name. We've used cd with the .. to move up to the parent directory (up one level). Using the cd command alone, without a directory name following it or the .., will take you to your home directory. Type cd and then ls and you should recognize the files that are in your home directory.

linux3[29]% cd
linux3[30]% ls
201  Desktop  Mail  mail
linux3[31]%

The pwd command tells you your current directory. It stands for ``print the working directory''. Type pwd and you will see the full path to your home directory. Mine is /afs/umbc.edu/users/b/o/bogar/home and yours will be similar.

linux3[31]% pwd
/afs/umbc.edu/users/j/m/jmccla3/home/
linux3[32]%

Now let's change directory into our homeworks directory by typing
cd 201/homeworks Typing pwd will reveal what the full path to this directory is
/afs/umbc.edu/users/ ... /home/201/homeworks

linux3[32]% cd 201/homeworks
linux3[33]% pwd
/afs/umbc.edu/users/j/m/jmccla3/home/201/homeworks
linux3[34]%

Once you understand how to move around, you can give more complicated commands like, for example,
cp fileheader.py ../proj2/












Email

Only email your instructors and TAs from your UMBC account or your message will get eaten by our spam filters. Make sure you put CS201 and your section number somewhere in the subject, too.












Locking Your Computer and Logging Out

Students should lock their computer if they are leaving briefly such as getting a printout or going to the restroom. If not,some malicious individual could wipe out the contents of your account very easily by issuing a single command at a UNIX shell, so be careful!!

Just as importantly, leaving your project up on the screen or leaving access to your account and thus your project, while leaving the room constitutes sharing/distribution of work, and is thus considered a violation of Academic Integrity. I need not tell you that cheating will not be tolerated. Luckily, if you are leaving briefly you do not need to logout. You can lock your workstation so that it can only be unlocked by you or a system administrator. To lock your workstation do the following:

Students should logout of their accounts before leaving the lab. As mentioned above, the consequences of not doing could be very bad. To log out follow this simple procedure:

  1. To end the terminal session (i.e. close the shell's window) type exit.
  2. Then click on the "System" menu at the top of the screen.
  3. Choose "Log out".
  4. Click on "Yes" when asked "Really log out ?".











Getting Help

Many students both new and returning have questions regarding lectures, projects, accounts, and problems logging in from home. These are a few of the most common places that you can go to for help. Check and see what services each offers before calling or visiting.

  1. The Computer Science Help Center.
    • URL: www.cs.umbc.edu/~cshc
    • Location: ITE 201E
    • Phone: 410-455-6336
    • Description: The CSHC is staffed by exceptional CMSC majors. Tutoring is on a first-come-first-serve basis, just walk in. Assistance is available for CMSC 104, CMSC 201, CMSC 202, CMSC 203, and CMSC 341. The CSHC also offers some on-line resources.


  2. The Learning Resources Center.
    • URL: http://www.umbc.edu/lrc/
    • Location: Academic IV, B Wing Room 345
    • Phone: 410-455-2444
    • Description: The LRC offers free tutoring by appointment for CMSC 100, CMSC 104, CMSC 201, CMSC 202 & CMSC 203 The LRC also tutors around 100 more non-CMSC courses. Tutoring for all courses takes place Monday through Thursdays from 9AM-4PM and Fridays from 9AM-2PM.


  3. Division of Information Technology.
    • URL: http://www.umbc.edu/oit/
    • Location: ENG 020
    • Phone: 410-455-2577
    • Description: DoIT offers walk in and electronic support for account and software issues. If you are having problems with your account, these are the people to see. DoIT offers support online. Information for using UNIX @ UMBC can be found online at http://www.umbc.edu/oit/Unix/.












Student Accounts

You should work on all of your homeworks and projects from within your UNIX account. All projects are going to be submitted electronically from this account.

If your assignment is not in your account you will not be able to submit it.













Logging In From Home

You do not have to be physically here at school to work on your projects. If you need help regarding the setup of your computer in order to connect to UMBC, you should see a consultant in ENG 020 (on-line info). Assuming that you have an internet connection (or are at a lab computer), you are ready to connect to gl.umbc.edu. Once you have connected to gl.umbc.edu, you can work on things almost as you would if you were sitting at UMBC in a lab. The notable exception is that Windows users will have to go to extreme measures to be able to bring up graphical windows.


Secure Shell

You must use a secure shell (ssh) client to connect to gl.umbc.edu. With a secure shell, your username and password are encrypted for protection.

To download a secure shell (SSH) client follow the appropriate link:

Assuming you are at school or have installed one of these software packages at home, you are ready to connect. All you need to do is to specify gl.umbc.edu which is server you want to connect to, your user-name, and your password. Please note: The first time you connect to a server, you will typically get a message asking to add the server to your list of knownhosts. You should let the software add linux.gl.umbc.edu to your list of known hosts.

NOTE:  If you need assistance connecting to the gl system from home, please seek a consultant in ENG 020.


Free OIT Software

DoIT used to put a lot of its free software on a CD, but now it's all available online here.