Professional Documents
Culture Documents
7. Now use the find command to find all files with "file" as part of their name. Don't forget
to put the wildcard specification in quotes - it won't work otherwise:
8.
9. find . -name 'file*' -print
10. Try to find only directories with "file" as part of their name. Are there any?
11.
12. find . -name 'file*' -type d -print
4. Use the diff command to determine the differences between two files:
5.
6. diff names1 names2
7. Use the diff command to determine the differences between two directories.
8.
9. diff subdir1 dir4
10. Try using sdiff to display the differences between names1 and names2:
11.
12. sdiff names1 names2
13. Now try sdiff specifying that the screen width is 80 characters...not the default 130:
14.
15. sdiff -w 80 names1 names2
sort
4. Use the cat command to look at an unsorted list of names. Notice that there are multiple
columns of information and that the list is not alphabetically sorted.
5.
6. cat name.list
10. Do the same sort, but send the output to a file. Then use the cat utility to view the file:
11.
12. sort name.list > sorted.list ; cat sorted.list
13. Sort the list by first names. This requires skipping over the first field, which is the last
name:
14.
15. sort +1 name.list
16. Sort the list by department. This requires skipping over the first four fields and using the -
b option to ignore blank characters:
17.
18. sort -b +4 name.list
These exercises will familiarize you with the basic UNIX commands for working with file access
permissions. Click here for more information on access permissions.
1. Make sure that you are in your Filesystem exercise directory, and then do a long listing of
your files:
2.
3. cd ~/Filesystem
4. ls -al
5. Notice the access permissions assigned to each file. Can you tell:
o which files are directories?
o if a file is executable?
o who has write access to each file?
o who has read access to each file?
o who owns the file?
o which group the owner belongs to?
o which permissions the group has?
o which permissions others have?
6. Use the chmod command to change the permissions for some files. List the file before
and after each change and determine how the command changes the file permissions.
7.
8. ls -l names1
9. chmod o-r names1
10. ls -l names1
11.
12. ls -l names2
13. chmod g+w names2
14. ls -l names2
15.
16. ls -l file*
17. chmod go-r file*
18. ls -l file*
24. Look in your ~/.cshrc file and find where your umask setting is specified. What is it and
what does it do? How would you change it so that nobody except you could see your
files?
25.
26. cd
27. more .cshrc
Standard UNIX File System Exercises
These exercises will familiarize you with the overall organization of your UNIX filesystem.
1. Change directory to the root level and then list the contents.
2.
3. cd /
4. ls
9. Spend some time navigating about the upper levels of the filesystem.... see how lost you
can get!!
Don't forget that you can always use the pwd command to tell you where you are, and
the cd command to return to your home directory.
In this practice you will practice using wild cards and a few other metacharacters.
1. List the files in the directory "/bin" that end in "sh". What command did you use?
ls /bin/*sh
2. On one line, use the "cd" command to first go to your home directory then to the "UNXclass"
subdirectory. What is the command line?
cd ; cd UNXclass
3. What command lists the files in the current directory that begin with upper case letters?
ls -d [A-Z]*
4. If they do not already exist, create three new directories in the UNXclass directory; "Letters",
"Programs", and "Misc". What command(s) did you use?
mkdir Letters Programs Misc
5. Copy all files in the current directory whose names contain the character string "let" into the
subdirectory "Letters". What command did you use?
cp *let* Letters
6. Copy all files in the current directory whose names end in ".c" or ".h" into the subdirectory
"Programs". What command did you use?
cp *.[ch] Programs
7. Copy all files in the current directory whose names contain the character strings "notes" or
"misc" into the subdirectory "Misc". What commands did you use?
cp *notes* Misc
cp *misc* Misc
or
cp *notes* *misc* Misc
8. Copy all files which begin with "copy.me" into the "UStoreIt" subdirectory. Move all files
which begin with "move.me" into the "UStoreIt" subdirectory. What commands did you use?
cp copy.me* UStoreIt
mv move.me* UStoreIt
9. Delete all files which contain the sequence "del". What command did you use?
rm -i *del*
1.
This practice will familiarize you with how UNIX permissions work. This practice
will also generate error messages to familiarize you with what file permission error
messages look like.
1. View the file "README.1", using the command "cat". What message did you
get?
This is a simple bit of text
2. View the file "README.2", using the command "cat". What message did you
get?
README.2: Permission denied
cat cannot read it because you do not have read permission on that
file.
3. cd into the NoWrite directory. Create a new file, named try.me, using
the command
touch try.me
What happened and why?
You cannot create try.me because you do not have write permission in
the NoWrite directory.
5. Run the command runMe.1 by typing ./runMe.1 . What did it print out?
What are its permissions?
You ran runMe.1
permissions are rwxr-xr-x (755)
6. Run the command runMe.2 by typing ./runMe.2 . What did it print out?
What are its permissions?
The file does not run because you do not have execute permission on it.
Permissions are rw-r--r-- (644)