Assign 1: File System and Process Commands, Environment Variables
Goals for Assignment 1
After the assignment, you should
- Know how to use the
chmod,chgrp, and filesystem commands. - Have a better understanding of UNIX permissions
- Practice using process commands.
- 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:
- Copy the files from
/csdept/courses/cs397/handouts/assign1into yourassign1directory. - Go into your
assign1directory if you aren't already. - Look at the contents of your
assign1directory. -
Make sure that
lastnames.txtis not readable by others. If necessary, changelastnames.txtso that its group is cs397. - Execute
example.shby executing bash example.sh - View the files' permissions.
- Try running the script as ./example.sh
- Change the permissions of
example.shsuch that it is executable by you. - Now, execute
example.shby executing ./example.sh - In a text file named
explanation.txt, tell me what you think it means for a file to be "executable". - Make a directory named by your username in the
/csdept/courses/cs397/shareddirectory. The directory should be readable, writable, and executable by you, and readable and executable by members of the cs397 group. - Go into the directory that you created.
- Execute touch filename.
- View the permissions of the newly created file.
- List all the files in your home directory and its subdirectories
that have
listin their name. - Create a backup copy of
list1, named with the extension.bkup. (A shortcut would be useful here.) - Using the
findcommand, delete all files that end with the extension.bkup - Run
ps - Run
ps -efNote the differences in the displayed output - Run
psand save its output into a file calledps.out - Find out how much space all the files in
your
assign1directory take up. (I want as little output as needed to answer this.) - 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)
- Create a new environment variable
called
HANDOUTSthat is the path to the course'shandoutsdirectory. Follow the directions from class. Note, since you already have the variable$CS397, you may want to use that in assigning yourHANDOUTSvariable's value. - In a new terminal, go back into your
assign1directory. (You need a new terminal to load the updated.bash_profileUsingsourcecan screw up thescriptcommand, so we'll just start a new terminal. - Run script env_demo.out
- Display the
$HANDOUTSvariable - Display the basename of
$HANDOUTS - Display the directory name of
$HANDOUTS - Type exit to stop saving the output to the file.
Optional: Customizing Your Prompt
- Open up your
.bashrcfile. - Comment out (
#) yourPS1definition if it exists. - What does this prompt look like?
export PS1="\e[1;31m\h:\W \u\$ \e[00m" - 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)
- 50 pts: Execute commands, evidenced by script file; correct permissions on files
- 20 pts: Setting environment variable, practice script.