UNIX Assignment This assignment will help you familiarize yourself with unix. Since you are already reading this, you should have a bit of familiarity with listing your home directory and cat (or an editor). This assignment will help set the stage for the weeks ahead and will give you a chance to test unix commands. When you are finished the assignment, you should have the following directories under your home directory: C Fortran1 Fortran2 HTML UNIX You should also have the following file located in your UNIX directory: README UNIX_Assignment HAND IN: README, UNIX_Assignment These files will be collected for marking on 11:59pm February 27, 2012. Make sure your final copies are in your UNIX directory! ============================================================================= PART 1: CHANGING YOUR PASSWORD It is good practice to change your password regularly. The first thing we will do is change your password on eidolon. 1. Log in to eidolon using the NX interface. 2. Open a terminal by clicking on the terminal button in the lower left corner of your interface. 3. On the command line for the terminal, type passwd. You will be prompted for a new password, and asked to re-type it. If you make a mistake typing the password in again, do not worry, eidolon will recognize this and not update your password. If you use a word as part of your password, you may get a warning indicating that you have picked a dictionary word. Eidolon will not prevent you from using a password like this, but it is not recommended. Good passwords do not contain words, have letters and numbers, and are 8 or more characters in length. Bad passwords contain words, are words with some letters replaced by numbers (ie b@dp@55w0rd), contain only letters or only numbers, or are short. Such passwords are much easier to crack. Do not be lulled into the belief your account will not be hacked. Every single day, hackers attempt to penetrate systems and accounts on hundreds of machines at UBC. I have over 2000 logs from last year documenting attacks on the systems I administrate. It is important to note, we are able to determine if your password has been changed during the course of this section and you will lose marks if you do not change your password. ============================================================================= PART 2: MAKING DIRECTORIES In this part, we will be setting up the directories which will contain your future and current work. This will give you a chance to try out the mkdir and chmod commands. 1. Make sure you are in your home directory (the directory you log into, not to be confused with the /home directory). What command can you use to determine your current directory? If you are not in your home directory, go to your home directory. 2. Use mkdir to make the directories C, Fortran1, Fortran2, HTML, and UNIX. Make sure you make the names exactly as they appear here. If you type in a directory name incorrectly, use the rmdir command to remove the directory and try again. 3. Change the permissions on these new directories to be rwx for you and group, and no permissions for other. If you want to use the octal form, rwx is 7, and no permissions is 0. Make sure you change the permissions on all the new directories. Do not change the permissions of your home directory (this will disable web access). 4. Check that the new directories have rwxrwx--- permissions and are owned by you and in your group (your username). ============================================================================= PART 3: MOVE UNIX_Assignment 1. Use the mv command to move the file UNIX_Assignment from your home directory to your UNIX directory. ============================================================================= PART 4: README In this part, you will get some experience with vi and unix commands. Make sure you are in your newly created UNIX directory and using vi, create/open a file named README (all in capitals). You are going to experiment with some unix commands and save the results or answer questions about them in the README file. Feel free to indent/add lines so it is easy to read. 1. Put your name and student number on the first line of README. 2. Open another terminal to work in using the terminal button in the bottom left corner of your interface. 3. In the new terminal, list out the contents of your home directory, including permissions and ownership. Copy the results to README. You can use copy and paste from the terminal menu or you can use the mouse. 4. What is the name of the directory just above your home directory? Can you list the contents of that directory? If so, what are they? If not, why not? 5. Are there any hidden files in your home directory? How do you find these? What are they? 6. Check the manual pages for 'cat'. Who is the author? 7. Check the manual pages for 'rm'. What does the -r option stand for? Try rm --help. What do you get? (Just describe what you get don't copy it) 8. Use grep to answer the following. How many times does the word 'does' appear in the UNIX_Assignment file? Find and copy all the lines from the UNIX_Assignment file containing the word 'copy' to README. 9. Save and close the README file. 10. Create a copy of the README file called README.orig. 11. Create a softlink to the README file. You can call it whatever you like. Open the softlink in your favorite editor. Go to the bottom of the file and type in "THIS IS A SOFTLINK!!!". Save and close the file. cat README to see if you changed it. Remove the softlink. Check the contents of your directory. Did it remove README? If so, copy README.orig back into README. Open README and write your answer into it, then save and close it. Copy README into README.orig. 12. Create a hardlink to the README file. You can call it whatever you like. Open the hardlink in your favorite editor, go to the bottom and type in "THIS IS A HARDLINK!!!". Save and close the file. Remove the README file. What happened to the hardlink? Write your answer into README.orig. Remove the hardlink. Move README.orig to README. 13. Let's find out a bit about your unix environment. Use env to get a listing of your environment. Copy and past this into your README. What shell are you using? Here is a chance to use pipes. Try env | grep SHELL. What do you get? How would you change the command to find out what your PATH is? What is your PATH? 14. Your environment is defined when you first open a terminal (shell) by a special file. If your shell is bash, then there is a file in your home directory called .bashrc that does it. If your shell is tcsh, then there is either a file called .tcshrc or .cshrc that does it. Depending on what your shell is, cat the appropriate file and have a look. It probably seems a bit cryptic because most default files of this type actually source a global definition file. Copy the contents of this file to your README by redirecting the output of cat. Make sure you use the append (>>) redirect rather than the overwrite (>) otherwise you will lose the entire contents of your README file. (If you are particularly worried about this, you might want to make a copy of your README file first). You're all done this part. Try playing around with the different commands you've seen, but make sure to clean up your directory before you finish. ============================================================================= PART 5: MAKE SURE YOUR FINISHED FILES ARE IN YOUR UNIX DIRECTORY AND THAT ALL YOUR DIRECTORIES ARE CREATED! DEADLINE: 11:59pm February 27, 2012