Answered step by step
Verified Expert Solution
Question
1 Approved Answer
awk /findme/ {print $1}' file1 is equivalent to which combination of commands? grep 'findme' file1 | awk '{print $1}' O awk '{print $1}' file1
awk /findme/ {print $1}' file1 is equivalent to which combination of commands? grep 'findme' file1 | awk '{print $1}' O awk '{print $1}' file1 | grep 'findme' Ogrep 'findme' | awk '{print $1}' file1 O awk '{print $1}' | grep 'findme' file1 QUESTION 2 Which command will display the contents of /etc/passwd correctly sorted by UID (3rd column)? O sort -rn /etc/passwd O cat /etc/passwd | sort sort -t':' -k3 -n /etc/passwd Osort -k':' -t3 -n /etc/passwd QUESTION 3 Which option allows 'sort to sort by number rather than alphabetically? -r -n -R -u QUESTION 4 You can use the sed command to perform find/replace substitution or to delete unwanted lines of text. True False QUESTION 5 You can send the standard output of one command to another command as standard input using the O a. < O b.> C. I d. # QUESTION 6 echo "hello" >filel 1>&2 2>file2 Where does the text "hello" end up? O STDIN O the screen O file1 O file2 shell metacharacter. QUESTION 7 What character is used to delimit fields in the Linux user and group database files, /etc/passwd and /etc/group? O a. space O b. colon O c. semicolon O d. tab QUESTION 8 Linux commands can be combined in three main ways. Match each with the correct description. B. shell script A. shell pipe C. subcommand A. sends the STDOUT of one command as STDIN of another B. an executable text file containing a sequence of commands that can be run as a command itself C. substitutes the output of one command as a command-line argument of another QUESTION 9 When combining commands in a pipeline, the processing typically follows what order? perform any manipulation on the selected data (e.g. `sed' or 'awk') get raw data into the pipeline (e.g. `cat file`, or some other command that produces your starting data) filter the stream down to what you're interested in (e.g. zero or more grep`s) save or append the resulting output to a file (i.e. with > or >>) QUESTION 10 Which command will count the number of currently mounted filesystems? O wc | mount O mount | wc -W O mount | wc -l O mount | wc -C QUESTION 11 Which commands will allow you to select specific columns of output? (choose all that apply) sort WC cut sed grep tr awk QUESTION 12 The file descriptor stdin is represented by the number a. 0 b. 1 C. 2 O d. 3 QUESTION 13 Which option do you need to supply to `awk` to tell it which character delimits columns in the source data? -F -f -D -d QUESTION 14 You can redirect the contents of a file to the standard input of a command using the a. | b. < O C. > O d. # metacharacter. QUESTION 15 It is a good idea to build compound commands one step at a time, testing with each new addition to the pipeline. For example 1. cat file 2. cat file | grep something 3. cat file | grep something | sed s/find/replace/g 4. cat file | grep something | sed s/find/replace/g > file2 True False QUESTION 16 allows you to duplicate stdout, sending it to the screen or a file as well as pipe it to another command. a. |& b.tee C. > d. &> QUESTION 17 You can use the BASH shell to redirect standard output from the terminal screen to a file on the filesystem using the by the absolute or relative pathname of the file. O a. # O b.> O C. < O d.l QUESTION 18 Are both standard output and standard error displayed on the terminal screen by default? O a. Yes O b. No shell metacharacter followed QUESTION 19 To append stdout to a file, use O a. < b. >> O c.l d. append O e.> O f. tee QUESTION 20 Sends both stdout and stderr of cmd to file: O a. cmd 2> file b.cmd &> file c. cmd |& file O d. cmd > file 1>&2 QUESTION 21 Which option causes `grep` to select lines that DON'T contain the given pattern? -V -d -e QUESTION 22 In what order are multiple I/O redirections (>, >>, QUESTION 23 Match each term with the correct statement below. d. Labels representing command input and output. b. Any error messages generated by a command. c. The information that is processed by the command during execution. a. The normal output of a command. a. stdout b. stderr c. stdin d. file descriptors QUESTION 24 Which command would show lines from file1 containing "banana", "Banana", or "BANANAS!!!"? grep -i 'banana' file1 grep 'BANANAS' file 1 grep -i 'BANANAS' file1 grep 'banana' file1 QUESTION 25 The command counts the number of lines, words, and characters in a file. atr b.wc c. pr d.nl QUESTION 26 Which is the equivalent of `cat file | cmd"? a. cmd > file b.file > cmd O c. file < cmd O d.cmd < file QUESTION 27 The file descriptor stderr is represented by the number O a. 0 b. 1 C. 2 d. 3 QUESTION 28 Which of these represent the use of a subcommand? (choose all that apply) echo "I am $(whoami)" echo "I am (whoami)" echo "I am {whoami}" echo "I am $whoami" echo "I am ${whoami}" echo "I am whoami" QUESTION 29 cat /etc/resolv.conf | grep 'nameserver' | awk '{print $2}' | sort -n >> nameservers.txt What does this command do? O filters out all lines containing "nameserver", isolates the IP address column, sorts the IPs numerically, and appends the results to a file. O selects only the second column where the value of the second column is "nameserver", then writes those values to a new file. O reads the file nameservers.txt, sorts it by number, selects the second column, filters out lines where that column is "nameserver", then writes the output to a file called /etc/resolv.conf. QUESTION 30 Filter command that prints lines from STDIN that match a given pattern to STDOUT: O a.tr b.grep O c. sed O d. cut QUESTION 31 Which command will make a backup copy of file1 and replace all instances of Matt with Matthew in the original copy of file1? O sed 's/Matt/Matthew/g' file 1 O sed -i.bak 's/Matt/Matthew/g' file1 O file1 | sed -i.bak 's/Matt/Matthew/g' O file1 | sed 's/Matt/Matthew/g' QUESTION 32 The command can be used to extract, manipulate, and format text using pattern-action statements. (Commonly used to select columns and/or rows from its input.) O a. grep Ob.awk c. nl O d. sed QUESTION 33 The file descriptor stdout is represented by the number O a.0 b.1 O c. 2 O d. 3 QUESTION 34 [root@md-fc13 ~]# ping -c 5 www.google.com PING www.google.com (173.194.77.106) 56 (84) bytes of data. 64 bytes from ob-in-f106. le100.net (173.194.77.106): icmp_seq=1 ttl-47 time=20.8 ms 64 bytes from ob-in-f106.1e100.net 64 bytes from ob-in-f106.1e100.net 64 bytes from ob-in-f106.1e100.net 64 bytes from ob-in-f106.1e100.net www.google.com ping statistics (173.194.77.106): icmp_seq=2 ttl-47 time=20.7 ms (173.194.77.106): icmp_seq-3 ttl=47 time=20.8 ms (173.194.77.106): icmp_seq=4 ttl=47 time=20.8 ms (173.194.77.106): icmp_seq=5 ttl=47 time=20.7 ms --- --- 5 packets transmitted, 5 received, 0% packet loss, time 4028ms rtt min/avg/max/mdev = 20.790/20.823/20.873/0.030 ms Which command would display just the overall packet loss percentage? awk -F',' '/packet loss/ {print $3}' $ (ping -c 5 www.google.com) | awk '{print $1}' O ping -c 5 www.google.com | awk -F', '/packet loss/ {print $3}' | awk '{print $1}' ping - 5 www.google.com | awk '{print $1}'| awk -F',' '/packet loss/ {print $3}' awk -F',' '/packet loss/ {print $3}' | awk '{print $1} $(ping -c 5 www.google.com) QUESTION 35 Why should you always enclose your `grep` search patterns, `sed substitution rules, and awk programs in single quotes? (e.g. `grep -v '\?*' file as opposed to `grep -v \?* file) O Some characters have special meaning for both the bash' shell and the command being run. To avoid confusion, quoting will force the shell to pass a literal string to the command. O They are required by "grep`, `sed', and 'awk. O They are required by "bash'. QUESTION 36 The general format of a 'sed substitution is Os/findme/replacewith/g O s/replacewith/findme/g O g/replacewith/findme/s O g/findme/replacewith/s QUESTION 37 *sed 's/Matt/Matthew/g' file1` modifies file1 (i.e. changes the contents on disk). True O False QUESTION 38 Which command would show only lines containing "/dev/sda" in the output of `mount? grep '/dev/sda' mount grep mount '/dev/sda' mount '/dev/sda' | grep mount | grep '/dev/sda' QUESTION 39 How does a subcommand "pass" its output to the enclosing/outer command (e.g. in the command 'echo $(subcommand)`) O The shell redirects STDOUT of the subcommand to STDIN of the outer command. O The subcommand is executed first and the shell substitutes the subcommand's output as one of the command-line arguments for the outer command. O The shell redirects STDIN of the subcommand to STDOUT of the outer command. O The outer command is executed first and the shell runs the subcommand each time it appears in the outer command's output. QUESTION 40 For more complex tasks, most Linux admins move up from piped combinations of commands to which scripting language(s)? (choose all that apply) Python C# OLISP Java O Perl
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started