CMSC 121, Section 0201 - Fall 2006
Introduction to UNIX
Homework 1 - Due Monday, 10/02/2006
Reminder: Don't forget to put the statement of sources used at the top of your homework!
Topics: UNIX, Linux, and the UMBC Computing Environment.
The goal of this assignment is to get you to become familiar with Linux, Gnome, KDE, and the UMBC UNIX Environment.
- 1.) Explain (in your own words) what is the difference between X window, a desktop manager, and a window manager.
- 2.) KDE and Gnome have a panel that holds shortcuts to programs. Give instructions for how to add a shortcut that launches a terminal. (Hint: Right click on the panel.)
- 3.) Describe how to lock your screen from both KDE and Gnome. Why would you want to lock your screen?
- 4.) This question has you create a very simple webpage (if you do not already have one). Do this by creating a file called "index.html" in your ~/../pub/www directory. You may have to create this directory if it doesn't exist. To verify that the file is a webpage, check out "http://userpages.umbc.edu/~username/". Submit the following: the URL (web address) where I can find your page, and the file permissions for the index.html file you created in this exercise. If you wish, you may make the webpage as fancy as you would like.
<h2>Welcome to NAME HERE's Homepage</h2>
- 5.) If you are over your GL account's disk space limit, can you continue to receive e-mail at your umbc.edu e-mail address? Describe the command you would use from the command line to determine whether you are over (or nearing) your limit.
- 6.) In order to run graphical applications on a UNIX server from a remote machine and see the GUI, what must be installed on the local machine? Can you use a Windows machine to run a remote graphical UNIX application in this manner?
- 7.) How can you recover a file that you deleted three days ago from your GL account? How about one that you deleted yesterday?
- 8.) Name three ways to change your working directory back to your home directory (assuming you're in an arbitrary directory two levels down from your home directory).
- 9.) What is wrong with telnet and ftp? What is the purpose of each of these programs? What are the programs available on the UMBC systems that replace telnet and ftp?
- 10.) Assume you are logged into a UNIX computer that is not on the UMBC GL systems and have a shell open. You want to copy a file in your home directory on that computer called "myfile.txt" to your gl account. What would be the command to securely copy this file to your gl account?
This assignment was adapted from Dan Hood's CMSC 121 website.
In order for the whole assignment to be logged to a file, you will need
to sit down and complete the whole thing from beginning to end
without logging out. If you make mistakes or typos as you go, do not
worry about it. Fix and re-issue the command.
I strongly recommend that you figure out what command and what arguments
you are going to be typing for each step before you actually issue the command.
This way you can test out the command before you actually sit down and log the entire assignment.
Connect via SSH to linux.gl.umbc.edu. You will be doing this assignment
via a SSH connection to one of the Linux servers. You may use the SSH
client of your choice.
Make sure that you are in you home directory before you proceed further into the assignment.
First type script at the command prompt.
This will allow for the entire interaction that you have with the
UNIX environment to be logged to a file called "typescript".
You should see the message "Script started, file is typescript".
Type exit at the command prompt.
This will close the session that logged all of your activity to a file.
You should see something like "Script done, file is typescript".
- Verify that you are in your home directory. Meaning issue the command
that prints out the current working directory.
- Make a directory called "courses". If for whatever reason this
directory already exists, then simply skip this step.
- Change the current working directory to this newly created directory called
- Again issue the command to verify that the current working directory is
now in this "courses" directory.
- From within this directory make 2 different directories called
"cmsc121" and "temp".
- Now do a normal listing of this directory. You should note the 2 new
directories now show up in this listing.
- Now let's create an empty file called "file0".
- Now do a long directory listing.
- Copy "file0" into the directory "cmsc121"
- Let's copy some more files. This time we will get them out of my public directory.
Copy the "file1" from /afs/umbc.edu/users/e/e/eeaton1/pub/cmsc121/hw2/ into the
directory called "cmsc121"
- Now copy all 3 of these files out of my public directory. Copy "file1",
"file2" and "file3" all into the directory called "temp".
- Now do a directory listing of each of the 2 directories "cmsc121" and "temp"
- Move "file0" (the one that is in this current directory) into the "temp" directory.
- Copy "file3" (which is in the "temp" directory) into the "cmsc121" directory
- Change directories into the "temp" directory
- Show the contents of both of "file2" and "file3" using the "cat" command.
- There is 1 slight difference between these 2 files. Use the UNIX command that will show the differences between
these 2 files to discover what it is.
- Change the directories to the parent of the current directory. You can do this using one of the special arguments
that I showed you for the change directory command or you can type in the full absolute pathname.
So once this command is done you should be in the "courses" directory.
- Now let's issue the command to remove a directory. Let's try to remove the "temp" directory. Issue the
command to remove a directory and note what happens. We get yelled at because the directory is not empty.
- So let's fix this. Remove all files that are in the "temp" using the commands of your choice. If you changed
directories to accomplish this, return back to the "courses" directory.
- Now you should be able to remove the "temp" directory. Try again to issue the command
that will remove this directory. Since the directory is empty it should work.
- Go ahead and do a directory listing of the "courses" directory to verify that the "temp" directory has been removed.
- Now change directories into the remaining "cmsc121" directory.
- There should be 3 files in this directory. Issuse the command to get the
total number of words, characters and bytes for the file called "file3". You should see that the total number of
bytes matches what the a long directory listing would show.
- Now using a wildcard, issue a command that will get the total number of words, characters and bytes for all files
in this directory. Notice now that this command has also returned us grand totals for all of the files combined.
- Change directories back to your home directory. You could do this using the ..characters, but instead
show me another way to change back to your home directory. Do not use an absolute path either
(/afs/umbc.edu/users/u/s/username/home/). Part of the goal of this course is to get you to work more efficiently. There are
many shortcuts to achieve the same effect.
- Issue the command to delete the "cmsc121" directory and all files within it recursively. You should only be using one command for this. If you wish, you can use the argument that will "force" the deletion. Be careful if you decide to use the "force" option!
- Issue the directory listing command in such a way that you see some of the hidden files and directories that
exist in your home directory.
- Now issue the command that will print out the current date and time
- Issue the command that will print a list out of all the users that are logged onto the same computer that you are.
Now that all of the assignment has been logged to the file called
"typescript", make sure that it logged
everything correctly. Use one of the commands that we discussed to
see the contents of the file.
Finally you will hand in the typescript file that you
created. You will not email me this project, instead we will use
UMBC's submit command. You will issue the following command to
submit the typescript file: "submit cs121_0201 hw2 typescript". You
can then issue the submitls command "submitls cs121_0201 hw2" to
see what you submitted. If you messed up and would like to re-submit you can
simply issue the submit command again, and the file that you previously
submitted will be overwritten.
Note that you will not be able to issue the "submit" command until after we go over the command in class and make certain it is working for everyone.
Homework 3 - Due Wednesday, 10/11/2006
You will hand these answers into me in typed hard copy. Do not forget to include a statement of the sources you used in this assignment, even if you did not use any sources.
For any questions asking you for a UNIX command, it is not necessary to run these commands under UNIX and log them with the script command, as in the previous homework. All you should submit is the command you would use to perform each of the actions listed below.
I highly recommend that you test out your commands on the command line before submitting them as answers in this homework. For each question asking for a UNIX command, give a one-line answer. That is, if your solution requires multiple commands, separate them by semicolons.
- Give the command to open a file named temp.txt in emacs, and set emacs to run in the background.
- Give the command to list all locations in your PATH variable where the more command may be found.
- Give the command to display the instance of the emacs command that is executed when you type in the emacs command.
- Give the command to find instances of the string "Answer" in the file ./homework.shtml along with the line numbers at which these instances occur. Also, ignore case, meaning that your command should find instances of "answer" as well as "Answer".
- Give the command to forceably terminate (kill) the process with process ID 2401.
- Give the command that would allow you to determine the process ID of an emacs job you have running in the background. This command should only print out lines of information about emacs processes.
- Give the command to create an alias in tcsh such that whenever you use the mv command, you will be prompted before overwriting an existing file.
- Give the command that will add the directory ~/projects/bin to your PATH variable.
- Give the command to create a tar file called proj2.tar of all files under the directory ~/CMSC201/proj2/.
- Give the command to create an alias in bash such that you can type quota to check on your account quota without having to explicitly use the -v option every time.
- This question requires a paragraph answer and is worth 25% of this homework grade. Describe in detail how you would implement the automatic keeping of a log file of login and logout times in the tcsh shell. Note that this may require writing UNIX commands and describing how to execute them. You must describe in detail how your proposed solution works. The filename of the log file should be timesheet.log. It should be of the following format:
Time in: Wed Sep 28 11:04:25 EDT 2005
Time out: Wed Sep 28 11:10:28 EDT 2005
Time in: Wed Sep 28 12:23:34 EDT 2005
Time out: Wed Sep 28 15:34:19 EDT 2005
Time in: Thu Sep 29 23:37:17 EDT 2005
Time out: Thu Sep 29 23:42:23 EDT 2005
- This question requires a paragraph answer and is worth 25% of this homework grade. Describe UNIX file permissions to a novice user.
* What are the purpose of file permissions?
* What are the meanings of the terms "owner", "group", and "public", and how can we change these for a file or directory?
* Explain how to read and interpret the file permissions listed by "ls -l".
* How can we change the permissions for a file?
* Explain how the permissions of the directories along a file's path affect access to that file.