Skip to main content.

Assign 1: File System and Process Commands, Environment Variables

Goals for Assignment 1

After the assignment, you should

  1. Know how to use the chmod, chgrp, and filesystem commands.
  2. Have a better understanding of UNIX permissions
  3. Practice using process commands.
  4. Practice making environment variables.

Objective: Unix Practice (50 pts)

Create an assign1 subdirectory within cs397/assignments.

Save the following commands and their output in a script file called practice.out. You'll also time the amount of time this takes. (I'm not evaluating you on your speed; just want to give you some practice with the time command.) Execute the following command:
time script practice.out

Do the following operations:

  1. Copy the files from /csdept/courses/cs397/handouts/assign1 into your assign1 directory.
  2. Go into your assign1 directory if you aren't already.
  3. Look at the contents of your assign1 directory.
  4. Make sure that lastnames.txt is not readable by others. If necessary, change lastnames.txt so that its group is cs397.
  5. Execute example.sh by executing bash example.sh
  6. View the files' permissions.
  7. Try running the script as ./example.sh
  8. Change the permissions of example.sh such that it is executable by you.
  9. Now, execute example.sh by executing ./example.sh
  10. In a text file named explanation.txt, tell me what you think it means for a file to be "executable".
  11. Make a directory named by your username in the /csdept/courses/cs397/shared directory. The directory should be readable, writable, and executable by you, and readable and executable by members of the cs397 group.
  12. Go into the directory that you created.
  13. Execute touch filename.
  14. View the permissions of the newly created file.
  15. List all the files in your home directory and its subdirectories that have list in their name.
  16. Create a backup copy of list1, named with the extension .bkup. (A shortcut would be useful here.)
  17. Using the find command, delete all files that end with the extension .bkup
  18. Run ps
  19. Run ps -ef Note the differences in the displayed output
  20. Run ps and save its output into a file called ps.out
  21. Find out how much space all the files in your assign1 directory take up. (I want as little output as needed to answer this.)
  22. Type exit to stop saving the output to the file.

View your practice.out file to make sure that you recorded all the above commands.

Objective: Environment Variables (20 pts)

  1. Create a new environment variable called HANDOUTS that is the path to the course's handouts directory. Follow the directions from class. Note, since you already have the variable $CS397, you may want to use that in assigning your HANDOUTS variable's value.
  2. In a new terminal, go back into your assign1 directory. (You need a new terminal to load the updated .bash_profile Using source can screw up the script command, so we'll just start a new terminal.
  3. Run script env_demo.out
  4. Display the $HANDOUTS variable
  5. Display the basename of $HANDOUTS
  6. Display the directory name of $HANDOUTS
  7. Type exit to stop saving the output to the file.

Optional: Customizing Your Prompt

  1. Open up your .bashrc file.
  2. Comment out (#) your PS1 definition if it exists.
  3. What does this prompt look like?
    export PS1="\e[1;31m\h:\W \u\$ \e[00m"
  4. Try out more by checking out the wiki page on customizing your prompt.

Finishing up: What to turn in for this assignment

Copy your directory assign1 and its contents into your turnin directory.

The electronic version should be in the turnin directory before the next class.

Grading (70 pts)