CMSC 121, Section 0201 - Fall 2005
Introduction to UNIX
Homework 1 - Due Monday, 9/26/2005
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.) Name several major differences between Linux and Windows (other than those listed in the class notes).
- 2.) Explain (in your own words) what is the difference between X window, a desktop manager, and a window manager.
- 3.) 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.)
- 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.
<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.) Log into irix.gl.umbc.edu. Assuming you want to find out if there are any UNIX commands that open a graphical calculator, use one of the commands that we talked about to search for a command regarding a calculator.
- 11.) Describe how to lock your screen from both KDE and Gnome. Why would you want to lock your screen?
- 12.) 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 taken 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".
- 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 (you already created it as part of organizing
your account) 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 command of your choice.
- There is 1 slight difference between these 2 files. Use the UNIX command that will show the differences between
these 2 files to show us 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 this "temp". 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 to verify that the directory has been removed.
- Now change directories into the remaining "cmsc121" directory.
- There should be 3 files in this directory. Verify that by doing a directory them. 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 long directory listing showed.
- 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.
- Let's go ahead and remove all 3 of the files that are
in this current working directory (which is "cmsc121").
- This directory should now be empty. Verify that using by listing the contents of the directory.
- 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 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 computer that you are.
- 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".
- Now that all of the assignment has been logged to the file called
"typescript", I want you to 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 Monday Sept 26, after we go over the command in class and make certain it is working for everyone.
Homework 3 - Due Wednesday, 10/05/2005
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.
Let me be clear that for any questions where I am asking you for a UNIX command, I am not asking you to run these commands under UNIX and log them with the script command. I merely want you to tell me what command you would use to perform each of the actions listed below.
Note that you can 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 repeat the 6th command in your tcsh shell's history.
- 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 find the location of all files with a name matching the pattern "proj*.c" and having a timestamp later than 10/1/2005 12:00 within the directory tree rooted at the current directory.
- Give the command to use the output of the who command as input to the wc command to see how many users are logged on to the host machine on which you are working. Use the flag with the wc command that only displays the number of lines.
- 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 use the -v option.
- 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:
Wed Sep 28 11:04:25 EDT 2005
Wed Sep 28 11:10:28 EDT 2005
Wed Sep 28 12:23:34 EDT 2005
Wed Sep 28 15:34:19 EDT 2005
Thu Sep 29 23:37:17 EDT 2005
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.