Chapter 3
Topic 103: GNU and UNIX Commands

THE FOLLOWING EXAM OBJECTIVES ARE COVERED IN THIS CHAPTER:

  • images  103.1 Work on the command line.
    • Key knowledge areas:
      • Use single shell commands and one-line command sequences to perform basic tasks on the command line.
      • Use and modify the shell environment including defining, referencing, and exporting environment variables.
      • Use and edit command history.
      • Invoke commands inside and outside the defined path.
    • The following is a partial list of the used files, terms, and utilities:
      • bash
      • echo
      • env
      • export
      • pwd
      • set
      • unset
      • type
      • which
      • man
      • uname
      • history
      • .bash_history
      • Quoting
  • images103.2 Process text streams using filters.
    • Key knowledge areas:
      • Send text files and output streams through text utility filters to modify the output using standard UNIX commands found in the GNU textutils package.
    • The following is a partial list of the used files, terms, and utilities:
      • bzcat
      • cat
      • cut
      • head
      • less
      • md5sum
      • nl
      • od
      • paste
      • sed
      • sha256sum
      • sha512sum
      • sort
      • split
      • tail
      • tr
      • uniq
      • wc
      • xzcat
      • zcat
  • images  103.3 Perform basic file management.
    • Key knowledge areas:
      • Copy, move, and remove files and directories individually.
      • Copy multiple files and directories recursively.
      • Remove files and directories recursively.
      • Use simple and advanced wildcard specifications in commands.
      • Use find to locate and act on files based on type, size, or time.
      • Use tar, cpio, and dd.
    • The following is a partial list of the used files, terms, and utilities:
      • cp
      • find
      • mkdir
      • mv
      • ls
      • rm
      • rmdir
      • touch
      • tar
      • cpio
      • dd
      • file
      • gzip
      • gunzip
      • bzip2
      • bunzip2
      • xz
      • unxz
      • file globbing
  • images  103.4 Use streams, pipes, and redirects.
    • Key knowledge areas:
      • Redirect standard input, standard output, and standard error.
      • Pipe the output of one command to the input of another command.
      • Use the output of one command as arguments to another command.
      • Send output to both stdout and a file.
    • The following is a partial list of the used files, terms, and utilities:
      • tee
      • xargs
  • images  103.5 Create, monitor, and kill processes.
    • Key knowledge areas:
      • Run jobs in the foreground and background.
      • Signal a program to continue running after logout.
      • Monitor active processes.
      • Select and sort processes for display.
      • Send signals to processes.
    • The following is a partial list of the used files, terms, and utilities:
      • &
      • bg
      • fg
      • jobs
      • kill
      • nohup
      • ps
      • top
      • free
      • uptime
      • pgrep
      • pkill
      • killall
      • watch
      • screen
      • tmux
  • images  103.6 Modify process execution priorities.
    • Key knowledge areas:
      • Know the default priority of a job that is created.
      • Run a program with higher or lower priority than the default.
      • Change the priority of a running process.
    • The following is a partial list of the used files, terms, and utilities:
      • nice
      • ps
      • renice
      • top
  • images  103.7 Search text files using regular expressions.
    • Key knowledge areas:
      • Create simple regular expressions containing several notational elements.
      • Understand the differences between basic and extended regular expressions.
      • Understand the concepts of special characters, character classes, quantifiers, and anchors.
      • Use regular expression tools to perform searches through a filesystem or file content.
      • Use regular expressions to delete, change, and substitute text.
    • The following is a partial list of the used files, terms, and utilities:
      • grep
      • egrep
      • fgrep
      • sed
      • regex(7)
  • images  103.8 Basic file editing
    • Key knowledge areas:
      • Navigate a document using vi.
      • Understand and use Vi modes.
      • Insert, edit, delete, copy, and find text in Vi.
      • Be aware of Emacs, nano, and vim.
      • Configure the standard editor.
    • The following is a partial list of the used files, terms, and utilities:
      • vi
      • /, ?
      • h,j,k,l
      • i, o, a
      • d, p, y, dd, yy
      • ZZ, :w!, :q!
      • EDITOR

  1. Assume that you’re using the Bash shell and want to prevent output redirects from accidentally overwriting existing files. Which command and option can be used to invoke this behavior?

    1. setoutput -f
    2. overwrite=no
    3. overwrite -n
    4. set -C
  2. What command can be used to view the current settings for your environment when using Bash?

    1. environment
    2. env
    3. listenv
    4. echoenv
  3. Which command is used to access documentation on the Linux computer for a given command?

    1. doc
    2. heredoc
    3. man
    4. manual
  4. Which of the following commands will print various information about the kernel and architecture, along with other details?

    1. info --sys
    2. man sys
    3. sysinfo
    4. uname -a
  5. When using sed for a substitution operation, which option must be included so that the substitution applies to the entire line rather than just the first instance?

    1. g
    2. a
    3. r
    4. y
  6. Which option for the wc command prints the number of lines given as input?

    1. -f
    2. -a
    3. -l
    4. -o
  7. What is the default number of lines printed by the head and tail commands, respectively?

    1. 10 for head, 5 for tail
    2. 5 for head, 10 for tail
    3. 10 for both head and tail
    4. 3 for both head and tail
  8. You are attempting to use rmdir to remove a directory, but there are still multiple files and other directories contained within it. Assuming that you’re sure you want to remove the directory and all of its contents, what is the command and arguments to remove the directory and all of its contents?

    1. rm -f
    2. rm -rf
    3. rmdir -a
    4. rmdir -m
  9. Which command will find directories with names beginning with 2014 located beneath the current directory?

    1. find ./ -name "2014"
    2. find ./ -type d -name "2014"
    3. find / -type d "2014"
    4. find ./ -type d -name "2014*"
  10. Which of the following commands will provide the usernames in a sorted list gathered from the /etc/passwd file?

    1. cat /etc/passwd | awk -F : '{print $1}' | sort
    2. sort /etc/passwd | cut
    3. echo /etc/passwd
    4. cat /etc/passwd | awk '{print $1}' | sort
  11. Which options to ls will produce output, including hidden (dot) files, in a list that is ordered such that the newest files are at the end of the output?

    1. -la
    2. -lat
    3. -latr
    4. -ltr
  12. What will be the result if the touch command is executed on a file that already exists?

    1. The access time stamp of the file will change to the current time when the touch command was executed.
    2. The file will be overwritten.
    3. There will be no change.
    4. The file will be appended to.
  13. Which option to both mv and cp will cause the command to prompt before overwriting files that already exist?

    1. -f
    2. -Z
    3. -r
    4. -i
  14. Which of the following commands will send the contents of /etc/passwd to both STDOUT and to a file called passwordfile?

    1. cat /etc/passwd > passwordfile
    2. var /etc/passwd | passwordfile
    3. cat /etc/passwd | tee passwordfile
    4. echo /etc/passwd | stdout > passwordfile
  15. The current hierarchy on the server contains a directory called /usr/local. You need to create additional directories below that are called /usr/local/test/october. Which command will accomplish this task?

    1. mkdir -p /usr/local/test/october
    2. mkdir /usr/local/test/october
    3. mkdir -r /usr/local/test/october
    4. mkdir -f /usr/local/test/october
  16. Which option to the cp command will copy directories in a recursive manner?

    1. -v
    2. -R
    3. -Z
    4. -i
  17. You have received a file that does not have a file extension. Which command can you run to help determine what type of file it might be?

    1. grep
    2. telnet
    3. file
    4. export
  18. Which command will create an image of the /dev/sda1 disk partition and place that image into a file called output.img?

    1. dd if=sda of=/dev/sda1
    2. dd if=output.img of=/dev/sda1
    3. dd if=/dev/sda1 of=output.img
    4. echo /dev/sda1 > output.img
  19. What is the default delimiter used by the cut command?

    1. Colon
    2. Tab
    3. Space
    4. Comma
  20. Which of the following will unzip and extract the contents of a file that has been tarred and gzipped?

    1. tar -zxf <file.tgz>
    2. tar -xf <file.tgz>
    3. tar -vz <file.tgz>
    4. tar -fd <file.tgz>
  21. What command is used to bring a command to foreground processing after it has been backgrounded with an &?

    1. bg
    2. fore
    3. 4g
    4. fg
  22. You need to write a script that gathers all of the process IDs for all instances of Apache running on the system. Which of the following commands will accomplish this task?

    1. ps auwx | grep apache
    2. pgrep apache
    3. processlist apache
    4. ls -p apache
  23. Which of the following command lines would monitor a single process called nagios in a continuous manner?

    1. top -n 1
    2. top -p 23
    3. ps -nagios
    4. top -p`pidof nagios`
  24. Users are reporting that various programs are crashing on the server. By examining logs, you see that certain processes are reporting out-of-memory conditions. Which command can you use to see the overall memory usage, including available swap space?

    1. tree
    2. pgrep
    3. uptime
    4. free
  25. You are using the Vi editor for changing a file and need to exit. You receive a notice indicating "No write since last change". Assuming you want to save your work, which of the following commands will save your work and exit Vi?

    1. :wq
    2. :q!
    3. dd
    4. x
  26. What option is used to change the number of lines of output for the head and tail commands?

    1. -l
    2. -f
    3. -g
    4. -n
  27. Which command can be used to determine the current load average along with information on the amount of time since the last boot of the system?

    1. uptime
    2. sysinfo
    3. bash
    4. ls -u
  28. You need to start a long-running process that requires a terminal and foreground processing. However, you cannot leave your terminal window open due to security restrictions. Which command will enable you to start the process and return at a later time to continue the session?

    1. fg
    2. bg
    3. kill
    4. screen
  29. You have attempted to stop a process using its service command and also using the kill command. Which signal can be sent to the process using the kill command in order to force the process to end?

    1. -15
    2. -f
    3. -9
    4. -stop
  30. When working in the Bash shell, you need to redirect both STDOUT and STDERR. Which of the following commands will redirect both STDOUT and STDERR?

    1. 1>2
    2. >2
    3. 2>&1
    4. >>
  31. Which command can be run to determine the default priority for processes spawned by the current user?

    1. prio
    2. nice
    3. renice
    4. defpriority
  32. Which of the following egrep commands will examine /etc/passwd to find users who are using either /bin/bash or /usr/bin/zsh for their shell environment?

    1. grep sh /etc/passwd
    2. egrep '/*/.sh$' /etc/passwd
    3. grep '/*/.=sh$' /etc/passwd
    4. egrep '/*/..?sh$' /etc/passwd
  33. Which option to the man command accesses a different level of documentation, for example, system call documentation?

    1. man 2 <argument>
    2. progman <argument>
    3. man --sys <argument>
    4. man --list sys
  34. When editing with Vi, which command changes to insert mode and opens a new line below the current cursor location?

    1. f
    2. a
    3. o
    4. i
  35. Which kill signal can be sent in order to restart a process?

    1. -HUP
    2. -RESTART
    3. -9
    4. -SIG
  36. Which of the following commands will display the last 50 lines of your command history when using Bash, including commands from the current session?

    1. bashhist 50
    2. history 50
    3. cat .bash_history
    4. tail -f .bash_history
  37. You have backgrounded several tasks using &. Which command can be used to view the current list of running tasks that have been backgrounded?

    1. procs
    2. plist
    3. jobs
    4. free
  38. Which of the following commands searches each user’s .bash_history file to determine whether the user has invoked the sudo command?

    1. find /home -name "bash_history" | grep sudo
    2. find /home -name ".bash_history" | xargs grep sudo
    3. find /home/.bash_history | xargs grep sudo
    4. find /home -type history | xargs grep sudo
  39. Which command will watch the Apache log at /var/log/httpd/access.log and continually scroll as new log entries are created?

    1. watch /var/log/httpd/access.log
    2. tail /var/log/httpd/access.log
    3. tail -f /var/log/httpd/access.log
    4. mon /var/log/httpd/access.log
  40. You are debugging a configuration file and the daemon indicates there is a problem on line 932. Which of the following commands will prepend line numbers onto the file?

    1. lines
    2. wc -l
    3. newline
    4. nl
  41. You receive a file with an .lzma extension. Which command can you use to decompress this file?

    1. xz
    2. lz
    3. gz
    4. bzip
  42. Which find command will locate files within the current directory that have been modified within the last 24 hours?

    1. find ./ -type f -mtime 0
    2. find ./ -type f -mtime 24
    3. find ./ -type f -mtime +1
    4. find ./ type -f time 24
  43. Which command will move all files with a .txt extension to the /tmp directory?

    1. mv txt* tmp
    2. move *txt /temp
    3. mv *.txt /tmp
    4. mv *.txt tmp
  44. Which command prints your current directory?

    1. cwd
    2. curdur
    3. cd
    4. pwd
  45. Assume that you have a file called zips.txt that contains several postal ZIP codes and you need to determine how many unique ZIP codes there are in the file. Which of the following commands can be used for that purpose?

    1. sort zips.txt | uniq -c
    2. uniq zips.txt
    3. count zips.txt
    4. cat zips.txt | uniq -c
  46. When using Bash, how would you execute the last command starting with a certain string, even if that command was not the last one that you typed?

    1. Precede the command with ! and then the string to search for.
    2. Search for the command in history.
    3. Precede the command with a ? and then the string to search for.
    4. This is not possible with Bash.
  47. Which command can be used to kill all processes by using their name?

    1. killproc
    2. killname
    3. killall
    4. kill -f
  48. You’re working with a large file in Vi and need to search for instances of a string earlier in the file. Which key will search backward in the file?

    1. /
    2. h
    3. ?
    4. x
  49. You need to declare a local environment variable that will then be available to child processes. Which of the following commands accomplishes this task?

    1. ex
    2. echo
    3. dec
    4. export
  50. You are creating a Bash shell script and need to output the current script name to the current terminal. Which of the following commands accomplishes this task?

    1. cat <CMD>
    2. echo $0
    3. echo $SCRIPT
    4. echo $PS1
  51. You have downloaded a file with a .gz extension. What is the most likely command that you will use to decompress this file?

    1. unz
    2. gunzip
    3. hunzip
    4. gzunzip
  52. You need to remove a single file from a directory if it exists but would like to be prompted for confirmation before doing so. Which option to the rm command causes the command to prompt for confirmation?

    1. -a
    2. -e
    3. -i
    4. -o
  53. You need to determine files that are sized above 1GB. Which of the following commands accomplishes this task?

    1. find / -size +1G
    2. find / -size 10000M
    3. find / +1M
    4. find / -size +1B
  54. Which option to cpio lists the files as it is operating on them?

    1. -l
    2. -v
    3. -k
    4. -s
  55. Which command is used to send contents of a bzip2 archive to STDOUT?

    1. bzout
    2. bzcat
    3. bz2cat
    4. bz2echo
  56. You are attempting to find more information about the jobs command; however, an Internet search was not particularly helpful because there are so many Linux-related jobs available. Additionally, you attempted to view the man page for the jobs command but it was not available. Which man page should you use to view more information on jobs?

    1. jbs
    2. procctl
    3. bash
    4. ps
  57. You need to start a process that cannot be sent or will not accept a SIGHUP signal. Which command should be used to start the process?

    1. nosig
    2. nohup
    3. nokill
    4. noproc
  58. You need to run a command periodically and examine its output in real time. Which of the following commands enables this scenario?

    1. mon
    2. procmon
    3. pgrep
    4. watch
  59. You would like to tail a log file to watch entries as they are being added to the log file. In addition, you would also like to work within the same terminal window or SSH (Secure Shell) session to add entries to another file at the same time. Which command can be used to create two sessions within the same terminal window?

    1. screen
    2. tmux
    3. sess
    4. termse
  60. You need to kill several processes at once. Rather than writing a complex ps-based command to do so, you can use which other command?

    1. pkill
    2. psk
    3. pskill
    4. prock
  61. You are using pgrep to find the process IDs for a given command. However, several other commands seem to also appear. Which option to pgrep enables matching against the full path of the process?

    1. -f
    2. -d
    3. -o
    4. -i
  62. You need to determine the exact command that will be run based on your current environment settings. Which command is used for this purpose?

    1. what
    2. which
    3. find
    4. ls
  63. An environment variable has been set on login, but you need to remove that variable temporarily for the current session. Which shell built-in command can be used for this purpose?

    1. reset
    2. unset
    3. undo
    4. clear
  64. You cannot find the man page of a command but you know the command exists. For example, the alias command exists but there is no man page for it. Which of the following commands could you execute to determine what type of command alias is?

    1. type
    2. cmd
    3. uses
    4. listr
  65. Which type of quotes are used so that variables are interpolated within a Bash shell script?

    1. Escaped quotes
    2. Single quotes
    3. Double quotes
    4. Side quotes
  66. Which of the following pagers includes the ability to search backward and forward as well as move backward and forward, line-by-line, and page-by-page?

    1. more
    2. mplus
    3. less
    4. catch
  67. You have a specialized need for outputting a file in octal format. Which command or series of commands can be used for this purpose?

    1. oct
    2. cat <file> | octalf
    3. od
    4. octf
  68. Which option to sha256sum causes the file to be read in binary mode?

    1. -i
    2. -b
    3. -c
    4. -p
  69. When operating in command mode, which keys enable you to move the cursor in the Vi editor?

    1. a, s, d, f
    2. h, j, k, l
    3. q, w, e, r
    4. z, x, c, v
  70. Which options to xz are functionally equivalent to the xzcat program?

    1. decompress and output
    2. output and format
    3. decompress and stdout
    4. stdout and format
  71. Which environment variable is used to control the default text editor used on a Linux system?

    1. EDITOR
    2. EDIT
    3. TEXTEDITOR
    4. DEFAULT_EDITOR
  72. You need to examine the seventh section of the manual page for regular expressions, or regex, on a Linux system. Which command displays the seventh section of the manual?

    1. man regex -7
    2. man regex 7
    3. man --page 7 regex
    4. man 7 regex
  73. Which of the following commands reprioritizes an already running process?

    1. nice
    2. renice
    3. chnice
    4. altnice
  74. The fgrep command is equivalent to running the grep command with which option?

    1. -f
    2. -F
    3. -a
    4. -E
  75. Which of the following regular expressions would find the pattern Steve or steve in a file when used with grep?

    1. '[sS]teve'
    2. '[S]*teve'
    3. '^[Ss]teve'
    4. '[$Steve]'
  76. Which of the following commands shows the currently running processes and their resource usage in real time, updated every few seconds?

    1. nice
    2. ps
    3. top
    4. procs
  77. You have been asked to create a compressed file that will be readable by those with other operating systems. Which tool can you use for this purpose?

    1. gzip
    2. bzip2
    3. xz
    4. tar
  78. You need to match files that begin with 201, as in 2017, 2018, 2019. Which of the following wildcard specifications can be used?

    1. 201?
    2. 201$
    3. 201@
    4. 201]
  79. You need to break a large file into smaller pieces. Which command can be used for this purpose?

    1. cut
    2. split
    3. dice
    4. rem
  80. When examining the output from top, you see that a process has a value in the PR column of 20. To what does the PR column refer?

    1. The process ID
    2. The process utilization
    3. The process priority
    4. The processor core on which the process is executing
  81. You need to cut or remove eight lines from a file while editing with Vi. Which combination should be used for this purpose?

    1. d7
    2. d8
    3. r8
    4. x7
  82. Which command is used in order to decompress a file that has been compressed with xz?

    1. unxz
    2. dexz
    3. xzu
    4. u2xz
  83. Which of the following commands uses 128-bit message digests?

    1. sha256sum
    2. sha512sum
    3. sh128sum
    4. md5sum
  84. You have several files that need to be combined, with a line from each file being appended onto a single line. Which command can be used for this purpose?

    1. paste
    2. comb
    3. appfile
    4. combo
  85. You need to run a command that is not inside your current path. Which of the following represents the typical method for doing so?

    1. Use a fully qualified path for the command.
    2. Set the PATH environment variable to include the correct path.
    3. Restart the shell environment.
    4. Restart the computer for settings to take effect.
  86. Which signal is used by default by the pkill command?

    1. SIGKILL
    2. SIGTERM
    3. SIGHUP
    4. SIGKS
  87. You are working with the jobs built-in command to display jobs. You would like to see only running jobs. Which option to the jobs built-in command will display only running jobs?

    1. -s
    2. -a
    3. -l
    4. -r
  88. Which option to the bunzip2 command sends output to STDOUT, much like the bzcat command?

    1. -s
    2. -o
    3. -c
    4. -d
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset