Sie sind auf Seite 1von 8

Guide to Linux+ (2

nd
Edition)
ISBN 0-619-21621-2
End of Chapter Soution!
Chapter " Soution!
Review Questions
1. A directory is a type of file. True or False?
Answer: True
2. Which command would a user type on the command line to find out what directory in the
directory tree he is currently in?
a. pd
b. cd
c. where
d. pwd
Answer: d
3. Which of the following is an absolute pathname? !hoose all that apply."
a. #ome$resume
b. !:%myfolder%resume
c. resume
d. $home$resume
e. !:home$resume
Answer: d
&. A special de'ice file is used to (((((((((((.
a. enable proprietary custom)built de'ices to wor* with +inu,
b. represent hardware de'ices such as hard dis* dri'es and ports
c. *eep a list of de'ice settings specific to each indi'idual user
d. do nothing in +inu,
Answer: b
-. .f a user/s current directory is $home$mary$pro0ect11 which command could she use to mo'e to the
etc directory directly under the root?
a. cd ..
b. cd /home/mary/etc
c. cd etc
d. cd /etc
e. cd \etc
Answer: d
2. After typing the ls a command1 you notice that there is a file whose filename begins with a
dot . ". What does this mean?
a. .t is a binary file.
b. .t is a system file.
c. .t is a file in the current directory.
d. .t is a hidden file.
Answer: d
3. After typing the ls F command1 you notice a filename that ends with an 4 asteris* character.
What does this mean?
a. .t is a hidden file.
b. .t is a lin*ed file.
c. .t is a special de'ice file.
1
d. .t is an e,ecutable file.
Answer: d
5. The 'i editor can function in which two of the following modes? !hoose both that apply."
a. te,t
b. command
c. input
d. interacti'e
e. insert
Answer: b1e
6. The less command offers less functionality than the more command. True or False?
Answer: False
17. Which command searches for and displays any te,t contents of a binary file?
a. text
b. strings
c. od
d. less
Answer: b
11. #ow can a user switch from insert mode to command mode when using the 'i editor?
a. 8ress the !trl9Alt9:el *eys simultaneously.
b. 8ress the :el *ey.
c. Type in a : character.
d. 8ress the ;sc *ey.
Answer: d
12. .f resume is the name of a file in the home directory off the root of the filesystem and your present
wor*ing directory is home1 what is the relati'e name for the file named resume?
a. $home$resume
b. $resume
c. resume
d. %home%resume
Answer: c
13. What will the following wildcard regular e,pression return: file<a)c=?
a. filea)c
b. filea1 filec
c. filea1 fileb1 filec
d. fileabc
Answer: c
1&. What will typing >? at the : prompt in command mode do when using the 'i editor?
a. >uit as no changes were made
b. >uit after sa'ing any changes
c. nothing as the ? is a metacharacter
d. >uit without sa'ing any changes
Answer: d
1-. A user types in the command head /poems/mary. What will be displayed to the
terminal screen?
a. the first line of the file mary
b. the header for the file mary
c. the first 27 lines of the file mary
d. the last 17 lines of the file mary
e. the first 17 lines of the file mary
Answer: e
12. The tac command (((((((((.
a. is not a 'alid +inu, command
b. displays the contents of hidden files
2
c. displays the contents of a file in re'erse order last word on the line first and first word on
the line last
d. displays the contents of a file in re'erse order last line first and first line last
Answer: d
13. #ow can you specify a te,t pattern that must be at the beginning of a line of te,t using a regular
e,pression?
a. 8recede the string with a $.
b. Follow the string with a %.
c. 8recede the string with a @.
d. 8recede the string with a A.
Answer: d
15. +inu, has only one root directory per directory tree. True or False?
Answer: True
16. Bsing wildcard metacharacters1 how can you indicate a character that is CDT an a or b or c or d?
a. <Aabcd=
b. not <a)d=
c. <?a)d=
d. ?a)d
Answer: c
27. A user typed in the command pwd and saw the output: $home$0im$sales$pending. #ow could that
user na'igate to the $home$0im directory?
a. cd ..
b. cd /jim
c. cd ../..
d. cd ./.
Answer: c
Hands-on Projects
Project 4-1
Etep 1: Cot a'ailable.
Etep 2: /root
Etep 3: Co1 the cd command ta*es you to your home directory.
Etep &: Co1 the . metacharacter refers to the current directory.
Etep -: Fes1 the .. metacharacter refers to the parent directory /".
Etep 2: Fes1 you used a relati'e pathname to enter your home directory /root".
Etep 3: The error message indicates that the etc directory was not found as it is not underneath your current
directory /root".
Etep 5: Fes1 we used an absolute pathname to change to /etc.
Etep 6: Fes1 we used an absolute pathname to change to /.
Etep 17: Fes1 we used the G metacharacter to specify our home directory /root"H the same can be achie'ed
by using the cd command.
Etep 11: Fes1 we used a relati'e pathname to change to /root/Desktop.
Etep 12: Cot a'ailable.
Etep 13: ../sysconfig na'igated one parent directory toward the root then down to the sysconfig directory.
Etep 1&: Fes1 you could ha'e typed cd /root/Desktop1 which is shorter than the relati'e pathname we used.
Project 4-2
Etep 1: Cot a'ailable.
Etep 2: cd /root/ because the /root directory is the only directory that starts with r underneath the /
directory.
Etep 3: Cot a'ailable.
Etep &: Co1 there must be more than one directory underneath the / directory that begins with the letter
b.Etep -: Two: /bin and /boot.
3
Etep 2: cd /bin/ because the /bin directory is the only directory underneath the / directory that begins with
the letters bi.
Etep 3: Two: /mnt and /misc.
Etep 5: Cot a'ailable.
Etep 6: Cot a'ailable.
Etep 17: Cot a'ailable.
Project 4-3
Etep 1: Cot a'ailable.
Etep 2: Cot a'ailable.
Etep 3: Cot all files are listed from /etc as the terminal screen is too smallH the most common file e,tension
is .conf configuration files".
Etep &: The files at the beginning of the directory listing is displayed.
Etep -: Cot a'ailable.
Etep 2: The files at the beginning of the directory listing is displayed.
Etep 3: Cot a'ailable.
Etep 5: Cot a'ailable.
Etep 6: /root.
Etep 17: .t displays the directory listing for the /etc directory without changing the current directory.
Etep 11: Co. The /etc/skel directory contains only hidden files. The . represents the current directory and
the .. represents the parent directory.
Etep 12: There are hidden files and one hidden directory.
Etep 13: Fes. The /bin directory contains e,ecutable and symbolically lin*ed files.
Etep 1&: .nformation a'ailable includes file type1 permissions1 hard lin* count1 owner1 group owner1 siIe1
modification date1 and filename. There are regular files1 symbolic lin*s1 e,ecutable files1 and directories in
the /boot directory. The ll command gi'es the same output as the ls l command.
Etep 1-: A directory file.
Etep 12: AE!.. ;nglish te,t.
Etep 13: Fes1 the file command displays the different types of regular files by content.
Etep 15: Cot a'ailable.
Project 4-4
Etep 1: Cot a'ailable.
Etep 2: Three lines.
Etep 3: Cot a'ailable.
Etep &: Cot a'ailable.
Etep -: The head command displays the first 17 lines by default.
Etep 2: Fi'e lines1 three linesH the head command ta*es the number of lines to display as an option.
Etep 3: The tail command displays the last 17 lines by default.
Etep 5: Fi'e lines1 lines &7)-3H the tail command ta*es the number of lines to display as an option.
Etep 6: A binary compiled e,ecutable. Te,t tools should only be run on te,t files.
Etep 17: Cot a'ailable.
Etep 11: Cot a'ailable.
Project 4-
Etep 1: Cot a'ailable.
Etep 2: Cot a'ailable.
Etep 3: .nserting te,t.
Etep &: The cursor mo'es one character bac*ward left"1 !ommand Jode1 ! deleted a character1 i inserts
before the character.
Etep -: Cot a'ailable.
Etep 2: The cursor mo'es up two lines because the second and third lines are treated as one lineH ne,t1 the
cursor mo'es up one line.
Etep 3: Cot a'ailable.
Etep 5: Cot a'ailable.
Etep 6: The filename and number of lines and characters.
&
Etep 17: Cot a'ailable.
Etep 11: Cot a'ailable.
Etep 12: AE!.. te,t.
Etep 13: The same information as in Etep 6.
Etep 1&: Cot a'ailable.
Etep 1-: The output of the date command appeared below the current line in the document.
Etep 12: Fes.
Etep 13: Cot a'ailable.
Etep 15: Cot a'ailable.
Etep 16: The document was sa'ed as sample2 in the current directory.
Etep 27: Co. Fou must sa'e or throw away your changes first.
Etep 21: Cot a'ailable.
Etep 22: Cot a'ailable.
Etep 23: Cot a'ailable.
Etep 2&: Cot a'ailable.
Etep 2-: Cot a'ailable.
Etep 22: Cot a'ailable.
Etep 23: The last function changing to to "#" was undone.
Etep 25: Cot a'ailable.
Etep 26: Cot a'ailable.
Etep 37: Cot a'ailable.
Etep 31: Cot a'ailable.
Etep 32: Cot a'ailable.
Etep 33: The pattern KfliesK was replaced with the pattern Kflies and bearsK on the current line.
Etep 3&: Cot a'ailable.
Etep 3-: Cot a'ailable.
Etep 32: Cot a'ailable.
Etep 33: Cot a'ailable.
Etep 35: Cot a'ailable.
Project 4-$
Etep 1: Cot a'ailable.
Etep 2: Three files: sample1% sample2% and sample3.
Etep 3: All files are listed 4 matches 7 or more characters".
Etep &: sample1% sample2% and sample3 are listed 4 matches 7 or more characters".
Etep -: sample1% sample2% and sample3 are listed ? matches 1 character".
Etep 2: Co files ?? matches two characters".
Etep 3: sample1 and sample3 are listed <13= matches 1 or 3".
Etep 5: sample2 is listed <?13= matches not 1 or 3".
Etep 6: sample1% sample2% and sample3 are listed <1)3= matches 112 or 3".
Etep 17: Co files are listed <?1)3= matches not 112 or 3".
Etep 11: Cot a'ailable.
Project 4-&
Etep 1: Cot a'ailable.
Etep 2: Any lines with the pattern K.nnK:
especially wished to see the model of the Highland Inn
Inn was originally located on Cache Lake.
Etep 3: Any lines which do not contain the pattern K.nnK:
!n "pr #$ %$&'(&(( )*+ #%%#
Hi ,o-. I hope this day finds yo! well.
/nfort!nately we were not a-le to make it to yo!r dining
room this year while 0acationing in "lgon1!in 2ark 3 I
and train station in the dining room.
-
I ha0e -een reading on the history of "lgon1!in 2ark -!t
no where co!ld I find a description of where the Highland
If it is no tro!-le. co!ld yo! kindly let me know s!ch that
I need not wait !ntil next year to 0isit yo!r lodge4
5egards.
6acken7ie )li7a-eth
2.. How were the flies and -ears this year4
Etep &: Cothing is displayed as the grep command is case sensiti'e.
Etep -: The output is the same as Etep 2.
Etep 2: Any lines that contain the K.K character:
Hi ,o-. I hope this day finds yo! well.
room this year while 0acationing in "lgon1!in 2ark 3 I
especially wished to see the model of the Highland Inn
I ha0e -een reading on the history of "lgon1!in 2ark -!t
no where co!ld I find a description of where the Highland
Inn was originally located on Cache Lake.
If it is no tro!-le. co!ld yo! kindly let me know s!ch that
I need not wait !ntil next year to 0isit yo!r lodge4
Etep 3: Any lines that contain the K.K character surrounded by spaces:
Hi ,o-. I hope this day finds yo! well.
no where co!ld I find a description of where the Highland
Etep 5: Any lines that contain the letter KtK followed by any other character following by the letter KeK:
especially wished to see the model of the Highland Inn
and train station in the dining room.
I ha0e -een reading on the history of "lgon1!in 2ark -!t
no where co!ld I find a description of where the Highland
2.. How were the flies and -ears this year4
Etep 6: Any lines that contain the letter KwK followed by any three characters followed by the letter KeK:
/nfort!nately we were not a-le to make it to yo!r dining
room this year while 0acationing in "lgon1!in 2ark 3 I
especially wished to see the model of the Highland Inn
no where co!ld I find a description of where the Highland
Etep 17: Any lines that start with the letter K.K:
I ha0e -een reading on the history of "lgon1!in 2ark -!t
Inn was originally located on Cache Lake.
If it is no tro!-le. co!ld yo! kindly let me know s!ch that
I need not wait !ntil next year to 0isit yo!r lodge4
Etep 11: Any lines that start with the letter K.K followed by a space character:
I ha0e -een reading on the history of "lgon1!in 2ark -!t
I need not wait !ntil next year to 0isit yo!r lodge4
Etep 12: Cothing is displayed as the grep command cannot understand e,tended regular e,pressions.
Etep 13: Any lines that ha'e the letters KweK or Kne,tK:
Hi ,o-. I hope this day finds yo! well.
/nfort!nately we were not a-le to make it to yo!r dining
I need not wait !ntil next year to 0isit yo!r lodge4
2.. How were the flies and -ears this year4
Etep 1&: Any lines that end with the letters K.nnK:
especially wished to see the model of the Highland Inn
Etep 1-: Any lines that end with the letter K?K ' is an e,tended regular e,pression and only has meaning in
the egrep command":
I need not wait !ntil next year to 0isit yo!r lodge4
2
2.. How were the flies and -ears this year4
Etep 12: Dnly blan* lines are displayedH because there are fi'e blan* lines in the file1 fi'e blan* lines are
displayed because A indicates the beginning of the line and @ indicates the end of the line.
Etep 13: Cot a'ailable.
Discovery Exercises
Disco(ery )!ercise 1
Answers will 'ary. Eome common commands include:
cd Gscientistname
ls
ls La
ls LaF
ls Ll
file 4
cd pro0ects then repeat the ls and file commands"
cd ..
cd lab then repeat the ls and file commands"
4may need to enter subdirectories as well.
4te,t files can be 'iewed with cat1 more1 less1 head1 tail
4binary files can be 'iewed with strings

Disco(ery )!ercise 2
a" cd $usr
b" cd ..
c" cd $usr$local$share$info
d" cd share$info
e" cd $etc
f" cd ..$..$etc

Disco(ery )!ercise 3
a" ls $etc$4.cfg
b" ls $home$user1$.4
c" ls Ld $'ar$4
d" ls $bin$a4
e" ls $bin$???
f" ls $bin$??<th=
Disco(ery )!ercise 4
Cot a'ailable.
Disco(ery )!ercise
All lines e,cept for blan* lines will be displayed because the regular e,pression matches any 2 KbK
characters or any characters that are not 2 KbK characters. This will match any two characters pro'ided they
e,ist?
Disco(ery )!ercise $
Cot a'ailable.
Disco(ery )!ercise &
Cot a'ailable.
3
Disco(ery )!ercise *
Cot a'ailable.
Disco(ery )!ercise +
Cot a'ailable.
5

Das könnte Ihnen auch gefallen