-------------------------------- DAT2330 - Unix - 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 5 - The Shell. Omit material that uses the line printer commands, e.g. "lpr". - True or False: These two command lines are equivalent: $ ls -l -i -d $ ls -lid - True or False: Every Unix command that takes several option letters lets you group them into a single argument starting with one hyphen. - Which software handles the ^U (CONTROL-U) line kill function? - the shell - the application program (e.g. "cat" or "sort") - the operating system - True or False: To find commands to run, the shell looks in every system directory on the machine. - True or False: You cannot change the places where the SHELL looks to find commands; the locations are built into the Unix system. - Will the "echo" command still work if you set your PATH variable to be empty? $ PATH='' $ echo "Does this work?" Explain the results. Now try "ls" and "date". Now try "/bin/ls" and "/bin/date". - True of False: The shell issues error messages about unrecognized options to commands. - True of False: Standard input is always your keyboard. Standard output is always your terminal screen. - Find the Unix pathname of the terminal with which you are connected to Unix (text p.95). Echo something and redirect the output into this pathname. Where does the output appear? Copy a short file onto this pathname using the "cp" command. Where does the output appear? - Study the differences between text figures 5-3, 5-5, and 5-8. Is it possible to redirect both the standard input *AND* the standard output of a Unix command at the same time? Give an example, if this is possible. - Go to the web site for the author and this textbook and find the correction to be applied to Figure 5-9. (The web site is mentioned in the intoductory pages.) - Study the box on page 99 and understand what the shell is doing when you redirect output! - What does "noclobber" mean? - What prompt does the shell use to remind you that you are operating as the Super User on a Unix system? - On page 101 the text says that a pipe is identical to redirecting the output of one command into a file, then running a second command and feeding it the file as standard input. While this is a true statement for pipes used in DOS, it isn't quite true under Unix. Unix pipes start passing data before the first command has finished; unlike DOS, you don't have to generate the full output of the first command before any output starts appearing on the input of the second command. Unix starts passing output as soon as it is available: $ cat -n -u | tr a-z A-Z abcd 1 ABCD hello 2 HELLO ^D $ Note how each line passes all the way through the pipe as it is typed. (What do the two options to "cat" mean on ACADAIX?) - What does it mean to use a command as a "filter"? Can any Unix command be used as a filter? - What happens if you give the name of your terminal as the file name argument to the Unix "tee" command? Why does this happen? $ echo "Testing testing" | tee /dev/pts/34 - To put a sequence of shell commands into the background, enclose the sequence in parentheses before appending the ampersand: bash$ ( sleep 5 ; date ) & [1] 50070 bash$ ( sleep 5 ; echo "Hello there" | write abcd0005 ) & [2] 50085 - Understand the use of the wildcard (glob) characters: * ? [] - What is the difference in output of these two commands? $ echo */. $ echo ./* - True or False: If a Bourne-style shell pathname expansion fails to match any files, the expansion is passed unchanged as an argument to the underlying command: $ mkdir empty $ cd empty $ echo * - True or False: The shell does pathname expansion before calling the utility in a command line. The utility sees the result of the expansion, not the wildcard characters that generated it. - What is the difference in output of these two "tr" commands? $ rm -rf empty $ mkdir empty $ cd empty $ touch a b c A B C $ ls A B C a b c $ head /etc/passwd | tr [a-z] [A-Z] $ head /etc/passwd | tr "[a-z]" "[A-Z]" Why is the output different? What is happening? - Chapter non-Advanced Review Questions: On ACADAIX or Linux: 1 - 9 (all) - Chapter Advanced Review Questions: On ACADAIX or Linux: 10, 11, 12, 13, 14, 15, 16