Linux Assignment 3

1307 Words6 Pages
Date: 12 Oct 2013
Subject: Assignment 3

Chapter 7 page 251 Exercises 1,3,4,8
1. What does the shell ordinarily do while a command is executing? What should you do if you do not want for a command to finish before running another command?
While the command is executing, the shell waits for the process to finish. Or sleeps
3. What is a PID number? Why are these numbers useful when you run processes in the background? Which utility displays the PID numbers of the commands you are running?
PID process identification numbers. Each of these numbers identifies the command running in the background. You can use the PS (process status) utility to display the PID numbers of running commands.
4. Assume that the following files are in
…show more content…
When CDPATH is set and the working directory is not specified in CDPATH, cd searches the working directory only after it searches the directories specified by CDPATH.
b. $ pwd
$ CDPATH=$(pwd)
$ cd $HOME/biblios
After executing the preceding commands, Zach’s working directory is
/home/zach/biblios. When you give cd an absolute pathname as an argument, cd does not use CDPATH.
8. Enter the following command:
$ sleep 30 | cat /etc/services
Is there any output from sleep? Where does cat get its input from? What has to happen before the shell displays a prompt?

There is no output from sleep (try giving the command sleep 30 by itself).
The /etc/services file provides input for cat (when cat has an argument, it does not check standard input). The sleep command has to run to completion before the shell displays a prompt.

Chapter 9, p.357, Advanced Exercises 10,11

10. Write a shell script that outputs the name of the shell executing it.

There are many ways to solve this problem. The following solutions are all basically the same. These scripts take advantage of the PPID shell variable, which holds the PID number of the shell that is the parent of the process using the variable. They also use the fact that echo changes multiple sequential SPACEs to a single SPACE. The cut utility interprets multiple sequential SPACEs as multiple delimiters, so the script does not work properly without echo.
$ cat a

More about Linux Assignment 3

Get Access