---------------------------------------------- DAT2330 - Unix - Winter 2000 - Prof. Ian Allen ---------------------------------------------- Here are questions you should be able to answer. You will likely find questions similar to these on tests and exams. Chapter 4 - The Unix/Linux File System. - The file system hierarchy diagrams in this chapter are misleading. See the Week 4 lecture notes for a correct sample diagram. (Names in directories are separated from the things they name.) - It's up to every individual program on Unix to decide if file name extensions have any meaning; there is no system-wide support for one standard. For example, the C compiler has a convention that recognizes *.o and *.a as being object files and libraries, but the "more" command is unaware of this convention and happily displays these files as if they were plain text files. There is no concept that a file with a particular extension is associated with a particular application. - If you telnet twice to a Unix machine, and you change the working directory of the shell in one telnet session, does the working directory for the shell in the other sesion change too? - If you change the working directory of your shell, then you start up a new copy of the shell by typing, say, "ksh" does the new copy of the shell have the changed working directory or the original working directory? - What is the difference between the command lines "ls" and "ls ."? - True or False: The "mkdir" command creates a new directory, and then makes the new directory your current working directory. - What option to the "ls" command will change its output to enable you to distinguish file names from directory names? Create an alias for ls that uses this option. - What is the difference between pathname "foo" and "./foo" and "./././foo"? - What is the difference between pathname "/bin/ksh" and "/bin/./ksh" and "/bin/./././././ksh"? - Explain this output (pay close attention to the patterns used): $ echo /* | wc 1 56 471 $ echo /*/* | wc 1 5356 81164 What do you expect would be the expansion of "/*/*/*"? (Don't type this - it's a very expensive computation!) Would the pathname /bin/ksh be included in the expansion of "/*/*/*"? (Don't type this - it's a very expensive computation!) - Explain this output (pay close attention to the patterns used): $ cd / $ echo ./* | wc 1 56 415 $ echo */. | wc 1 37 304 Why is the number of words different? What is the difference between the shell patterns "./*" and "*/."? - Use the ls command to explore the list of "standard" directories given on page 75-76 and find out which ones are not present on ACADAIX. - Students who don't take the time to understand how relative pathnames work (especially "..") often type absolute path names to every file they want to access. Why does this slow them down, relative to students who use relative pathnames? What kind of Unix user are you choosing to be? - What Unix command renames files? - The text says that directories cannot be copied with "cp". This is true of old versions of "cp". New versions, usually found only on Linux, can duplicate a directory and all of the files and directories inside it. - What is the difference in behaviour between a directory that only has X permissions and a directory that only has R permissions? - What permissions are needed on a file to enable you to remove the file name from a directory? - Try an exercise similar to the one the bottom of page 81: Create a sub-directory. Create a file in that sub-directory. Remove X permission from the directory. (Use the ls command to verify that you have done this successfully.) Try to use "ls -l" on the sub-directory. In the text, doing this shows the contents of the sub-directory and the details about the files contained therein. What does it do for you? - What information does the "-i" option to "ls" add to the output? - Execute these commands on ACADAIX and explain the output: $ ls -li /bin/*sh $ ls -li /bin/*sh | sort How does adding the sort make decoding what you see easier? - If you own a file or directory, but you give me permission to write to it, can I use the chmod command to change its permissions? - True or False: The first time you create a file, you create a real file. Subsequent hard links to the file, made using the "ln" command, are only pointers to the file and aren't as strong as the original file name. Removing the original file name will destroy the file. Removing one of the links only affects that one link. - True or False: The "ln" command takes two arguments, so the maximum number of hard links a file can have is two. - True or False: The first time you create a file, you create a real file. Subsequent *symbolic* links to the file, made using the "ln" command with the "-s" option, are only pointers to the file and aren't as strong as the original file name. Removing the original file name will destroy the file. Removing one of the symbolic links only affects that one link. - True or False: To make a hard link to "foo" named "bar, "foo" must exist. - True or False: You can make a hard link to a directory. - True or False: To make a symbolic link to "foo" named "bar, "foo" must exist. - True or False: You can make a symbolic link to a directory. - By using a positive number (e.g. +5) as an argument to the "tail" command, you can skip over the first N-1 lines of a file or of standard input. Try: who | tail +5 Now read Review Question #6 and write a Unix pipeline that answers part (a). The pipeline must count the number of file systems on the local machine. (You will need at least three commands in the pipeline.) - Chapter non-Advanced Review Questions: On ACADAIX or Linux: 1 - 11 (all) - Chapter Advanced Review Questions: On ACADAIX or Linux: 12, 13, 14, 16