Linux Certification CompTIA Group 3
Which results will the following command display? egrep '^[a-e]' file.txt
All lines that begin with a, b, c, d, and e All lines that begin with a, b, c, d, and e. The [] can contain ranges, so [a-e] means all letters from a to e, and the ^ means at the beginning of the line or word. You use $ for the end of a line or word.
Which of the following is the simplest type of regular expression?
An alphabetic string The alphabetic string is a regular expression that is as simple as a word or sample of text. For example, searching for the word, Linux, or the alphabetic text pattern, process.
Which of the following is a keyboard shortcut for repeating the last command entered?
!! The keyboard shortcut !! repeats the last command entered on the command line.
Which of the following regular expressions, when used with egrep, will match all words or lines that begin with any letter from a to e and their capitalized alternatives?
'^[a-e]|[A-E]' The '^[a-e]|[A-E]' regular expression matches all lines or words that begin with the letters a through e or A through E. Neither option '^[a-e][A-E]' nor '^[a-e]&[A-E]' works, because the correct operator is missing. The '^[a-e]|[A-E]$' option matches words that begin with a through e or words that end with A through E.
To be sure that a user does not overwrite or remove any important files when moving, copying, or removing files, which option should a user always use?
-i The -i option, which is interactive, should always be used. In fact, many users and almost all administrators set aliases for mv, cp, and rm. The -R option is only valid for cp and rm. The -f option is the force option, which should not be used in every case. The -v option only means to report in verbose mode, but is done so after the command has executed.
Using metacharacters, how would a user isolate text entries that have three random alphanumeric characters with the fourth character being a period (.) within a file from all other text entries? Examples: 123. bob. sally john day.
...\. The metacharacter match for three random characters and the fourth being a period (.) is (...\.). The ..... metacharacter will capture all entries with more than five characters, with no special consideration for the period in the line. The \W metacharacter will match any line with non-alphanumeric characters in it. The .* metacharacter will match everything.
By default, how many commands does the HISTSIZE variable keep?
1,000 The default HISTSIZE is 1,000 commands.
Which vi command allows a user to delete 10 lines of text in a file?
10dd 10dd deletes 10 lines in vi. 10x deletes 10 characters. 10A moves the cursor to the end of a line of text in insert mode, but the 10 has no effect. 10d removes lines or characters in the direction of navigation entered after the command.
If a user has opened multiple files in vi, how does the user quit all of them at the same time?
:qa The command qa (quit all) quits all files that are in the buffer. The :q! command quits all files without saving data. The :wq command quits only the current file. The :e command requires an external file to edit.
Which of the following is uniquely assigned to each running process?
A process ID (PID) A PID is uniquely assigned to each process. A dynamically-linked library is not assigned nor required for a process. A file system is not assigned to a process; the process runs in memory.
How does a user set a new shell variable, BLAH, to the value test?
BLAH=test BLAH=test. It is simple to set a variable to a value using the form: VAR=value.
Which of the following is NOT an advantage of placing a program into the background?
Background tasks use less memory than foreground ones do. Tasks that have been placed into the background use the same memory as they would if run in the foreground.
Which keyboard key combination does a user press to suspend a running job?
Ctrl+Z Ctrl+Z suspends or stops a job. Ctrl+C kills a job. There are no other key combinations that work with processes for job scheduling.
A process may include all but which of the following attributes?
Disk location ID A process runs in memory and therefore has no disk location ID. It has a process ID (PID).
What is the name of the graphical version of the vim editor?
Gvim Gvim is the graphical version of the vim editor. Emacs is an alternative to vi for command-line interface (CLI) editing. Gedit and KWrite are both graphical editors.
What is the function of the :num command?
It displays the line number of the cursor position and the text. The :num command displays the line number at the cursor's position in the file and displays the line of text.
In Linux, what is the command line?
It is a text-based interface. The Linux command line is a text-based interface in which users can interactively work with the system through a series of commands and scripts. A DOS window and a CMD prompt are both Microsoft command line interfaces. An xterm window is a graphical command line shell used within the graphical user interface.
What does the 1> operator do in the command ls 1> files.txt?
It is standard output (stdout) and the same as >. The 1> operator is the same as the >, standard output (stdout), operator. Standard error is 2>. There is no operator other than < for input.
When using the dd command, what is the purpose of the 'of' option?
It is the output file option. The 'of' option defines the outfile for the dd command. The input file option is 'if'. There are no overflow or octal format options.
In a display from ps -ef, what is the column header PPID?
It is the parent process ID (PID) for the process. PPID is the parent process ID of the process. The parent process is the process that spawned the process.
What is the nice value of a process?
It is the processes' priority in using shared system resources. The nice number refers to the priority a process has on the system. Because all resources have to be shared, if a process has a high priority, it is not as nice as one with a normal priority.
What does the following command, issued by the root user, do to the test.sh (PID 6547) script issued by user bsmith? renice 5 6547 -u bsmith
It lowers the priority to 5. The renice command lowers the priority to a value of 5. Remember that a negative number raises or increases the priority, while a positive number lowers or decreases the priority.
A user attempts to list the file FiscalYear2015.txt with the command ls FiscalYear2015.txt 2> files.txt. The user receives no output on the screen. What does no output to standard output (stdout) mean?
It means that the file does not exist in that directory. The ls command, ls FiscalYear2015.txt 2> files.txt means that the file does not exist because the user redirected standard error (stderr) (2>) only and that the error information is contained in the files.txt file.
In using the grep utility, what does the -v option do?
It omits the specified string following it. The -v option omits the string following it.
What function does the . command have in vi?
It repeats the last text edit. The . command repeats the last text edit.
Which operation does the following command perform for a user who has a file containing a list of words? sed -re 's/^(B|b)/C/' file.txt
It replaces all occurrences of words beginning with the letters B or b in a file with the letter C. The command replaces all occurrences of words beginning with the letters B or b in a file with the letter C, but only replaces the first letter because of the ^ metacharacter. The pipe character is the regular expression for or.
What is the difference in the two commands L and G?
L moves the cursor to the bottom of the screen and G moves to the bottom of the file. L moves the cursor to the bottom of the screen and G moves to the bottom of the file.
What is the matching pattern for the command egrep '^\w{6,8}'?
Match all lines that begin with any alphanumeric characters between six and eight characters in length Match all lines that begin with any alphanumeric characters between six and eight characters in length.
Which Linux feature allows programs to run in the background?
Multitasking Linux's multitasking capability allows processes to run in the background. The command line interface is a standard feature, but is not responsible for running processes in background. Pseudoterminals are software devices that emulate physical terminals. Symmetric multiprocessing refers to the hardware and software design of central processing units (CPUs).
How can a user create a permanent environment variable?
Place the variable into the .profile file and export it To create a permanent environment variable, the user must edit the .profile file, enter the variable, export the variable, and save the file. The variable will be available at login. The root user would not create a personal environment variable in a global file. The script option would not work, because child shell variables are not available to the parent shell. There is no .variable file.
Section 2
Section 2
Section 4
Section 4
Section 5
Section 5
Section 7
Section 7
Section 8
Section 8
Data entered via the keyboard is which type of stream?
Standard input The keyboard is standard input. Standard output is data that is sent to the screen. There are no streams identified as transfer or entry.
In the command wc < blah.txt, which type of stream does the < operator represent?
Standard input (stdin) The < symbol represents standard input from the blah.txt file into the wc command. Standard output is the > operator. Standard error is 2>. There is no standard stream.
Which of the following is the correct term defined as a sequence of one or more lines of text that can be written to be read on a text-based display?
Text stream A text stream is a sequence of one or more lines of text that can be written to be read on a text-based display. A text filter uses a text stream, but is passed through a filter to isolate part of a text stream. A text pipe is output from a command that is used as input for another command. A text redirect is a text stream that is passed in its entirety to a file.
In vi, the letters hjkl are equivalent to which other keys on the keyboard?
The arrow keys The navigation keys, hjkl, are equivalent to the arrow keys on a keyboard.
What is the result of the following command: echo Hello > hello.txt?
The hello.txt file is created and the word Hello is added to it. echo Hello > hello.txt creates the hello.txt file and copies Hello into it.
What information is displayed by issuing the pwd command?
The user's current working directory The pwd command stands for print working directory and displays the user's current working directory. Documents in the print queue are listed with the lpq command. The who command lists the users logged in to a system. The uptime command displays how long the system has run since the last reboot.
A user issues the following command: ls 2> files.txt. What information displays to the screen if the user then issues: cat files.txt?
There is no information to display to the screen. The ls 2> files.txt redirects errors to the files.txt file, but there are no errors, so there is nothing to display. The files.txt file is empty.
If a user wants to terminate only one instance of a particular process, what must the user do?
Use ps -ef | grep <command> and selectively use the kill command to terminate the specific instance The ps -ef |grep <command> ; kill PID is the best method. Using killall will kill all processes with the command name and not just the specific one. The pkill command can kill more than one instance, especially when using a partial name. The top command can work, but only if the desired instance appears near the top of the list.
A user needs to extract information that includes a period (.) from text files, but has had no success thus far. Which regular expression metacharacter will help the user collect the information required?
\. The \. metacharacter matches lines with periods or dots in them. The ./ is not a metacharacter, but how one launches a script or executable that is in the same directory. The *.* metacharacter means everything and is no different than simply using cat to view the contents of a file. The .* metacharacter means capture all.
How does a user match all lines that end with a period using grep with no options?
\\.$ \\.$ is the correct answer, as in: grep \\.$ file.txt. The first \ escapes the second one and greps for a period at the end of the line ($). The \.$, .$, and . are all the same to grep and yield all lines from the file. In this case, egrep would be a better choice for differentiating among the choices.
Which files does the following command match in file.txt? egrep '^(b|r)e' file.txt
better rent better and rent. The expression '^(b|r)e' translates as words beginning either with b or r and the second letter is an e.
How does a user restart a stopped job?
bg %# To restart a stopped job, issue bg %#. There is no restart command. Using an & after the fg or bg command has no effect.
Which of the following words will the grep command, cat file.txt | grep b[aeiou]t, not match?
boot The regular expression b[aeiou]t will match any word with the pattern: bat, bet, bit, bot, or but at the beginning of the word. The word boot is not matched.
An administrator wants to know how many users on a particular system use the C shell (csh) as their default shell. Which command produces the desired result as a single number?
cat /etc/passwd | grep csh | wc -l The cat /etc/passwd |grep csh | wc -l command is the correct answer. The grep csh /etc/passwd command will not count the number of entries. Neither file nor ls will expose the contents of the /etc/passwd file.
Which of the following is the INCORRECT method of using the sort command?
cat file.txt > sort The sort command cannot have input redirected to it. The cat file.txt > sort command will copy the contents of the file.txt file into a new file named sort.
Which of the following commands displays the contents of a file (file.txt) as output and then uses that output as input for a command that searches for a pattern (one) in that file and outputs the result?
cat file.txt | grep one (The correct command is: cat file.txt |grep one.)
Which command deletes from the current cursor position to the end of the file in vi?
dG The dG command deletes from the current cursor position to the end of the file. The d$ command deletes from the cursor to the end of the line. The d) command deletes to the end of the sentence. The d- command deletes the current and previous lines.
A user finds a file named file_backup on the system. How can the user determine which type of file it is, because it has no discernable extension or other identifier?
file file_backup The user should use the file file_backup command to determine what type of file it is. None of the other options will give any information about the type of file, and the ls | cpio command will overwrite the file as a cpio backup.
A user has three jobs running in the background. From the jobs table, how does the user terminate the xclock process? [1] Running xclock & [2]- Running firefox & [3]+ Running xterm &
kill %1 The kill %1 command will terminate the xclock process. There is no terminate command. The kill xclock command will not work, because the user has not specified a process ID (PID) or job number. Ctrl+C terminates foreground processes only.
Which command allows a user to name the command to terminate rather than using a process ID (PID)?
killall The killall command allows a user to use the command name rather than the PID to terminate a process. The kill command requires a PID. The nohup command is the opposite of kill, as it keeps a command running even after a user has logged out. The free command reports the amount of free memory.
Duplicate the functionality of the following tee command by using only the ls command. ls | tee files.txt
ls > files.txt ; ls The ls > files.txt ; ls command duplicates the ls | tee files.txt command's output. The ls files.txt command will only display the files.txt file if it exists; otherwise, an error is displayed. The ls | ls > files.txt command gives no output to the screen.
Which of the following ls commands will redirect standard output (stdout) to a file and standard error (stderr) to the same file, logfile.txt, such that the administrator can keep a log of which files do and which files do not exist?
ls FY2011.txt >> logfile.txt 2>> logfile.txt The ls FY2011.txt >> logfile.txt 2>> logfile.txt command is the correct option because it uses >> (append) for both redirects of stdout and for stderr. All the other options use a single > (create/overwrite) option.
Which of the following is the correct syntax usage of the nice command to set a specific priority on a user script, ping_network.sh?
nice -10 ./ping_network.sh The correct syntax for the nice command is: nice -10 ./ping_network.sh.
Which option allows a user to see only a particular user's processes in top when starting the top program on the command line?
top -u username The top -u username command allows a user to see the processes specified by username. None of the other top command options work with username as a parameter.
At the command line, how does a user open multiple files for editing with vi?
vi file1.txt file2.txt file3.txt Execute vi at the command line and all the files to open with it: vi file1.txt file2.txt file3.txt.
What is the function of the ? key in command mode?
It allows the user to search backward through the document for specific text. The ? allows the user to search backward through a document for a string.
What can an administrator determine from looking at the system load average?
The administrator can determine how busy a system is. The load average gives the administrator a snapshot of performance and how busy a system is. No other information can be inferred from the load average numbers.
Which of the following commands functions exactly like d$ in vi?
c$ The d$ and the c$ command have the same functions in vi. They both delete to the end of a line without deleting the line. The y$ has no significance in vi; it reads as a y. $ sends the cursor to the end of the line. The s substitutes one character under the cursor.
Which numeric kill option is SIGKILL?
-9 The SIGKILL signal is -9. As an example, kill -9 6847. It is an immediate termination of a process. -15 is a gentle termination, or SIGTERM. -2 is the SIGINT, which is the same as using Ctrl+C. The -HUP signal means hangup, which is to say, stop and restart immediately.
Which ps option allows a user to view the priority of a process?
-l The -l option allows a user to view the priority of processes. The -f option is for full format. The -e option displays every process running on a system. The -u option displays the processes for a user.
A user needs to execute the following command: /opt/mw/vcompare. The command is not in the user's path. What do they enter on the command line to execute this command?
/opt/mw/vcompare The user has to provide the full path to the command, /opt/mw/vcompare, to execute the command. The ./vcompare command will work if the user is in the /opt/mw directory, because that is how a user would execute a command in the current directory. Issuing vcompare will not work if /opt/mw is not in the path. The pwd vcompare command will not work, because pwd displays the working directory and ignores any arguments.
How does a user copy five lines of text and then undo before pasting in a new location?
5yy,u 5yy,u copies five lines with yy, then undoes the copy with u (undo). 5dd,p deletes five lines, and then pastes them. 5x,u deletes five characters and then undoes the deletion. 5r,u replaces five characters with u.
If a user opens multiple files (file1.txt, file2.txt, file3.txt) for editing with vi, how does the user switch to the next file (file2.txt)?
:n file2.txt The :n file2.txt command switches to file2.txt in vi. The :! command is for executing an external command. The :r command reads in the contents of a file into the current file. The :o command has no functionality in vi.
How does a user quit without saving any changes in the vi editor?
:q! To quit vi without saving changes, use :q!.
A user opens a trouble ticket and reports the following error for a directory they attempted to remove that they own in their home directory: rm: cannot remove `dir1': Is a directory. What is the problem?
A directory cannot be removed using the rm command. A directory cannot be removed using the rm command, even if the user has sufficient permissions to do so. The -i option specifies interactive and will not affect the outcome. Using the -f option will not remove the directory.
Which command does a user enter if the user needs help with the sudo command?
man sudo To get help with sudo, the user enters man sudo. The general form is: man command. Using help sudo will give an error, as will sudo /?, which is the DOS/Windows method of accessing command help. Typing export sudo will set the word sudo as an exported variable.
If a user wants to quickly search for the process ID (PID) of a specific process, for example, mysqld, which command should they use?
pgrep mysqld pgrep mysqld. The quickest method of isolating a PID for a process is to use pgrep and the process name. The other methods work, but they are not quick.
How can a user instruct a command to accept a command's output as its input that does not accept another command's output as its input? For example, how can a user instruct the echo command to accept output from ls as input?
By using xargs A user has to use xargs, which essentially adds arguments to the command and then executes it. Echo does not accept piped input or redirected input. The tee command does not work, because echo does not accept redirected output as input.
A program that a user executes interactively at the command line, such as ls -lR *.txt, is which type of process?
Foreground A command or process that a user executes interactively at the command line is an example of a foreground process. A background process is not interactive with the user. A paged process is saved to disk. A killed process is no longer in memory.
Processes may run where in memory?
In the foreground or in the background Processes run either in the foreground or in the background. All processes run in memory only—not on file systems or storage of any kind.
If an administrator issues the set command with no options or arguments, what does the command display?
It displays the names and values of all shell variables and functions. The set command with no options or arguments displays a list of shell variables, their values, and functions.
What does the < operator do for a user?
It sends the contents of a file to a command as input. The < operator sends the contents of a file to a command as input for that command. Typing words at the prompt is writing standard input to standard output. Redirecting errors to /dev/null or anywhere else requires the standard error, 2>, operator.
What is the function of the export command?
It sets an environment variable that is passed to child shells. (The export command makes variables set in a parent shell available to scripts and commands in child shells. The export command cannot provide variable values to other users, send outputs to other users, or redirect output to other shells. )
A user edits a file with the vi editor, with the following command: vi file.txt. Immediately after editing the file, the user issues the following command: ^vi^cat^. What does this command do?
It substitutes cat for vi, so that the new command is cat file.txt. The caret (^) is a substitution operator. The command ^vi^cat^ replaces vi with cat for the previously run command and then executes it.
To use pkill properly, what does a user need to know about a process?
Only part of its name For pkill to work, the user needs to know only part of the name of the in-memory process. The kill command requires the PID. The killall command requires the exact command name. The full path to the executable is not required for any kill command.
Which user is allowed to launch a program with a higher priority?
Only the root user Only the root user is allowed to launch a program with a higher priority.
What are symbols such as <, >, =, >>, 2> known as when used as part of a command?
Operators These symbols, when used as part of a command sequence, are operators. Some of the symbols are redirects (>, <, >>, 2>). Pipes always have the pipe symbol (|) in the command. Variables are assigned using the = operator.
The term regex refers to what in Linux?
Regular expressions The term regex refers to regular expressions, which are sequences of characters that define a string search pattern.
Which term describes the redefining of a processes' priority?
Renice The task of changing the priority of a process is to renice the priority.
The export command confuses a new Linux user. How can the user find immediate help for the export command?
By using the Linux man pages Users can always find help through the system's help system, known as man (manual) pages. The user will receive errors when typing google export or export /? at the command line. The export /? is the DOS/Windows method of obtaining system help with a command. If the user enters export with no options or arguments, the command displays a list of currently exported names.
Which of the following ps command fields has possible values of R (running), T (stopped), D (asleep and uninterruptible), S (asleep), Z (zombie), or N (positive nice value)?
STAT The STAT, or status, field displays the status of a process as R, T, D, S, Z, or N. PRI is the priority of a process. NI is the nice value for a process. SHARE is the amount of shared memory consumed by a process.
What is the significance of the $ in the environment variable $SHELL?
The $ means that the object is a shell variable name. (The $ designates an object as a variable. A variable is usually in all caps. The variable name is the $ and the variable. For example, the variable FOO has the variable name $FOO.)
What does the following locate command send to the screen as output? locate filename.txt -n 10
The first 10 search results for filename.txt The locate command with the -n 10 option displays the first 10 results of a locate search. None of the other options listed exist for the locate command.
What is the function of the :! command in vi?
To run an external command and see the results while in vi The :! command allows a user to issue an external command while in vi and display the command's results.
Which of the following regular expressions is equivalent to the \w metacharacter in its scope of pattern matches?
[a-zA-Z0-9_] The \w metacharacter is equivalent to [a-zA-Z0-9_] because of its range of matching all letters, both lower- and uppercase, 0 through 9 and the underscore character. The [a-zA-Z] is a subset of \w. The [*.*] matches everything. The [....] only matches lines with more than three characters.
A user has a list of topics in a file and wants to be sure that all topics begin with capital letters. Which of the following commands can accomplish this task?
sed -re 's/^./\U&/' file.txt The sed -re 's/^./\U&/' file.txt command will convert all first letters to uppercase on each line. The other options attempt to replace the first match with the literal second argument.
Which two commands would a user combine into a command to alphabetize a file's contents and then display its last 10 lines of content?
sort and tail Sort and tail. Sort alphabetizes the contents of a file, and tail displays the last 10 lines of content. Uniq removes repeated lines, and head displays the first 10 lines. Sed replaces text in a file, and join combines two files that share a common field. Cat displays a file, and cut filters a column or field.
How does a user undo a mistyped entry in the vi editor?
u The lowercase u command is undo for the last action. The dd command removes a line of text. The :w command writes the current contents to the file. The x deletes a single character.
How does a system administrator find the central processing unit (CPU) type for a running system?
uname -a (The uname command prints system information based on a variety of options. The -a option prints all information, including the processor type, operating system, kernel name, and other information. The -p option would also print the processor type. The uname -r command will display the kernel release. No $CPUTYPE or $PLATFORM variables exist.)
A user used the expand command on a file to convert tabs to spaces, but an administrator wants to reverse this action on the file. Which command provides this capability?
unexpand The unexpand command reverses the action of the expand command. The expand command has no option for reversing its action. The uniq command filters repeated lines of text in a file. The nl command applies line numbers to lines of text in a file.
How does a user clear a local variable, for example the variable $BLAH, from memory?
unset BLAH The command to clear a local variable is unset BLAH, using the general form: unset VAR. Do not use the variable $BLAH; it will not unset the variable. The kill command is for ending processes. The unalias command is to clear an alias. The unlink command removes a file.
How does a user change the value of the variable FOO from blah to blah2?
unset FOO ; FOO=blah2 The proper method of changing the variable FOO from blah to blah2 is: unset FOO ; FOO=blah2. The command rm is for removing files, not variables. Neither of the other options is a working command.
Which command does the administrator use to update the mlocate database for the locate command?
updatedb The administrator issues the updatedb command to update the mlocate database. This refreshes the files contained in the database.
Which of the following commands allows a user to navigate to the first letter of the next word in a sentence?
w The w command moves to the beginning of the next word. The b command moves to the beginning of the previous word. The r command replaces a character of text. The ^ moves to the beginning of the current line.
How does a user navigate to the beginning of the current line in vi without entering insert mode?
^ The ^, or caret, moves the cursor to the beginning of the current line without entering insert mode. The d key deletes text using navigation keys. The h key moves the cursor left one character. The p key pastes the buffer below the current line.
Which regular expression metacharacter denotes the beginning of a line or word when applied to a bracketed value, but as an exclusion when applied inside the bracket?
^ The caret (^) denotes a string at the beginning of a search pattern. For example, the first letter in a word or the first character of a line of code. The caret (^) when used inside the [] means that the user wishes to exclude that information from the match. For example, ^[^a] means do not match the letter a at the beginning of a word or a line.
Which of the following words matches the regular expression ^b[aeiou]t?
butcher The word butcher is matched. The word to match must begin with the letter b (^b); have one of the letters a, e, i, o, or u next; and then have a t in it. Any characters after those first three letters will also be a match.
Which of the following commands copies all files named with a .txt into the /tmp directory?
cp *.txt /tmp cp *.txt /tmp is the correct command to copy all files named with a .txt into the /tmp directory. A user cannot use the > or | with the cp command. The cp .txt /tmp command only copies a file named .txt to the /tmp directory.
How can a user find how many shell commands are kept in .bash_history?
echo $HISTSIZE echo $HISTSIZE. The HISTSIZE environment variable holds the value for the number of commands that are kept in history. The history command displays all the commands in history. The echo .bash_history command will display the word .bash_history, and echo history will display the word history.
Which command can a user run to view all of the user's shell environment variables?
env The env command displays the user's shell environment variables. $SHELL is not a command, but is a shell variable. The echo $SHELL command displays the user's default shell. The uname command displays system information.
A user wants to remove all the tabs in a file and convert them to spaces, but to do so manually is time-consuming and tedious. Which command performs this function for the user?
expand The expand command converts tabs in a file to the equal number of spaces. The fmt command formats text to a specific width by filling empty lines for the file. The split command splits a file into two equally sized files. The paste command merges the lines of one or more files.
Which of the grep commands would find the line containing pa$$word in a file using pa$ as the expression to match?
fgrep The fgrep command will find the word pa$$word in a file using pa$ as the pattern to match because it ignores regular expressions and uses the text as typed to match. The grep and egrep commands would only find a match if a word ended in pa$. The pgrep command is for processes, not files.
What type of information does the regular expression '^http(s?):\/\/.*' match?
http or https web addresses The regular expression 'http(s?):\/\/.*' matches http or https web addresses.
Which of the following ls commands allows a user to display all files, even hidden ones?
ls -a The ls -a command displays all files in the specified directory, even hidden ones. The ls command with no options shows all files except hidden ones. The ls -r command displays the file list in reverse alphabetical order. The ls -s command displays files by file size and displays the file size.
Which man command option formats a man page so that it enables printing?
man -t The man -t option formats a man page so that it looks correct when printed. The man -p option specifies the sequence of preprocessors to run. The man -d option displays debugging information. There is no -lpd option for man pages.
Which find command -name option wildcard pattern would a user use to locate all files with five-character names named with any suffix?
"?????.*" The correct option is: "?????.*". The ? is a search for any single character. The * searches for any string regardless of length. The "*5.*" option will find all files with the number 5 positioned before the dot (.) in the file name. The "*****.*" pattern will find every file, because * is a generic wildcard for any string and any length. The "*****.?" pattern will match any file that has a single character suffix.
Explain why the command mv dir1 dir2 completes successfully, but the command cp dir1 dir2 fails.
Because mv is recursive by default and cp is not The mv command is recursive by default and cp is not. The equivalent cp command requires the -R option. Any user can execute the mv command. Both mv and cp work well with directories and regular files.
A user finds that they have repeated the same five commands in performing a housekeeping task. How can they use their command history to repeat the commands in the most efficient manner?
Use the Up Arrow key to find the command, and press ENTER when the desired command is found (Use the Up Arrow key on the keyboard to cycle through the last 1,000 commands issued at the command line, beginning with the most recent first. The history 5 command shows the last five commands used, but does not execute them. The echo history 5 command will display the words history 5. The tail -5 .bash_history command will display the last five commands, but will not execute them.)
Vi is not an acronym, but it is a short form of which term?
Visual Vi is known as the visual editor.
Identify the match for the regular expression: '^t'
testing The word testing is the only match for '^t', because the caret character (^) matches the character or string at the beginning of the word or line.
What does the nohup command's acronym mean?
No hangup The nohup acronym means no hangup, which is to say, do not kill the task when the shell logs out.
Which of the following is NOT part of the process table?
The process job status The process job status is NOT part of the process table. The jobs table displays job status.
Identify the match for the regular expression: 'g$'
hag The 'g$' regular expression will match any word that ends with the letter g. $ is the end of the word or line regular expression character.
To copy a directory and its contents to another directory, which option or switch must be used?
-R The -R option is the recursive option, which is required to copy one directory and its contents to another directory. The -p option preserves permissions. The -v option is for verbose output. The -u option is for update, to copy only when the source directory contents are newer than the target's.
Which find command option does an administrator use to find all files accessed within the last 10 days in the /home directory?
-atime The find command option to define last accessed time is -atime. The -mtime option is modification time, which is different from accessed time. A user can cat a file (accessed) without making modifications. The -name option is for searching for a particular file name or multiple file names using a wildcard. The -type option searches for files, directories, and other file types.
Which find option should an administrator use if they want to find a list of files that have been modified within the last 10 days?
-mtime The find command option that lists files by modification time is -mtime. This option tells the administrator which files have been modified or changed within the specified time period. The access time (-atime) option only tells the administrator if a user has looked at a file, but the file might not have been modified. The -perm option offers the administrator a list of files by permissions. The -type option filters a search by file type.
A user issues the following command and receives expected results. ls -l -rw-rw-r-- 1 user user 323 Feb 2 20:18 file1.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file2.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file3.txt How do the displayed results change if the user pipes the command to xargs?
-rw-rw-r-- 1 user user 323 Feb 2 20:18 file1.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file2.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file3.txt Piping the output to the xargs command with no options results in the following output on a single line: -rw-rw-r-- 1 user user 323 Feb 2 20:18 file1.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file2.txt -rw-rw-r-- 1 user user 323 Feb 2 20:18 file3.txt
How does a user successfully run this script: file_list.sh, which is in the user's current directory?
./file_list.sh (Use ./file_list.sh. The script must be run with the leading ./ so that the user's path is overridden and the current directory is used. Simply running file_list.sh will fail with a command not found error because the current directory is not in the user's path. The runas command is a Windows command. Sudo -c would not work because the script is in the current directory. )
In which file is the user's command history stored?
.bash_history The hidden file .bash_history stores a running list of previously used commands. The .bashrc file is a hidden file that sets shell variables for the user. The .profile file sets global profile variables for the user. The .ssh/known_hosts file maintains a list of previously used hosts that the user has connected to via ssh, along with the remote system's fingerprint.
When a user compresses an archive using the bzip2 command, which suffix does the bzip2 command give the compressed archive file?
.bz2 The bzip2 command appends the archive file name with the .bz2 suffix (extension), indicating that it has been compressed using the bzip2 command. The .tar suffix is traditionally used for files archived using the tar command. The .gz suffix is appended to an archive by the gzip utility. The .zip suffix is appended to the file name by the WinZip utility for Windows computers.
When a user uses the xz command to compress an archive, which file name suffix does the xz command append to the archive?
.xz The xz compression utility appends the .xz suffix to the archive file name. The .gz suffix is added by the gzip command. The .tar suffix is added by the user traditionally when using the tar command, and then passing the archive through gzip adds the .gz suffix. The .Z suffix is added by the compress command.
If a system administrator wants to know which shell a user is configured to use, in which file would the administrator look?
/etc/passwd The shell assigned to each user is set in /etc/passwd. The /etc/group file contains group information, but nothing about shells. The /etc/shadow file contains user names and encrypted passwords. The /bin/bash file is the user shell, bash.
What is the name of the global bash configuration file?
/etc/profile The global bash configuration file that sets the PATH, configures the prompt, sets aliases, and sets environment variables is /etc/profile. There is no /etc/bash file. The .bash_history file keeps a running history of commands used in bash. The .profile file is each user's personal profile file where some default variables and settings can be placed.
What is the default nice value of all processes in Linux?
0 The default nice value of all processes in Linux is 0. The range of possible values is from -20 for the highest priority to 19 at the lowest priority.
Why does the command ls 2> files.txt display a list of files to the screen, but nothing to the files.txt file?
2> is standard error (stderr) and there were no errors, and standard output (stdout) was not redirected, so it displays on the screen. The ls 2> files.txt command shows a list of files because the stdout was not redirected, and there is nothing in the files.txt file because no errors were redirected to it via 2>. There are no errors to display or to redirect. No options are required for the ls command.
Identify the method of redirecting standard error (stderr) to standard output (stdout) using a single operator.
2>&1 2>&1 redirects stderr to stdout. The reason a user or an administrator uses this combination operator is that it is an easier method of manually writing results to a file. This is used when the user or administrator wants all output saved to a file, even if the output is an error.
How does a user move two lines of text from one location in a file to another location using vi?
2dd, navigate to the new location, p 2dd, navigate to the new location, p. Delete the two lines from the current location, navigate to the new location, and press p to paste the lines. Using y (yank) copies the files instead of moving them. The u key will undo the deletion of the two lines.
Identify the number that will match the regular expression: '^[0-9]{5}'
76470 76470. The regular expression '^[0-9]{5}' matches all numbers with five or more digits.
How does a user access online help while using the vi editor?
:help The :help command opens help above the current file in vi, but does not affect the current file.
Which command copies the contents of another file into the current one while in vi?
:r file.txt The :r file.txt command reads in the named file into the current file. The :w file.txt command writes (saves) to the file.txt file. The :q command will quit and ignore the file.txt info. The :n file.txt command opens file.txt for editing.
How does a user editing a file in vi periodically save work without exiting the file to do so?
:w Periodic saves can be done by entering command mode and typing :w. ZZ writes and then quits vi. The :q! command quits vi without saving. The :wq command writes and then quits vi.
If a user opens vi by typing vi <ENTER> at the command line and enters text into the buffer, what must the user do to save the current file?
:w <file name> The user must supply a file name when saving for the first time, :w <file name>. After the first save to the file, then the user can issue :w to periodically save the file. The :wq command will write and quit. The :q! command quits without saving.
Which command line operator redirects output from a command to a file?
> The command line operator that redirects output from a command to a file is the > operator. The & operator puts a command into the background for operation. The ; operator between commands directs the shell to execute one command and then the other in order from left to right. The | (pipe) operator takes the output of one command and provides it as input for another command.
What does the top command display for a user?
A dynamic list of the top resource-consuming processes The top command displays a dynamic process table and some system statistics. The top resource-consuming processes are shown at the top of the list. The amount of free memory on a system is found with the free command. The top command does not provide the list of the largest programs running in memory. The jobs command displays job information, and only for the user who executes it.
What is the output of the following command? ls | tee files.txt
A list of files is displayed to standard output (stdout) and written to the files.txt file. The tee command sends the output of the stream to the screen and to the specified file. There are no errors, so nothing is directed to stderr.
What does the env command display to a user?
A list of the user's environment variables and their values The env command displays a list of the user's environment variables and their values. A user's command history is shown using the history command. A list of the user's aliases is displayed with the alias command. No single command will list all available languages, fonts, and aliases on the system.
What is the primary difference between a pipe and a redirect?
A pipe takes a data stream of output from one command that is input to the next command, and a redirect is a stream of output that is usually directed to a file and not to another command. A pipe takes the output from one command and uses it as input to the next command, and a redirect is a stream of output that is usually directed into a file and not to another command. Pipes are unidirectional, as are redirects. A pipe converts output to input and does not redirect any stream to a file.
Which term is described by an instance of a running program that performs a data processing task?
A process A process is an instance of a running program that performs a data processing task. A file can be a program, but the file itself is not running or processing data. Standard input is data from the keyboard or redirected from a file. The kernel is the heart of the operating system and is responsible for managing processes.
Bracket expressions are handy for identifying characters to match, but what else can a user place inside brackets to extend and strengthen string matches?
A range of options A user can extend matches by placing ranges inside brackets, such as [0-9] or [a-z], which captures all numbers from 0 to 9 and all letters from a to z. The other options do not extend matches and are standard narrow match options.
When a user works at the command line, what is the user actually working in?
A shell When a user works at a command line, the user is actually working inside a shell, which is a user environment for executing commands and working with the operating system. The command line is not the graphical user interface. A DOS window is a Microsoft command line. The shell is an integral part of Linux and not external to it.
A child shell is also known as which type of shell?
A subshell A child shell is also known as a subshell. Subshells are typically invoked by running a script.
Which pattern will the command, grep [0-9] file.txt, match?
Any line with a number in it [0-9] will match any line that contains a number.
Which user may launch a program with a lower priority?
Any user Any user may lower the priority of a program.
Why do scripts spawn subshells when a user executes them?
Because the first line in the script spawns the new shell (Scripts spawn new shells because typically the first line of a script identifies the shell in which the script will run. For example, #!/bin/bash tells the script to run the script's commands in the bash shell. If no designation is made, the script runs in the user's default shell. Commands run interactively on the command line do not run inside a new shell. The new shell is not a function of which user runs the commands. Scripts can run in any shell.)
Why are the vi editor and vim preferred by many Linux administrators?
Because they are efficient and customizable The vi editor and vim are efficient and customizable. The other options are also true, but the editors are preferred because of their efficiency and the capability to be extensively customized.
Which of the following is a match for egrep -i '1{3}' file.txt?
Bob (212) 555-1111 The egrep -i '1{3}' file.txt command searches for lines containing three consecutive 1s in them.
Which of the following would NOT match the regular expression '^[0-9]{3}'?
Bob 111 Bob 111. The regular expression '^[0-9]{3}' matches at least three digits at the beginning of the line.
Which of the following is NOT a shell function?
Booting the system The option that is NOT the function of a shell is booting the system. The bootloader's job is to boot the system. No shell is available in the boot process.
What is the requirement for combining two files using the join command?
Both files must have a common field. The requirement for joining two files is that they share a common field on which to join. The common field is usually numeric, and both must share the same numbers for a proper join. There are no size restrictions.
Which shell is the most commonly used in Linux?
Bourne-again shell (bash) (Bash, the Bourne-again shell, is the most commonly used Linux shell. The csh, or C shell, is mainly used by programmers. The Korn shell (ksh) is a standard UNIX shell that is still available, but not commonly used on Linux systems. The Bourne shell (sh) is a common UNIX shell that was the basis for the creation of bash.)
What is the default Linux shell?
Bourne-again shell (bash) Bash is the default Linux shell. Other shells may be used either as a subshell in scripting or interactively, or the root user can reset a user's default shell to any available system shell.
If a user does not want to cd (change directory) to, for example, the /etc directory, how does the user display a list of files from that directory?
By using the absolute path in the command All of the options will work, but the most correct, and the most often used, is to supply the absolute path to the remote directory that the user wants to work with in a command.
If a user wants to execute a command that is not included in their path, how do they execute the command?
By using the full path to the command A user who wants to execute a command that is not in their path must use the full path to the command when executing the command.
Predict the output of the tr command and the input that follows. tr a-z A-Z comptia test (input) (output)
COMPTIA TEST The output is COMPTIA TEST because the tr, or translate, command takes a pattern and interprets the input according to that pattern. In the example, a-z A-Z translates the input, comptia test, into the uppercase result.
What are bracket ([]) expressions?
Characters inside the brackets match any one character. Bracket expressions are characters enclosed in square brackets that match any one character inside the brackets. For example, h[a o u]g can match hag, hog, or hug.
Which key switches from insert mode to command mode in vi?
ESC The ESC key is used to switch from insert mode to command mode. The i key switches to insert mode. The v key switches to visual mode, enabling selection of one character at a time. The A key switches to insert mode at the end of the line.
How does a user place a command into the background?
Enter the command with a trailing & To place any command into the background for processing, enter the command with a trailing &. For example, xclock &. The trailing - is not a valid option. Piping the command to /dev/null is not possible because output is redirected, not piped, to /dev/null. Redirecting output to a remote terminal does not place the command into the background.
Identify the type of the following command: sort /etc/passwd
Filter The sort command is a filter for the /etc/passwd text stream.
How many possibilities for job status are there?
Four There are four possible statuses for jobs: Running, Stopped, Terminated, and Done.
Which of the following commands moves the cursor to the top of the screen?
H The H command moves the cursor to the first line of the screen. The gg command moves the cursor to the first line of the file. The G command moves the cursor to the last line of the file. L moves the cursor to the bottom of the screen.
Which vi keyboard shortcut moves the cursor to the beginning of the line?
I I moves the cursor to the beginning of the current line. H moves the cursor to the beginning of the file. G moves the cursor to the beginning of the last line. O opens a new line above the current line.
When using the locate command, where does the locate search take place for a file?
In the mlocate database The locate command uses the mlocate database file that keeps a list of all files on the file system. It is more efficient to search through a single file database rather than searching through an entire file system. The list of files on most systems is too large to keep cached in memory. The system.map file is a file used by the Linux kernel to look up symbol names and their addresses in memory.
Identify the correct method of resetting the priority of a process.
In top, press r, enter the process ID (PID) of the process to alter, and enter the nice value. Using the top command, type r for renice, enter the PID, and enter the nice value. The n value is a number of processes to display in top. The nice and renice commands have the incorrect syntaxes for their use.
In the command mail user@domain < /etc/passwd, what is the file /etc/passwd for the purposes of this command?
Input (The /etc/passwd file in the command mail [email protected] < /etc/passwd is input for the command. Output requires the > operator. Piped filter requires the pipe (|) and a filter command. A filter requires one of the filter commands.)
The vi editor has four modes: command mode, visual mode, execute mode, and which other mode?
Insert Insert mode is the fourth vi mode.
When a user runs a bash script, where do the commands inside the script run?
Inside the child shell (The script executes in the parent shell, but the commands inside the script run in the child shell. )
What function does the jobs command perform for a user?
It allows the user to view all processes the user has placed into the background. The jobs command allows the user to view all background processes and their statuses. The jobs command allows users to only view the processes, and it does not bypass security.
What does the 2>> operator do when it is used as part of a command, ls FY2011.txt 2>> files.txt, for example?
It appends any error output to the files.txt file. The 2>> operator will append any information in the files.txt file with its own error information. It will not overwrite anything. The >> is the append redirection operator.
The grep utility is a versatile one in that it can search for strings inside of files, but it can also accept which type of information from other commands?
It can accept input from piped streams. The grep utility can accept input from piped streams. In fact, piping to grep is perhaps the most popular method of using it. Grep cannot accept redirected output, stderr, or interactive information.
What does the following command do? cp dir1 ../
It copies dir1 to the directory one level above the current directory. The ../ designation means one level above the current directory. If the user has permission to write to that directory, the command proceeds. A user's home directory is specified by the ~/ designation.
When using the xargs command, what is the -d option's function?
It describes a string delimiter. The xargs -d option describes a file's delimiter, which is to say the character that separates lines or items in a file.
Describe the result of the following command: cat newfile.txt
It displays the contents of newfile.txt to the screen. The cat newfile.txt command displays the contents of the newfile.txt file to the screen. Newfile.txt is not being redirected to any location or to any command. Cat does concatenate, but without options, it only displays the contents of a file.
What is the notable feature of the fgrep command?
It does not recognize regular expressions. The fgrep command does not recognize regular expressions. Extensions are meaningless to the Linux operating system shells.
What is the purpose of the -i option for the egrep command?
It ignores case. The egrep -i option means to ignore case in the same way that grep -i does.
What is the jobs table?
It is a list of jobs running in the background. The jobs table is a list of all jobs running in the background. The jobs command displays only current background jobs and their statuses.
What is a regular expression?
It is a string of characters that form a pattern in order to match an alphanumeric string or range of strings. All of the options are possible using regular expressions, but regular expressions themselves are strings of characters that form a pattern in order to match an alphanumeric string or range of strings.
What is the process table?
It is a summary of processes currently running on a system. The process table is a summary of currently running processes on a system. The list of jobs is the jobs table. A list of processes owned by the root user is part of the process table. No table of programs that can run in memory exists on a system by default.
If a user's shell is set to /bin/false, what does this mean to the user?
It means that the user cannot log in to the system. The /bin/false designation means that the user account cannot log in to a shell on that system. This usually means that the user account is a daemon or service account and it would be a security problem if this user could log in. For an account with /bin/false, it just means that there's no interactive shell available, but the account has not been deleted or disabled. It has nothing to do with a security violation, such as hacking attempts.
What is meant by the term, file globbing?
It means using wildcard characters as a pattern match. File globbing means to use wildcards to specify a large number of files to be processed or to gather a set of files based on some pattern. Globbing can be used for any of the other options, but the options themselves are not globbing.
What does the j key do in vi?
It navigates down in the file one line at a time. The j key navigates downward in a file one line at a time. The k key navigates up one line at a time. To navigate right, use the l key. The x key deletes one character at a time.
Administrators often add the following redirection to shell scripts: 2>/dev/null What does the redirection do for the administrator who uses it?
It redirects all standard error (stderr) to /dev/null, essentially discarding it. This command sends all stderr to /dev/null, which discards it from the system. It is a method of suppressing errors. There is no further processing available after a redirect to /dev/null. A redirect to a tape archive would be a pipe rather than a redirect. To send all stderr to stdout, use 2>&1.
In the following command, what is the bs=1M designation? dd if=/dev/zero of=/tmp/fileout bs=1M count-1024
The number of bytes written to the output file. The bs=1M designation in this command refers to the number of bytes written to the output file during the command's execution. The other options are not part of the dd command or its options.
Piping a command to the grep utility is a very common practice in Linux. What does grep do for a Linux user?
It searches for a string inside a file. The grep utility searches for a string within a file or a group of files. The split utility splits files into equally sized parts. The pr utility is one that prepares a file for printing. There are several archive utilities, such as tar, compress, and bzip2.
What does the following xz command do? xz -dq files.tar.xz
It uncompresses the compressed archives and suppresses errors. The xz -dq files.tar.xz command uncompresses the compressed archive and suppresses errors. The -q option is for -quiet (suppress errors), not quit. The -d means decompress. The -t option is used to perform an integrity check.
What are regular expression elements known as when used in a search string formed by wildcards, numbers, and characters?
Notational elements A regular expression with notational elements is a search string formed by combining wildcards, numbers, and characters.
Escaping a string of text or a single character involves doing what to the text or character?
Placing a \ in front of the text or character Escaping text or a character means that you have to place a leading \ so that the processing program will ignore it. For example, \Clever becomes lever, because the \ tells the program to ignore the next letter, which is C.
When using top, how does the root user filter the results to show only a single user's processes in the list?
Press the 'u' key and then enter the user name The root user presses the 'u' key and then enters the user name. The 'p' key has no effect. The 'I' key turns off Irix mode. The 'd' key changes the refresh delay from three seconds to a manually entered number.
How can a user overwrite multiple characters in vi?
R The R key is used to allow a user to overwrite an unlimited number of characters. The dd command deletes an entire line of text. The xx combination deletes two characters. The r command allows a user to overwrite a single character.
Which of the following ps command fields describes the physical memory in kilobytes (KB) used by a process?
RSS The RSS field is the amount of physical memory in KB used by a process. PRI is the priority. SIZE is the virtual image size. TT is the TTY or terminal associated with a process.
A user types 'ls' at the command line and receives the following information displayed on the screen: list.txt processes.txt blah.txt Which type of stream is the response from the ls command?
Standard output (stdout) The output from the ls command is stdout, or a screen display. There is no standard input to the ls command. The file list is the output from the ls command. There are no errors, so there is no stderr.
Which of the following is not a type of stream?
Standard transfer Standard transfer is NOT a stream type.
What happens if a user enters !6 on the command line?
The command at offset 6 will execute from the user's shell history. The command at offset position 6 will execute from the user's shell history. To execute the command from six lines back in the user's shell history, the user enters !-6.
An administrator issued the following command on a system. What is the administrator looking for by using this command? find / -size +10M -print
The administrator is looking for all files larger than 10 megabytes on the entire system. The administrator is searching for files larger than 10 megabytes on the entire system, from the root (/) directory. If the administrator wanted to find files by last accessed time, they would use the -atime option. To find files smaller than 10 megabytes, the administrator would use -10M. To find files in the administrator's home directory, they would search from /root, or . if they were in the home directory.
What happens if a user issues the bash command while using the bash shell?
The bash command opens another instance inside the current bash shell. The new bash shell opens within the current shell and looks identical to the original.
What does the following command do for the user who executed it? touch newfile.txt ; mv newfile.txt /tmp
The command creates the newfile.txt file and then moves it to the /tmp directory. The command creates the newfile.txt file and then moves it to the /tmp directory. The cat command displays a file's contents, and a user cannot rename a file to /tmp because it is a system directory name. The file command displays the type of file.
What is the expected output from the following command? find . -name "*.txt" -print
The command searches the current directory and displays a list of all files with a .txt ending. The find command lists all files in the current directory with a .txt ending. The -print option means print to the screen or stdout. The "*.txt" is a wildcard that gathers all files regardless of name or name length, as long as they have the .txt ending. The (.) after find means to search the current directory, which includes all subdirectories (a recursive search by default) of the current directory.
What happens if the following command is executed, but the destination directory (dir2) does not exist? cp -R dir1 dir2
The copy command creates the dir2 directory and recursively copies the contents of dir1 to it. The cp -R dir1 dir2 command copies dir1 and its contents to dir2. If dir2 does not exist, the copy command creates it.
What does the .gz file extension in a file name mean to a user?
The file has been compressed with gzip. The .gz extension means that the file has been compressed with gzip. Using tar copies files to a single file archive, but provides no extension. Files processed with dd have no particular extension. Files extracted with gunzip have the .gz extension removed from their names.
A user creates an executable shell script, file_list.sh, in their home directory and attempts to execute it by typing file_list.sh. They receive an error: file_list.sh: command not found. What is the problem?
The file is in their current directory, but the current directory is not in their path. The script is in the user's current directory and the current directory is not part of the default path. The extension has nothing to do with the file type in Linux.
How does a Linux system identify the init or systemd process?
The init or systemd process' process ID (PID) is always 1. The init or systemd process always has a PID of 1. The root user runs the init or systemd process and runs under root's UID and GID.
What does a job status of Stopped mean?
The job has been suspended. A stopped job has been suspended by the user. A stopped job can be restarted. A completed job has a status of Done. A terminated or killed job has a Terminated status.
How can a user determine which job was executed most recently?
The jobs table displays a (+) next to the job name. The jobs table displays a (+) next to the most recently executed job. All running jobs have a status of Running. There is no Current job status. The list order is not in the correct order of execution.
In a user's .profile file, there is an entry: TZ='America/Chicago' ; export TZ. What is the purpose of this line?
The line sets the TZ (time zone) variable to America/Chicago, and export TZ makes TZ an environment variable. (This line has two effects. The first is that it sets the TZ (time zone) variable to America/Chicago, and second, it exports the variable TZ so that it is an environment variable.)
A user searched their home directory for a file named history.doc using the locate command, but locate returned several files matching history.doc as if the user had used a wildcard, such as "*history.doc*" in the search. Why did locate return so many matches?
The locate command automatically wildcards all searches. The locate command uses wildcards at the beginning and at the end of a string. For example, a locate search for the file name of history results in a wildcard search as *history*.
What is the result of a user issuing the following command? ls -lR | tee list1.txt list2.txt list3.txt
The ls command's output displays to the screen and is written to all three files in its entirety. The ls command's output is shown on the screen and is copied, in its entirety, to each of the three files. The output is not split. Users can specify as many files as they want for the tee command and it will write to each of them.
If a user launches a new shell within a shell, what is the relationship of the new shell to the original shell?
The new shell is the child shell of the original or parent shell. The new shell is a child shell of the original or parent shell. The original shell does NOT pass its variables to the child shell.
What does the count option refer to when using the dd command?
The number of blocks written to the input or to the output file. The count, for example count=1024, is the number of blocks to be written to the output file or from the input file. There is no maximum output file size. The number of bytes transferred is specified by the bs parameter.
A user issues the command ls > files.txt, but sees no output on the screen. What happened to the output?
The output was redirected to the files.txt file. A simple redirect operation redirects the output to a file and not to the screen. The > operator is correct, and no errors were thrown because there were no errors to display.
While running top, a user presses the 'k' key on the keyboard. The entry pauses the dynamic update and it also prompts the user for information. For which information does top prompt the user?
The process ID (PID) to kill The 'k' prompts the user for 'PID to kill'. There are no options for sending processes to the background, to log out a user, or to restart a process.
What is the result of executing the following command? df -h | tee diskspace.txt
The result of the df command displays on the screen and is copied to the diskspace.txt file. The tee command displays its input to the screen and to the file specified in the command following it. This command is a pipe and not a redirect. Tee does not filter text. Tee takes the output from almost any command as input for itself and displays it on the screen and copies it into a specified file.
What is the significance of the leading dot in some file names, such as .bash_history, .profile, and .bashrc?
They are hidden from a standard file listing. (The leading dot (.) in a file name means that it is hidden from a standard directory listing. Files named with a leading dot are not necessarily executable or owned by the root user—as any user can create them and interact with them. )
Which of the following is equivalent to stdout?
The screen (Standard output or stdout is the screen. The keyboard is standard input. The mouse is part of standard input. The /dev/null designation is not a stream but a null device, kind of like a trash bin.)
Other than current time, running time, and currently logged on users, what information appears in uptime?
The system load average The uptime command also reports the load average for the system. The three numbers present the last 1 minute, 5 minutes, and 15 minutes load averages.
A user uses a sed command to convert the letter b to B in a file, but when the user looks at the file, there are no changes to it. What happened?
The user failed to redirect the converted output to a file. The user failed to redirect the converted output to a file. The sed command does not rewrite the file.
How does a user initiate a foreground process at the command line?
The user issues a command. To run a program in the foreground, the user simply issues the command. Unless the user places the command into the background with a trailing &, commands are always in the foreground.
How does a user turn a local variable into an environment variable?
The user must export the variable. (To turn a local variable into an environment variable, the user has to export the variable. The user-exported variable is not permanent if created in an interactive environment and will disappear upon logout.)
A user attempts to remove a directory and receives the following error: rmdir: failed to remove `dir1': Directory not empty. Explain the problem.
The user used the correct command, rmdir, to remove the directory; however, the directory is not empty and cannot be removed with rmdir. The rmdir command cannot remove a directory that contains files. Any user can execute the rmdir command. The -ignore-fail-on-non-empty option only suppresses the error, but does not remove the directory.
The vi and the vim editors are often known as simple editors because of which feature?
They use simple keystrokes to perform complex text editing tasks. The vi and vim editors are known as simple editors because they use simple and somewhat intuitive keystrokes to perform complex editing tasks.
What is the purpose of this statement: ps -ef >> processes.txt?
This statement appends process information to information already in processes.txt. The statement appends any information in the processes.txt file with current process information. The single operator > will create the file and overwrite any existing information. To send process information to a file and to the screen requires the tee command.
The rmdir command removes a directory, but which particular idiosyncrasy does the rmdir command have?
To be used successfully, the directory has to be empty To remove a directory with the rmdir command, the directory has to be empty. There are no -R or -f options for rmdir. There is no character limitation for directory names to be removed.
What is the primary function of the gzip command?
To compress archive files so that they consume less disk space The gzip command compresses files so that they consume less disk space. Files with the .gz suffix are already compressed. The tar command both archives and unarchives files. The tar command traditionally is used to send files to streaming tape for backup.
What are text filters sometimes used for?
To insert or remove headers Filters are shell scripts and are sometimes used to insert or remove headers. Passing text into a file is redirection. Reading data from a file is parsing. Executing one program after another is performed by using a semicolon between the commands.
What is the function of the J (uppercase j) command in vi?
To join the current line with the line below it The J command joins the current line with the line below it. To jump down five lines in a file, use the 5j command. There is no spell check in vi. The dG command deletes from the current cursor position to the end of the file.
What is the purpose of the 'g' in the following sed command? sed -e 's/b/B/g' file.txt
To make the substitution globally The 'g' means replace globally, or every occurrence of the letter b in the file with B, regardless of where in the line or in the word that it occurs.
Users and administrators both use regular expressions for which purpose?
To match strings based on a pattern While there are many different applications of regular expressions, the primary purpose of them is to match strings based on a pattern. Regular expressions often use wildcard characters, but that is not their overall purpose.
What is the function of the :w! command?
To write (save) the file and overwrite the permissions if the user has privileges to do so The :w! command writes or saves the file and overwrites the permissions if the user has privileges to do so.
How does a user search for a particular word or string in vi?
Use the / key, type the word, and press ENTER Use the / key, type in the word, and press ENTER. Typing jj will move the cursor down two lines, but not allow a search. The \n combination has no effect, because the \ is invalid in vi. The :e! command reverts to the last saved version of a file without closing the file.
How does a user or an administrator start a long-running task that might take longer than the automatic logout time limit for a system?
Use the nohup command and the & to place the task into the background The user or administrator uses the nohup command with a trailing &. The other options will not continue to run the task after the automatic logout, which is the point of the exercise. Using nohup plus the & will run the task to completion without user intervention.
Which two attributes does a process inherit from the user who starts the process?
User ID (UID) and group ID (GID) When a user starts a process, the process inherits the user's user ID and the user's group ID. The process is assigned a process ID from the system and has nothing to do with the user. The process does not inherit a user's home directory or the user's shell environment variables.
Other than using the nohup command, which other method exists to allow running commands after a user logs out of a system?
Using the screen command The screen command allows a user to run a process that might require multiple hours to complete, but still log out of the system. Using bg and fg will not allow a user to log out of a system and leave a process running. Using & will not allow a user to log out while running a process. Once a user logs out of a system, all shells and child shells die.
Which keyboard shortcut writes (saves) the current file and then quits vi?
ZZ ZZ writes and then quits vi. The dd command deletes a line. The yy command yanks (copies) a line. The gg command moves the cursor to the first line of the file.
What does the regular expression '.*' mean?
Zero or more of any number of characters in a row The .* regular expression means zero or more of any number of characters in a row.
A user notices that when using string matching with \w, no lines with spaces or special characters display in the results, although the user knows those types of lines exist. Which metacharacter matches lines with those types of characters?
\W The \W metacharacter will only match lines containing special characters and spaces. The \d metacharacter matches digits. The \s metacharacter matches lines only containing whitespace. The [w] is not a metacharacter, but a bracket expression that only matches lines containing a w.
A user wants to search the /etc/passwd file for a particular username, Bob Jones. Which command performs the search correctly?
cat /etc/passwd | grep "Bob Jones" cat /etc/passwd | grep "Bob Jones" is the correct option. First, the /etc/passwd is passed through cat to create a text stream and then piped into grep, which searches for the string, "Bob Jones". Grep cannot have output redirected into it. The ls command will not expose the contents of the file to grep.
Which of the following is the proper use of the grep command using regular expressions to isolate words at the end of a line or on a single line that have the 'arch' ending in their names?
cat file.txt | grep 'arch$' The cat file.txt | grep 'arch$' command is the correct one to isolate lines or words with the arch ending in their names or words that end in 'arch' that occur at the end of a line. The cat file.txt | grep [arch] command will return any file with one of the letters a, r, c, or h in it. The cat file.txt | grep arch command is a standard grep for a string that returns any line with the 'arch' pattern anywhere in the line. The cat file.txt |grep \arch command returns any line with the 'arch' pattern in it.
Which of the following grep commands performs a case insensitive search for the string alpha?
cat file.txt |grep -i alpha The cat file.txt |grep -i alpha command is the correct choice. The ls command does not expose file contents to grep. The grep -v option finds every string except alpha. The grep -c option will only return the number of times the string alpha occurs in the file.
A user wants to copy the contents of two files to a third file. Which command performs the task correctly?
cat one.txt two.txt > three.txt The cat one.txt two.txt > three.txt command will perform the desired task correctly. The file command reports the type of file that follows it. The cut command gives an error because it expects input to operate on.
Which cp command copies the /etc/passwd file to a backup location (/opt/bkup) only if the source is newer than the backup?
cp -u /etc/passwd /opt/bkup The cp -u /etc/passwd /opt/bkup command will copy the passwd file to /opt/bkup, but will not do so again until the original /etc/passwd file has been changed, regardless of how many times it is run. The cp /etc/passwd /opt/bkup command copies and overwrites the /opt/bkup/passwd file each time it is run. For this example, the -R option performs the same function as no option because there are no files or directories other than the passwd file to copy. The cp -b command creates a backup of the passwd file in each directory specified—in this example, the cp -b command creates /etc/passwd~ and /opt/bkup/passwd~.
Which of the following is the correct syntax to duplicate a file in the same directory?
cp file1.txt file2.txt The cp file1.txt file2.txt command is the correct command to duplicate a file. COPY is the DOS/Windows command line copy command. The file command describes the type of file. The mv command in this example renames the file.
Which of the following is NOT a correct method of using cpio?
cpio -ov > /opt/bkup/backup_Monday.cpio The cpio -ov > /opt/bkup/backup_Monday.cpio command is the incorrect choice. The cpio command must have input piped to it when creating an archive. The command cpio -idv < /opt/bkup/backup_Monday.cpio is correct because this command extracts files from the archive.
Which of the following commands does an administrator use with the ps -ef command to extract only the user account names running processes on a system?
cut The cut command using the output from ps -ef as input is used to isolate columns and fields of data. The split command splits files into two equal parts. The uniq command filters repeated instances or lines in a file or stream. The pr command converts a text file into a printable format.
Which command deletes the current line and the line above it in vi?
d- The d- command deletes the current line and the line above it. The dd command deletes the current line. 2dd deletes the current and the next line. The d$ command deletes from the cursor to the end of the line.
Which command deletes from the cursor position to the first occurrence of the letter 'b' in vi?
dfb The dfb command deletes all characters from the current cursor position to the first occurrence of the letter b in a sentence. This command works for any letter (dfc, dfd, dfe, etc.). The d$b command deletes to the end of the line; the b is ignored. The db command deletes the previous word. The dw command deletes the current word.
Which command does a user run to view the current PATH variable?
echo $PATH (The correct method to show just the PATH variable is to use echo $PATH. $PATH by itself is not a command. The echo PATH command will echo only the word PATH. There is no show command in Linux.)
Using the echo command, how can a user find which shell is currently in use?
echo $SHELL To find the current shell, use the echo $SHELL command. $SHELL is the environment shell variable. By itself, the echo command echoes a blank line. The echo /etc/passwd command echoes /etc/passwd, and the echo bash command echoes bash on the command line, but neither shows the shell.
Which command brings a program to the foreground that has been placed into the background?
fg The fg (foreground) command brings a program placed into the background into the foreground. The bg command can be used to place a program into the background. The kill command terminates a command whether in the foreground or in the background. The free command displays the amount of free memory in a system.
How does a user bring a background job (process) to the foreground?
fg %# A user brings a process to the foreground by issuing the fg %# command, where # is the job number found from issuing the jobs command. Ctrl+Z suspends a job. Ctrl+C kills a job. Using bg %# will send a job to the background.
Which command do Linux users usually pipe input from when using xargs?
find The output of the find command is used as a filter for xargs and then xargs is used to take some action, such as removing files, further filtering results, or to display results in a more convenient pattern.
A user remembers that they created a file with a four-character name with the .txt suffix. How can they search for files named with only four characters plus the .txt suffix?
find . -name "????.txt" -print The find command that lists only those files that have four-character names plus the .txt suffix is: find. -name "????.txt" -print. The wildcard *.txt command finds all files with the name pattern of .txt as the suffix. The command -size 4.txt gives an error for using an invalid size type. The search for "4.txt" yields files only named 4.txt.
A user created a document, but is unsure what they named it. They think the name is either "Heritage" or "heritage," but they also do not remember the extension or if it had one. Which command will find the file?
find . -name "[H,h]eritage*" -print The correct command to use is find. -name "[H,h]eritage*" -print. The find . -name "H-heritage*" -print command will find files named only H-heritage plus any suffix. The locate command uses regex filters, but only with the --regex option. The locate heritage command will only find the file heritage if it is named with a lowercase h.
A user wants to mail themselves the contents of a file they created on their Linux system. Which of the following commands accomplishes this task?
mail [email protected] < file.txt To mail the contents of any text file on the system that the user has access to, use: mail [email protected] < file.txt.
How does a user locate and display all directories within their home directory?
find . -type d -print The find command that lists all directories within a user's home directory is: find . -type d -print. The find . -dir * -print command gives an error because there is no -dir option. The ls -la command shows all files at the current level, including hidden files and directories, but no subdirectories. The ls -lR |grep drwx command will show all non-hidden directories and subdirectories.
Which of the following is the correct method for running the firefox application in the background?
firefox & firefox &. The correct method for running a command in the background is to issue the command with an & following it. Issuing the command with no & places the command into the foreground. Using the exec firefox command would start firefox, but kill the user shell. Using sleep prior to a command delays the start of the command by a number of seconds, but does not place the command into the background unless the command is followed by an &.
How does a user display the amount of free memory on a system in megabytes?
free -m The free -m command displays the amount of free memory in megabytes. The -M option is not a functional option. The -b option displays free memory in bytes. The -V option displays the free version.
Which command and option does a user issue to display the amount of free memory on a system continuously and refresh after a specific number of seconds (five)?
free -s 5 The free -s 5 command displays the amount of free memory updated every five seconds. None of the other options use the numeric input.
The egrep command is equivalent to which other command?
grep -E The egrep command is extended grep, which is equivalent to grep -E. The fgrep command is equivalent to grep -F. The pgrep command is used to grep for process IDs (PIDs) from running processes. The grep -R command is a recursive grep.
Which of the following commands is the equivalent of the gunzip files.tar.gz command?
gzip -d files.tar.gz The gunzip files.tar.gz command uncompresses the files.tar.gz file and renames it as files.tar. The equivalent command is gzip -d files.tar.gz. The gzip command compresses and uncompresses. It uncompresses with the -d (decompress) option. The tar command, tar zxvf files.tar.gz, will uncompress and untar (unarchive) the files back to the original files before archiving. The find command will locate the files.tar.gz file. The ls | cpio command will create a cpio archive named files.tar.gz; however, it cannot be uncompressed using gzip/gunzip because it is not the correct format.
Which command allows a user to view the first 10 lines of a file?
head The head command displays, by default, the first 10 lines of a file. Tail displays the last 10 lines of a file. The uniq command filters out repeated lines in a file. The cat command displays the entire contents of a file.
How does a user remove all command history?
history -c To successfully remove all command history, the user issues the history -c command. Using echo > .bash_history and rm .bash_history removes the history file's contents and the file respectively, but all the command history in memory is written to the file upon logout, including the attempts to remove the file and its contents. The history -d * has no effect, because the history command has no wildcard offset.
Which command does a user execute to delete the exit command out of the command history from the history command output below? 1 ls -la 2 ps -ef |more 3 who 4 history 5 rm file.txt 6 touch newfile 7 exit 8 logout
history -d 7 The command history -d 7 will remove the exit command from history. To remove a specific command, use the command's corresponding history position offset.
How does a user kill a process, for example, firefox, with the killall command?
killall firefox killall firefox. For killall to work correctly, all a user needs is to issue killall and the name of the process. The killall command cannot use the process ID.
A user wants to create a list of every file in their home directory and save it to a file named homefiles.txt. Which of the following commands accomplishes this?
ls -aR > homefiles.txt The command that creates a complete list of all files in the user's home directory and saves it to the homefiles.txt file is: ls -aR > homefiles.txt. The -a option lists all files, and the -R option lists files recursively. The ls -la command will list files in the current directory only. The ls command will list non-hidden files only. The locate command will list every file in the mlocate database that the user has access to.
Which ls command produced the following output? -rw-r--r-- 1 root root 3042 Feb 16 20:47 passwd
ls -l The ls -l command provides the user with a long listing of directory contents displaying permissions, file name, file ownership, size, and last modified date and time. The ls -a command displays a list of all files, including hidden ones. The ls -s command displays a list of files by size and with file sizes. The ls -r command lists files in reverse alphabetical order.
Which ls command displays a list of files in the reverse order of when they were last modified? In other words, how does a user list files with the most recently changed files at the bottom of the list?
ls -ltr The ls -ltr command provides a long list, by modification time, in reverse order. The ls -r command lists files in reverse alphabetical order. The ls -lt command displays a long list sorted by modification time, newest first. And ls -t just displays the list by modification time, newest first.
Which of the following is NOT an acceptable method of using multiple pipes with the grep utility?
ls /etc/passwd | grep bash | grep -i fred The incorrect command is: ls /etc/passwd | grep bash | grep -i fred.
Which of the following creates the cpio archive, files.cpio, from a list of files?
ls | cpio -ov > /opt/bkup/files.cpio ls | cpio -ov > /opt/bkup/files.cpio. The cpio command creates archives by having some file listing piped to it. There are several methods of generating output from which to pipe into cpio, but typically ls or find are used to generate the list of files for its input. None of the other options have input piped into cpio; therefore, none of them work.
What information is in the files.txt file if a user issues the following command and the files do not exist? ls FY2014.txt 2> files.txt ; ls FY2015.txt 2> files.txt ; ls FY2016.txt 2> files.txt
ls: cannot access FY2016.txt: No such file or directory. The only entry in the files.txt file is: ls: cannot access FY2016.txt: No such file or directory. The reason is that the user used 2>, which overwrites the files.txt file every time the user issues the command.
What information is in the files.txt file if a user issues the following command and the files do not exist? ls FY2014.txt 2> files.txt ; ls FY2015.txt 2>> files.txt ; ls FY2016.txt 2>> files.txt
ls: cannot access FY2016.txt: No such file or directory. ls: cannot access FY2015.txt: No such file or directory. ls: cannot access FY2014.txt: No such file or directory. The correct answer is: ls: cannot access FY2016.txt: No such file or directory. ls: cannot access FY2015.txt: No such file or directory. ls: cannot access FY2014.txt: No such file or directory. All three ls command error outputs are sent to the files.txt file because the initial ls used 2>, which creates or overwrites the files.txt file, and the subsequent ls commands use 2>>, which appends their error output to the files.txt file.
A user attempts to list the file FiscalYear2015.txt with the command ls FiscalYear2015.txt 2> files.txt. The user receives no output on the screen. What information is in the files.txt file?
ls: cannot access FiscalYear2015.txt: No such file or directory. The output from standard error (stderr), ls: cannot access FiscalYear2015.txt: No such file or directory, was redirected into the files.txt file by the command. The file does not exist and therefore there is no standard output (stdout) to display.
How does a user execute a command that is in the user's path, for example the /usr/bin/lynx command?
lynx The user enters the lynx command without any pathing. The ./lynx command will not work, because lynx is not in the user's current directory. The man lynx command opens the man page for lynx, but will not execute the lynx application. The echo lynx command will only display the word lynx.
Which of the following would NOT match the egrep command's search? egrep 'ton\b' file.txt
monotone The egrep 'ton\b' file.txt will match all except monotone, because the 'ton\b' matches the string at the end of the word.
Which command successfully moves an entire directory and its contents to another directory?
mv dir1 dir2 The mv dir1 dir2 command moves dir1 into the dir2 directory. The -i option is interactive and will prompt for any overwrites. The -v option means verbose, which shows the user that the directory was moved. The option that includes rm dir1 is not necessary, because the mv command performs this function for the user.
Which of the following commands renames the file one.txt to once.txt?
mv one.txt once.txt To rename a file, use the mv command: mv one.txt once.txt. The cp command copies the file. REN is the DOS/Windows rename command. The rm command removes (deletes) both files.
Which of the following nice commands does NOT change the execution priority of the test.sh command to a value of 10?
nice --10 test.sh The option --10 raises the priority to -10, whereas the other options lower the priority to 10.
What is the output of the command sed s/two/nine/ numbers.txt on the contents of numbers.txt below? numbers.txt: one two three
one nine three The command sed s/two/nine/ numbers.txt replaces all instances of the string two with the string nine.
A user has a file, list.txt, with the following contents: one one two three four four five If the user cats the file and passes it through uniq (cat list.txt | uniq), what will be the output?
one two three four five The uniq command filters out all repeated lines; therefore, the duplicate one and duplicate four would be removed to give the following as output: one two three four five
Which of the following is NOT a method for isolating a single process on a system?
ps -e The ps -e command lists every command currently running on the system. It is not a method of isolating a single process.
How does a user display the process table for all users on a system?
ps -ef The ps -ef command displays all processes in full format. This is the standard method of displaying the process table. The ps, ps -a, and ps -af commands show processes triggered only by the user who issues the ps command.
Which of the following ps commands provides all user processes, user names, start times, and processes without a terminal associated with them? Hint: This is a very common ps command with options on all Linux and UNIX-like operating systems.
ps aux The ps aux command is a comprehensive ps command with options that provide for all user processes, user names, start times, and processes without a terminal. The ps -ef command lists all processes with full format details. The ps -T command excludes processes that were started by any terminal other than the current one. The ps -u command lists processes with the current user and start times.
How does a user run multiple commands on a single line, for example, run pwd and then run uname on the same line?
pwd ; uname The proper method of executing multiple separate commands on a single line is: pwd ; uname. Separate the commands using a semicolon. The | operator will not work, because pwd's output is incorrect for uname input and uname accepts no input. Neither the colon nor the comma is a proper command line operator.
Which key does a user type in command mode to overwrite a single character in vi?
r The r key allows a user to type over a character after the command is issued. The R key allows a user to overwrite an unlimited number of characters. The x deletes one character. The d key deletes a line or a character after a navigation key has been pressed.
Which command does an administrator use to change the priority of a running process?
renice The renice command changes the priority of a process. The ps command lists processes. The chage command changes a user's password expiration. The nice command alters the priority of a program at launch, but not while it is running.
Which command removes all files and directories under the current directory?
rm -rf * The rm -rf * command removes all files and directories in the current directory. This is an extremely dangerous command to run, especially for the root user, and its effects are irreversible. The rm * and rm *.* commands remove all visible files but not directories or hidden files in the current directory. The rm .* command removes all hidden files in the current directory.
Which of the following commands successfully removes a directory, dir1, and all its contents?
rm -rf dir1 The command rm -rf dir1 recursively removes dir1 and all files contained in it. The -f option is to force without prompting. The rmdir dir1 command will not remove a directory that includes files. The rm dir1 command will not remove a directory, empty or not. RD dir1 is the DOS/Windows command for removing a directory.
How does a user correctly delete the file, file.txt from the user's home directory?
rm file.txt The correct method of deleting a file is rm file.txt. DEL is the DOS/Windows delete command. Copying a file to /dev/null does not delete file.txt, but does send a copy of it to /dev/null. The rm command cannot accept a text stream.
Which of the following is known as the stream editor command?
sed Sed is the streams editor command. Vi is the visual editor. Split is a command that splits files into two equal parts. Fmt formats text to a specific width.
Which command allows a user to edit a file without opening the file with an interactive editor program?
sed The sed command is the stream editor and it allows a user to edit files without opening them in an editor. The grep commands only search for strings, but cannot edit.
If the regular expression to convert lowercase letters to uppercase is: sed 's/./\U&/g' file.txt, then what is the regular expression for converting uppercase letters to lowercase letters using the sed command?
sed 's/./\L&/g' file.txt The sed 's/./\L&/g' file.txt command converts all uppercase letters to lowercase in file.txt. The sed 's/./\u/g' file.txt command converts all lowercase letters to uppercase the same as \U. The other options replace letters with the substitution string.
Which of the following commands includes both a pipe and a filter?
sort /etc/passwd |grep 50 The sort /etc/passwd |grep 50 command first filters the command with sort and then pipes it using grep 50. The other three options are redirects. Cat and nl are filter commands.
Which command will break the file processes.txt, containing 182 lines of text, into four files?
split -l 50 processes.txt The split -l 50 processes.txt command will split the processes.txt file into four files, splitting at 50 lines. The -l option tells the split command how many lines maximum should be in each file split. Three files will have 50 lines, and the fourth file will have 42 lines. The -l 4 option will split the file into 46 files, the -l 25 option will split the file into eight files, and the -l 91 option splits the file into two files. previous
An administrator wants to find the most recent errors in a log file. Which command allows the administrator to do this?
tail The tail command shows the most recent additions to a file that are always appended at the end of the file. The head command shows the first (oldest) entries in a file, which does not help the administrator identify the most recent errors. The wc command is a word count command and does not display the lines themselves. The od, or octal dump, file displays the contents of a file after it has been converted to octal format, which is not helpful to the administrator.
Which of the following is NOT a method of finding the number of lines in a file, list.txt?
tail list.txt The tail list.txt command displays the last 10 lines of the file, but does not give the user any indication of the number of lines in the file.
Which command combines files in such a way that they are packaged into a single file for convenient archiving purposes?
tar The tar, or tape archive, command collects a defined group of files and places them into a single file that makes it easy to transfer and archive those files. The cat command displays the contents of a file. The file command identifies the type of file. The find command locates a file or files based on search criteria.
A user receives a file named documents.tar.gz and asks a system administrator to help open the file to extract the individual documents from it. Which command does the administrator use to do this?
tar zxvf documents.tar.gz For documents.tar.gz, which is gzipped and tarred, use tar zxvf documents.tar.gz to extract the documents from the compressed archive. The gunzip command only uncompresses the file, but does not extract the documents from it. The expand and unexpand commands are for removing and adding TABs in a file and will not extract files from an archive.
Which of the following is NOT a method to terminate or kill a process?
terminate <PID> There is no terminate command in Linux.
Which of the following commands creates an empty file with the name file.txt?
touch file.txt The touch file.txt command creates the empty file.txt file. The mkdir file.txt command creates a directory named file.txt. The file file.txt command identifies the type of file that file.txt is, if it exists. The cp file.txt command gives an error because there is no target.
How does an administrator display the kernel version on a running system?
uname -r The uname -r command displays the kernel version. There is no kernel or version command. The whoami command displays the username of the currently logged on user.
Which command displays the length of time a system has been running since the last reboot?
uptime The uptime command provides the length of time a system has been running since the last reboot. The free command displays free memory. The ps aux command displays a process table. Screen is a utility that multiplexes between several processes.
In most Linux distributions, instead of the traditional vi editor, which editor are users actually editing files with when they type vi file.txt?
vim In Linux, the traditional vi editor has been replaced with vim (vi improved). Nano, gedit, and emacs are all alternatives to the vi(m) editor.
Which command line operator accepts the output from one command and pipes it into the next command as input?
| The | (or pipe) takes output from one command and pipes it into the next command as input. For example, cat file.txt | wc -l. This command first displays the contents of file.txt and pipes that content into the wc (word count) command as input. The -l option gives the number of lines in the file.txt file.