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, press the up arrow until you see the last echo command. Press the up arrow again.

    1. What do you see?

    2. Why wasn’t it the exit command?

    3. Press the up arrow 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`
  5. 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?

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

    $ sed 's/:[^:]*:/:---:/' /etc/passwd | less
  7. 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 ...

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.