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 2010. We will be covering the following topics in this week's lab:
The following subjects will not be emphasized in the lab discussion, but you should be sure to read these sections on your own time.
Mastery of the lab | Score |
---|---|
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 are different from MS-DOS commands. Here are some basic guides to some of the most useful commands.
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.
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.
ssh gl.umbc.edu
.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/
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.
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:
exit
.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.
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.
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.
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:
ssh
is installed by default and can be run from a
terminal window.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 ECS 020.
DoIT used to put a lot of its free software on a CD, but now it's all available online here.