67.

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); }

Book: LPI Linux Certification in a Nutshell
Section: Chapter 8.  Exam 101 Review Questions and Exercises



8.1 GNU and Unix Commands (Topic 1.3)

8.1.1 Review questions

  1. Describe the difference between shell variables and environment variables.

  2. Compare and contrast built-in and explicitly defined commands and those found in PATH.

  3. After a lengthy session of file manipulation on the command line, what will the !ls command produce?

  4. What program was the source for the default history editing key bindings in bash?

  5. Explain the notion of pipes as they refer to shell capabilities, and illustrate using an example of two or more filter programs.

  6. Explain the -p option to cp and give an example of why it is necessary.

  7. Give two examples of files matched by the wildcard ??[!1-5].

  8. Name the three Standard I/O streams and their functions.

  9. Give an example of the redirection operator, >, and describe how the outcome would be different using the >> operator.

  10. What process is the ultimate ancestor of all system processes? Give both the PID and the program name.

  11. Name three common utilities used for process monitoring.

  12. What happens to a typical daemon when it receives SIGHUP? How would the behavior be different if it received SIGKILL?

  13. Compare and contrast background and foreground jobs, and state the syntax to put a command in the background on the command line.

  14. Explain the relationship between a process' nice number and its execution priority.

  15. What two classifications of characters make up regular expressions?

  16. How are the regular expressions [A-Z]* and ^[A-Z]*$ different?

8.1.2 Exercises

8.1.2.1 Exercise 1.3-1. Bash
  1. Start a bash shell in a console or terminal window and enter the following commands:

    $ MYVAR1="Happy" $ MYVAR2="Birthday" $ export MYVAR1 $ bash $ echo $MYVAR1 $MYVAR2 $ exit $ echo $MYVAR1 $MYVAR2
    1. Was the behavior of the two echo commands identical?

    2. If so, why? If not, why not?

    3. What happened immediately after the bash command?

    4. Which variable is an environment variable?

  2. Continuing the previous exercise, enter Ctrl-P until you see the last echo command. Enter Ctrl-P again.

    1. What do you see?

    2. Why wasn't it the exit command?

    3. Enter Ctrl-P again so that the export command is displayed. Add a space and MYVAR2 so that the line now looks like this:

      $ export MYVAR1 MYVAR2

    What happens when you enter this command?

  3. Still continuing the previous exercise, enter the command !echo. Does anything change as a result of the revised export command?

  4. The file command is used to examine a file's contents and displays the file type. Explain the result of using file as follows:

    $ cd / ; file $(ls | head -10)
8.1.2.2 Exercise 1.3-2. GNU commands in pipes
  1. Execute this command on your system:

    $ cut -d: -f1 /etc/passwd | fmt -w 20 | head -1
    1. What was displayed?

    2. How many lines of output did you see? Why?

    3. What was the width of the output? Why?

  2. Execute the following sed substitution command and explain why it might be used on /etc/passwd:

    $ sed 's/:[^:]*:/:---:/' /etc/passwd | less
8.1.2.3 Exercise 1.3-3. File management
  1. Execute this command:

    $ cd /sbin ; ls -li e2fsck fsck.ext2
    1. What is the significance of the first field of the output?

    2. Why is it identical for both listings?

    3. Why are the file sizes identical?

  2. Execute the following command sequence and explain the result at each step (this example assumes that cp is not aliased to cp -i, which is a common default alias):

    $ cd $ cp /etc/skel . $ cp -r /etc/skel . $ cp -rfv /etc/skel . $ cp -rfvp /etc/skel .
  3. Remove the directory created in the previous exercise, using rmdir and/or rm. Which command can complete the task in a single step?

  4. Explain when the wildcard {htm,html} might be useful.

  5. Give an example of how the wildcard *.[Tt][Xx][Tt] could be used with directory listings.

  6. What can be said about filenames matched by the *.? wildcard?

8.1.2.4 Exercise 1.3-4. Redirection
  1. Experiment with redirecting the output of ls as follows:

    $ cp /etc/skel . 2> info.txt
    1. How is the terminal output different than that observed in Exercise 1.3-3?

    2. What is written to info.txt ?

  2. Experiment with the various forms of redirection in Table 3-4, including the tee command.

8.1.2.5 Exercise 1.3-5. Processes
  1. Experiment with ps, pstree, and top to monitor active processes on your system. Include top's interactive commands.

  2. If you have Apache running, use ps (and perhaps grep) to identify the httpd process and its pid, which is owned by root. Send that process the HUP signal as follows:

    $ kill -SIGHUP pid

    Using tail, examine the Apache error log (the location of your log file may differ):

    $ tail /var/log/httpd/error_log

    What was the effect of HUP on Apache?

  3. While running X, start some interactive processes in the background and experiment with using jobs, bg, and fg. For example:

    $ netscape & $ xterm & $ emacs & $ jobs $ fg 1 $ fg 2 ...

    Were you able to bring each of the jobs to the foreground successfully?

8.1.2.6 Exercise 1.3-6. Process priority
  1. This exercise starts a process, using various methods to view and modify the process execution priority:

    1. Start an editing session in the background using nice:

      $ nice vi &
    2. Observe that the process was nice'd using ps:

      $ ps -u
    3. Check it again using top:

      $ top -i
    4. Within top, renice the vi process using the r command and observe the effect on priority.

    5. Exit top and use renice to set the nice value back to zero.

8.1.2.7 Exercise 1.3-7. Regular expressions
  1. Use a simple regular expression with grep to find sh and bash users in /etc/passwd:

    $ grep "/bin/..sh" /etc/passwd
  2. Determine the number of empty lines in /etc/inittab :

    $ grep "^ *$" /etc/inittab | wc -l

    Explain the regular expression and the use of wc.

 


LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2000
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net