NT1310 Unit 3 Homework

Topics: File system, Working directory, Domain Name System Pages: 8 (1253 words) Published: November 15, 2014

CHAPTER 7
Q1) What does the shell ordinarily do while a command is executing? What should you do if you do not want to wait for a command to finish before running another command? A1) The shell goes to “sleep” until the command has been processed. You can run a program in the background, which will allow you to run more than one at a time. Q3) What is a PID number? Why are these numbers useful when you run process in the background? Which utility displays the PID numbers of the commands you are running? A3) process identification (PID) number—a larger number assigned by the operating sys- tem. Each of these numbers identifies the command running in the background. It’s useful to know what jobs the program has completed and which ones are still running. The utility to use to run more than one command is “&”. Q4) Assume that the following files are in the working directory: intro notesb ref2 section1 section3 section4b notesa ref1 ref3 section2 section4a sentrev Give commands for each of the following, using wildcards to express filenames with as few characters as possible.

a. List all files that begin with section.
b. List the section1, section2, and section3 files only.
c. List the intro file only.
d. List the section1, section3, ref1, and ref3 files.
A4) a – $ echo section*
B - $ echo section(1,2,3)*
C – 4 echo *intro
Q8) Give an example of a command that uses grep
a. With both input and output redirected.
b. With only input redirected.
c. With only output redirected.
d. Within a pipe.
In which of the preceding cases is grep used as a filter?
A8) a - $ grep \$Idid_list
B - $ grep –I mike report_files
D - $ file /usr/bin/* | grep “shell script” | sort –r
“d” uses grep as a filter
CHAPTER 9
Q1 – Explain the following unexpected result
A - $ whereis date
Date: /bin/date…
B - $ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
C - $ cat > date
Echo the format I was to write date as
D - $./date
Q2 – What are two ways you can execute a shell script when you do not have execute permission for the file containing the script? Can you execute a shell script if you do not have read permission for the file containing the script? A2 – You can give the name of the file containing the script as an argument to the shell. The shell must read the commands from the file containing a shell script before it can execute the commands, you must have read permission for the fiel to execute a shell script. Q3 – What is the purpose of the PATH variable?

A – Set the PATH variable so it causes the shell to search the following directories in order: /usr/local/bin
/usr/bin
/bin
/usr/Kerberos/bin
The working directory
Export PATH=/usr/local/bin;/usr/bin/:/bin;/usr/…
B – If there is a file named doit in /usr/bin and another file with the same name is your ~ /bin directory, which one will be executed? (Assume you have execute permission for both files). Ans – It is determined by the order in the path statement. The command will execute the /usr/bin file C – If your PATH variable is not set to search the working directory, how can you execute a program located there? A – If you need to run a file that is not in your path, you would use the full command directory structure like: /usr/bin/doit or cd to the /usr/bin directory and type ./doit E – Which command can you use to add the directory /usr/games to the end of the list of directories in PATH? Export PATH=$PATH:/usr/games

Q4 – Assume you have made the following assignment:
A4 - $ person=mark
Give the output of each of the following commands:
A – echo $person
Mark
B – echo ‘$person’
$person
C – echo “$person”
Mark
Q5 – The following shell script adds entries to a file named journal – file in your home directory. This script helps you keep track of phone conversations and meetings. $ cat journal
# journal: add journal entries to the file
#...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • NT1310 unit 5 Essay
  • Unit 3 Homework Essay
  • homework Essay
  • MAT540 Week 3 Homework Essay
  • Unit 3 p6 Essay
  • unit 3 distinction 1 Essay
  • unit 331 outcome 3 Essay
  • Unit 3

Become a StudyMode Member

Sign Up - It's Free