Flash Cards - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Flash Cards

Description:

grep. cut. read. wc. pwd. Display working directory ... grep S01 products. File Name: products. S0107:Lobby Furniture:1201. S0109:Ballroom Specials:1221 ... – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 42
Provided by: homeCo8
Category:
Tags: cards | flash | grep | mslinux

less

Transcript and Presenter's Notes

Title: Flash Cards


1
Flash Cards
  • CS205 Linux

2
Q1 What Happens?
  • counter0
  • while "counter" lt 5 do
  • let countercounter1
  • cat gsfile1
  • done
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

3
Q1 And the answer is
  • Error
  • line 2 10 No such file or directory
  • Why?
  • lt is a redirection symbol, not a numeric
    comparison symbol

4
Q2 What Happens?
  • counter0
  • while "counter" -lt 5 do
  • let countercounter1
  • cat gsfile1
  • done
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

5
Q2 And the answer is
  • The following is displayed 5 times
  • 1-abcd
  • 2-bcde
  • 3-cdef
  • 4-defg
  • 5-efgh
  • 6-fghi
  • Why?
  • The cat command is executed 5 times inside the
    loop. Remember cat command display an entire file.

6
Q3 What Happens?
  • cat gsfile1
  • while IFS read id code
  • do
  • echo id code
  • done
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

7
Q3 And the answer is
  • The following is displayed
  • id code
  • id code
  • id code
  • id code
  • id code
  • id code
  • Why?
  • That is what you said to print the words id and
    code one time for each line in the file.

8
Q4 What Happens?
  • cat gsfile1
  • while IFS read id code
  • do
  • echo id code
  • done
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

9
Q4 And the answer is
  • The following is displayed
  • 1 abcd
  • 2 bcde
  • 3 cdef
  • 4 defg
  • 5 efgh
  • 6 fghi
  • Why?
  • The in front of the variable said to print the
    values of the variables. The colon is missing
    since it was not a variable.

10
Q5 Matching
  • Statements
  • Purpose
  • mkdir
  • ls l
  • echo
  • awk
  • grep
  • cut
  • read
  • wc
  • pwd
  • Display working directory
  • Display a file with formatting
  • Display a variables value
  • Display a listing of files
  • Extract a field from a record
  • Extract a field from all records
  • Extract matching records
  • Count words, lines, and bytes
  • Create a directory

11
Q5 And the answer is
  • Statements
  • Purpose
  • mkdir
  • ls l
  • echo
  • awk
  • grep
  • cut
  • read
  • wc
  • pwd
  • Display working directory
  • Display a file with formatting
  • Display a variables value
  • Display a listing of files
  • Extract a field from a record
  • Extract a field from all records
  • Extract matching records
  • Count words, lines, and bytes
  • Create a directory

12
Q6 What do we do?
13
Q6 And the answer is
14
Q7 What Happens?
  • dd ifgsfile1 ofgsfile2 convucase
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

15
Q7 And the answer is
  • Nothing is displayed however, the file gsfile2
    now contains
  • 1ABCD
  • 2BCDE
  • 3CDEF
  • 4DEFG
  • 5EFGH
  • 6FGHI
  • Why?
  • The dd command copies a file. The conv option
    allows you to convert between upper case and
    lower case or between ASCII and EBCDIC.

16
Q8 What command am I? What is a PID and how
would you stop PID 12345?
17
Q8 And the answer is
  • The top command was run to get the display.
  • PID stands for Process ID. A process is a program
    running on the server.
  • To stop the process, type a k for kill then enter
    the PID of the process that you wish to stop.
  • To stop the top process from running, just type a
    q.

18
Q9 What will I display?
  • code"a"
  • case "code" in
  • "1") echo "Point 1"
  • "A") echo "Point 2"
  • "B") echo "Point 3"
  • ) echo "Point 4"
  • esac

19
Q9 And the answer is
  • Point 4
  • Why?
  • Linux is case sensitive with respect to
    variables, values, commands, file names, etc. The
    is executed when none of the cases is met.

20
Q10 What will be displayed?
  • cat gsfile1
  • more gsfile1
  • less gsfile1
  • head gsfile1
  • tail gsfile1
  • The file gsfile1 contains
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi

21
Q10 And the answer is
  • Each command will display exactly the same thing
  • 1abcd
  • 2bcde
  • 3cdef
  • 4defg
  • 5efgh
  • 6fghi
  • Why?
  • The cat command displays the entire file. The
    more and less commands display a screen at a time
    but the amount of data is less than a screens
    worth so they both display everything. The head
    and tail command display the first and last 10
    lines respectively, but there are less than 10
    lines so they are the same.

22
Q11 What would be displayed?
  • The following command is entered at the command
    prompt
  • cut f2 d products

23
Q11 And the answer is
  • The records will be displayed as entered.
  • S0109Ballroom Specials1221
  • S0110Poolside Carts1320
  • S0130Formal Dining Specials1340
  • S0201Reservation Logs1410
  • Why?
  • I have no idea why. I expected an error message
    to the effect that there was no second field,
    since the delimiter was a but Linux displayed
    all the records.

24
Q12 What would be displayed?
  • The following command is entered at the command
    prompt
  • cut f2 d products

25
Q12 And the answer is
  • The 2nd field of each record will be displayed
  • Ballroom Specials
  • Poolside Carts
  • Formal Dining Specials
  • Reservation Logs
  • Why?
  • The f option said to pick field 2 and the d
    option said the delimiter for the data was a
    colon.

26
Q13 What would be displayed?
  • The following command is entered at the command
    prompt
  • grep S01 products

27
Q13 And the answer is
  • The 2nd field of each record will be displayed
  • S0109Ballroom Specials1221
  • S0110Poolside Carts1320
  • S0130Formal Dining Specials1340
  • Why?
  • All records containing the characters S01 will be
    extracted and displayed, in the sequence in which
    they occurred in the file.

28
Q14 What would be displayed?
  • The following command is entered at the command
    prompt
  • awk -F 'printf "s\t s\t s\n", 1, 2, 3'
    products

29
Q14 And the answer is
  • Data would be displayed as follows
  • S0107 Lobby furniture 1201
  • S0109 Ballroom Specials 1221
  • S0110 Poolside Carts 1320
  • S0130 Formal Dining specials 1340
  • S0201 Reservation Logs 1410
  • Why?
  • The awk command said to print the data separated
    by tabs. Since Poolside Carts is shorter than the
    rest of the data, the 1320 tabbed to the next
    tabs stop and does not line up.

30
Q15 What would be displayed?
  • The following command is entered at the command
    prompt
  • awk -F 'printf "s\t -30s\t s\n", 1, 2,
    3' products

31
Q15 And the answer is
  • Data would be displayed as follows
  • S0107 Lobby furniture 1201
  • S0109 Ballroom Specials 1221
  • S0110 Poolside Carts 1320
  • S0130 Formal Dining specials 1340
  • S0201 Reservation Logs 1410
  • Why?
  • This time, the awk command sets the 2nd field to
    a length of 30, forcing all the fields to be the
    same size.

32
Q16 Name that command
  • The following command is executed
  • ls -l product
  • And the following data is displayed
  • -rw-r--r-- 1 gsmith csis 261 Mar 4 1236
    practice1
  • -rw-r--r-- 1 gsmith csis 335 Mar 4 1246
    practice2
  • -rw-r--r-- 1 gsmith csis 280 Mar 6 1209
    practice3
  • -rw-r--r-- 1 gsmith csis 298 Mar 2 2031
    practice_loop
  • What command would you use to give permissions to
    everyone to edit practice1, practice2, and
    practice3?

33
Q16 And the answer is
  • chmod gow practice?
  • Why?
  • The chmod command is used to modify permissions
    on a file. Since the owner already has write
    access, you only need to add it for groups and
    others. And, since there are multiple files that
    start with practice and you only want the ones
    that end in a 1, 2, or 3, you can use the ?
    wildcard character to limit the files that are
    affected.

34
Q17 What gets displayed?
  • cat gt gsfile1
  • 1234
  • 2345
  • 3456
  • 4567
  • d
  • cat gt gsfile2
  • aaaa
  • bbbb
  • cccc
  • dddd
  • Eeee
  • d
  • paste gsfile1 gsfile2

35
Q17 And the answer is
  • The following data will be displayed
  • 1234 aaaa
  • 2345 bbbb
  • 3456 cccc
  • 4567 dddd
  • eeee
  • Why?
  • The paste command displays the contents of files
    side-by-side. All data from both files will be
    used so since gsfile2 has more data than gsfile1,
    the last line shows nothing for gsfile1 but does
    show data for gsfile2.

36
Q18 What does this mean?
  • gsmith_at_linux ping -c 5 cs100.us
  • PING cs100.us (67.220.194.133) 56(84) bytes of
    data.
  • 64 bytes from 67-220-194-133.hosted.static.webnx.c
    om (67.220.194.133) icmp_seq1 ttl51 time67.2
    ms
  • 64 bytes from 67-220-194-133.hosted.static.webnx.c
    om (67.220.194.133) icmp_seq2 ttl51 time65.3
    ms
  • 64 bytes from 67-220-194-133.hosted.static.webnx.c
    om (67.220.194.133) icmp_seq3 ttl51 time66.0
    ms
  • 64 bytes from 67-220-194-133.hosted.static.webnx.c
    om (67.220.194.133) icmp_seq4 ttl51 time66.2
    ms
  • 64 bytes from 67-220-194-133.hosted.static.webnx.c
    om (67.220.194.133) icmp_seq5 ttl51 time66.8
    ms
  • --- cs100.us ping statistics ---
  • 5 packets transmitted, 5 received, 0 packet
    loss, time 3999ms
  • rtt min/avg/max/mdev 65.317/66.356/67.277/0.699
    ms

37
Q18 And the answer is
  • The server running the web site cs100.us is up
    and running and no data is being lost when
    communicating with the server.
  • What is the purpose of the c option?
  • The ping command by itself will continuing
    testing the server connection until to ctrl-c out
    of it or otherwise cancel the session. The c
    option limits the number of attempts made to test
    the server connection.

38
Q19 What Linux command was executed to send this
e-mail?
39
Q19 And the answer is
  • The mail command was used, specifically
  • mail g_at_cs100.us
  • What was the subject line and was anyone else
    copied?
  • The subject line was None and no one else was
    copied.

40
Q20 Matching
  • mail
  • read
  • write
  • sed
  • ping
  • dump
  • restore
  • kill
  • ps
  • top
  • Delete specific lines from a file.
  • Input data from a file.
  • Send an e-mail message.
  • Communicate interactively.
  • Display all processes running.
  • Backup a file system
  • Display your processes.
  • Restore a file system.
  • Stop a process that is running.
  • See if a server is running.

41
Q20 And the answer is
  • mail
  • read
  • write
  • sed
  • ping
  • dump
  • restore
  • kill
  • ps
  • top
  • Delete specific lines from a file.
  • Input data from a file.
  • Send an e-mail message.
  • Communicate interactively.
  • Display all processes running.
  • Backup a file system
  • Display your processes.
  • Restore a file system.
  • Stop a process that is running.
  • See if a server is running.
Write a Comment
User Comments (0)
About PowerShow.com