---------------------------------------------------- Chapter 5 Reading Guide - A Practical Guide to Linux ---------------------------------------------------- -IAN! idallen@ncf.ca Here is a Reading Guide and some review questions for Chapter 5 "The Shell". You will find questions similar to these on tests and exams. Chapter 5 - The Shell. * Omit all material that uses the line printer commands, e.g. "lpr". - True or False: These two command lines are equivalent (p.92): $ 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. (p.92) - When processing a shell command line, which software handles the ^U (CONTROL-U) line kill function (p.93)? - the shell or the operating system terminal driver - the application program (e.g. "cat" or "sort") on the command line - In terms of parsing the command line, what is a "word" or "token" (p.94)? - How does the shell differ in its treatment of command names that contain slashes vs. command names without slashes? Explain the differences (p.94): $ ls $ /bin/ls $ who $ /usr/bin/who - True or False: To find commands to run, the shell always looks in every system directory on the machine. (p.94) - True or False: You cannot change the places where the SHELL looks to find commands; the locations are built into the Unix system. (p.94) - Will the "echo" command still work if you set your PATH variable to be empty (p.94)? $ PATH='' $ echo "Does this work?" Explain the results. Now try "ls" and "date". Now try "/bin/ls" and "/bin/date". Your shell won't work very well now, with PATH set to be empty. How can you get a fresh shell with a correct default PATH? - True or False: The shell issues error messages about unrecognized options to commands, e.g. "who -z". (p.94) - True or False: To the shell, a command is simply an executable file of the same name as the command name. (p.94) - True or False: Standard input of every command on a command line is always your keyboard. Standard output is always your terminal screen. (p.94/95) - 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? $ cp /etc/group /dev/pts/4 - How do you signal EOF (end-of-file) from the keyboard? (p.96) - What does "redirection" mean to the shell? (p.96) - What program will join several files together into one big file? (p.97) - When you use "<" to redirect standard input, what program actually opens the file, e.g. "$ cat /dev/null - What prompt does the shell use to remind you that you are operating as the Super User on a Unix system? (You can safely become the super-user on your Floppix system - see the "superuser" Lab on www.floppix.com.) (p.101) - 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 is *not* 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 ACADUNIX?) - If pipes produce output right away, why doesn't the following command produce any output until after EOF? (Why doesn't ABCD appear right away, as it does in the above example using "cat"?) $ sort | tr a-z A-Z abcd hello ^D ABCD HELLO $ - Most Unix commands that read from standard input also read from file names given on the command line. (If you don't give any file name or names, the command reads from standard input.) Name one common Unix command that *only* reads from standard input. (p.101) - bottom p.101 - do not use "cat" to open a file for standard input to a program; use input redirection by the shell instead: $ cat abstract | tr a-z A-Z # DO NOT DO THIS - INEFFICIENT $ tr a-z A-Z