COP 3344-01 Introduction to Unix: Lecture 2
Learning objectives
After this class, you should be able to:
- Use the following Unix command:
cd,chmod,cp,ln,mkdir,mv,pwd,rm, andrmdir.- Create, rename, and remove files and directories.
- Copy files.
- Set access permissions on files.
- Use wildcards (for example, to refer to a set of filenames).
- Explain the difference between absolute and relative pathnames.
- Explain the meaning of the following symbols, when discussing pathnames or directories:
.,..,~, and~<username>.
Reading assignment
- JEA: Chapters 6-9, 10.11.
- Lecture slides: Lecture2.
Exercises and review questions
- Questions on current lecture's material
- Create a directory called
courses/cop3344under your home directory. Change directory so that~/courses/cop3344becomes your working directory. Which Unix command will you use to verify that you have, indeed, correctly changed your working directory?- Create a directory called
Lec3in your current working directory. Create a file calledfile2under theLec3directory. Rename the directory toLec2instead, and rename the file in there tofile1. Create another file called.file2in theLec2directory. How will you show a listing of the directoryLec2so that the file.file2is also displayed?- Create a directory called
junk1under theLec2directory, and create a few files under the latter directory. Usecpwith suitable arguments so that a copy of the directoryjunk1, calledjunk2, is created. Delete the directoryjunk2. Did you have to remove the files under this directory in order to accomplish your task? Did the corresponding files under thejunk1directory get deleted?- Change access permissions to the
junk1directory so that others have execute permission alone. Change access permissions to the files under thejunk1directory so that others have read permission. Again, change the access permissions to the directory and files so that others don't have any permission.- Which of the following actions can others perform on a directory if they have only read permission on it: (i) list the files in the directory using
ls, (ii)cdto that directory, (iii) read the contents of a file in that directory, (iv) remove a file from that directory, (v) create a file in that directory, (vi) execute a file in that directory? Which of the above can they do if they had only execute permission on that directory, and on the entire path to that directory. Which of the above can they do if they had only write and execute permissions?- Which of the following can others perform on a file if they have only read permission on it, and execute permission on the entire path to the directory in which it is present: (i) list the file using
ls, (ii) read the contents of that file, (iii) modify the contents of that file, (iv) remove that file, (v) execute that file? Which of the above can they do if they had only execute permission on that file? Which of the above can they do if they had only write permission on that file?- Learn about use of the
lncommand with the-soption from the web. In which web site did you find the most useful information? (Post this answer on the discussion board)- Create a link to a file in the
junk1directory. If you remove the new file usingrm, then does the file with the original name continue to exist?- Assume that the current working directory has the following files in it
file1.txt,file1a.txt,file11.txt,file12.txt,file12,file1.ba.txt. Which files will be listed by the following command:ls file?[a-c,2-4]*. What command will you issue if you wish to list precisely those files that start withfileand end with a digit followed immediately by.txt?- Questions on next lecture's material
- None.