Exploring Linux Filesystems (review questions) - [LINUX System Administration]
If a user's current directory is /home/mary/project1, which command could she use to move to the etc directory directly under the root?
cd /etc
A special device file is used to ___________.
represent hardware devices such as hard disk drives and ports
Which command would a user type on the command line to find out the current directory in the directory tree?
pwd
Mike has changed directory into one subdirectory after the next and has lost track of where he's at in the directory tree. Which of the following commands can he use to tell him the full path to the current subdirectory he is in?
pwd (The pwd command stands for present working directory)
What will typing q! at the : prompt in command mode do when using the vi editor?
quit without saving any changes
Which of the following is an absolute pathname? (Choose all that apply.)
/home/resume
Chase is trying to extract records for employees 423 through 428 out of a comma separated values file and store them in another one. Which of the following commands would accomplish this? (Choose all that apply.)
1. cat employees.csv | grep "42[3-8]" > employees-newhires.csv 2. grep "42[3-8]" employees.csv > employees-newhires.csv 3. grep "42[3-8]" < employees.csv > employees-newhires.csv (1. This command will use the cat command to send the contents of the employees.csv file to the grep command to filter the results. The -E option isn't required as the square brackets are part of common regular expressions, not extended regular expressions. 2. The grep command doesn't require the -E option as the square brackets are part of common regular expressions, not extended regular expressions. 3. The less than sign isn't required to have grep use it as input, but it is a valid syntax.)
The vi editor can function in which two of the following modes? (Choose both that apply.)
1. command 2. insert
Jo has received a text file which contains multiple instances of his name spelled correctly as well as multiple instances spelled as Joe. Which of the following commands would search a text file for any occurrences of either spelling and display them out to the terminal? (Choose three.)
1. grep -E "Joe?" document1.txt 2. grep "Joe*" document1.txt 3. grep -E "Joe*" document1.txt (1. The grep command must have the -E specified in order to use a question mark, which is considered part of an extended regular expression. 2. The grep command can use an asterisk to match zero or more instances of the previous character. As the asterisk is used for common regular expressions, the -E is not necessary, although it will also work with a -E. 3. Although the -E is not necessary, the asterisk will return all instances where the string contains Jo as well as zero or more of the letter e.)
Which of the following commands will not interpret regular expressions, which translates into faster results being returned? (Choose all that apply.)
1. grep -F 2. fgrep (1. The grep -F command is the same as the fgrep command which is used to match fixed strings rather than a pattern using regular expressions. 2. The fgrep command is the same as the grep -F command which is used to match fixed strings rather than a patter using regular expressions.)
When using the vi text editor, which of the following keys, when in command mode, will change to insert mode and place the cursor at the end of the current line?
A (A capital A will change to insert mode and move to the end of the current line to append new text.)
The less command offers less functionality than the more command. True or False?
False
When using the vi text editor, which of the following keys, when in command mode, will move to the last line in the document?
G (A capital G will move the cursor to the last line in the document.)
Linux has only one root directory per directory tree. True or False?
True
After typing the ls -a command, you notice a file whose filename begins with a dot ( . ). What does this mean?
It is a hidden file.
After typing the ls -F command, you notice a filename that ends with an * (asterisk) character. What does this mean?
It is an executable file.
How can a user switch from insert mode to command mode when using the vi editor?
Press the Esc key.
How can you specify a text pattern that must be at the beginning of a line of text using a regular expression?
Precede the string with a ^.
A directory is a type of file. True or False?
True
Using wildcard metacharacters, how can you indicate a character that is not an a or b or c or d?
[!a-d]
A user typed in the command pwd and saw the output: /home/jim/sales/pending. How could that user navigate to the /home/jim directory?
cd ../..
Kate wants to compare two text files to identify what might have been changed from one version to another. Which of the following commands can she use to do this?
diff document1.txt document2.txt (The diff command will compare the contents of two text files.)
The tac command _________.
displays the contents of a file in reverse order last line first and first line last.
What will the following wildcard regular expression return: file[a-c]?
filea, fileb, filec
Garrett wants to search through a csv file to find all rows that have either the name John or Bob in them and display them out to the terminal. Which of the following commands could Garrett use to perform this search?
grep -E "(John|Bob)" salesemployees.csv (The grep command has a -E option that specifies that it should use extended regular expressions. When used inside parentheses and the pipe symbol, you can search for lines that contain either John or Bob. The pipe symbol is commonly used as an OR operator.)
If "resume" is the name of a file in the home directory off the root of the filesystem and your present working directory is home, what is the relative name for the file named resume?
resume
Which command searches for and displays any text contents of a binary file?
strings
A user types the command head /poems/mary. What will be displayed on the terminal screen?
the first 10 lines of the file mary