Describe the difference between shell variables and environment variables.
Compare and contrast built-in and explicitly defined commands and those found in PATH
.
After a lengthy session of file manipulation on the command line, what will !ls produce?
What program was the source for the default history editing key bindings in bash?
Explain the notion of pipes as they refer to shell capabilities, and illustrate using an example of two or more filter programs.
Explain the -p option to cp and give an example of why it is necessary.
Give two examples of files matched by the wildcard ??[!1-5]
.
Name the three standard I/O streams and their functions.
Give an example of the redirection operator, >
, and describe how the outcome would be different using the >>
operator.
What process is the ultimate ancestor of all system processes? Give both the PID and the program name.
Name three common utilities used for process monitoring.
What happens to a typical daemon when it receives SIGHUP
? How would the behavior be different if it received SIGKILL
?
Compare and contrast background and foreground jobs, and state the syntax to put a command in the background on the command line.
Explain the relationship between a process's nice number and its execution priority.
What two classifications of characters make up regular expressions?
How are the regular expressions [A-Z]*
and ^[A-Z]*$
different?
What is the difference between executing :q
versus :q!
in vi?
What does it mean to put vi into command mode?
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
Was the behavior of the two echo commands identical?
If so, why? If not, why not?
What happened immediately after the bash command?
Which variable is an environment variable?
Continuing the previous exercise, enter Ctrl-P until you see the last echo command. Enter Ctrl-P again.
Still continuing the previous exercise, enter the command !echo. Does anything change as a result of the revised export command?
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)
Execute this command on your system:
$ cut -d: -f1 /etc/passwd | fmt -w 20 | head -1
What was displayed?
How many lines of output did you see? Why?
What was the width of the output? Why?
Execute the following sed substitution command and explain why it might be used on /etc/passwd:
$ sed 's/:[^:]*:/:---:/' /etc/passwd | less
Execute this command:
$ cd /sbin ; ls -li e2fsck fsck.ext2
What is the significance of the first field of the output?
Why is it identical for both listings?
Why are the file sizes identical?
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 .
Remove the directory created in the previous exercise, using rmdir and/or rm. Which command can complete the task in a single step?
Explain when the wildcard {htm,html}
might be useful.
Give an example of how the wildcard *.[Tt][Xx][Tt]
could be used with directory listings.
What can be said about filenames matched by the *.?
wildcard?
Experiment with redirecting the output of ls as follows:
$ cp /etc/skel . 2> info.txt
How is the terminal output different than that observed in Exercise 8?
What is written to info.txt ?
Experiment with ps, pstree, and top to monitor active processes on your system. Include top's interactive commands.
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?
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?
This exercise starts a process, using various methods to view and modify the process execution priority:
Use a simple regular expression with grep to find sh and bash users in /etc/passwd.
Determine the number of empty lines in /etc/inittab.
Use vi to create a text file. Enter insert mode with i
and insert text. Quit insert mode with Esc and move around using h, j, k
, and l
, then re-enter insert mode and add more text. End the session with ZZ.
cat the file. Is it as expected?