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/assign1
into yourassign1
directory. - Go into your
assign1
directory if you aren't already. - Look at the contents of your
assign1
directory. -
Make sure that
lastnames.txt
is not readable by others. If necessary, changelastnames.txt
so that its group is cs397. - Execute
example.sh
by executing bash example.sh - View the files' permissions.
- Try running the script as ./example.sh
- Change the permissions of
example.sh
such that it is executable by you. - Now, execute
example.sh
by 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/shared
directory. 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
list
in their name. - Create a backup copy of
list1
, named with the extension.bkup
. (A shortcut would be useful here.) - Using the
find
command, delete all files that end with the extension.bkup
- Run
ps
- Run
ps -ef
Note the differences in the displayed output - Run
ps
and save its output into a file calledps.out
- Find out how much space all the files in
your
assign1
directory 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
HANDOUTS
that is the path to the course'shandouts
directory. Follow the directions from class. Note, since you already have the variable$CS397
, you may want to use that in assigning yourHANDOUTS
variable's value. - In a new terminal, go back into your
assign1
directory. (You need a new terminal to load the updated.bash_profile
Usingsource
can screw up thescript
command, so we'll just start a new terminal. - Run script env_demo.out
- Display the
$HANDOUTS
variable - 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
.bashrc
file. - Comment out (
#
) yourPS1
definition 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.