CompTIA LINUX+ Flashcards
Which of the following commands will open the mainlist. txt text file in a command-line text editor?
a) cd mainlist.txt
b) rm mainlist.txt
c) gedit mainlist.txt
d) vi mainlist.txt
d
Which command will modify the date and time stamp of an existing file?
a) ls {hfx,tor}??
b) file [Bb}*201[4-5]
c) touch [a-z] [a-z] [a-z] 0?
c
Which command will allow you to replace the string red with the string blue in a text file without being asked for confirmation?
a) :%s /red/blue
b) :%c /red/blue/s
c) :%s /red/blue/c
a
You used to vi to open a text file and now you want to edit it. What options represent the keys you can press that will allow you to actually edit the contents?
a) a
b) i
c) v
d) w
a and b
Write the command to compress every file contained in the /images directory using the fastest compression command.
gzip -r /images
Which statement best describes the purpose of the tee command?
a) It allows you to send the output of a query to another query
b) It allows you to print query results
c) It allows you to write standard output to the screen and additional locations
c
Write the command that would return any files owned by the emclampett that are in the /images directory.
find /images -user emclampett
Complete the code to use the cpio command to extract the files from /images.cpio and place them in the same directory, recreating any required subdirectories.
-id < /images.cpio
Complete the command that will add the /images directory to the PATH variable
PATH=$PATH:/images
Complete the code to recursively copy all files in the current directory to the /backup001 directory. Make sure the code also returns what files have been copied.
-Rv
You want to search cheese.txt for instances of string blue, but you don’t want the search to be case sensitive.
a) -c
b) -i
c) -v
b
You’ve opened a text file using vi and now you want to search for instances of the string mark. As mark can be a verb as well as a name you want to make your search case insensitive. Which option will perform this query?
a) \MaRk/
b) /mark\c
c) \mark/c
b
Write the command that will copy all subdirectories recursively in /images in the backup folder /imgbak.
cp -r /images /imgbak
What command will return the value of the variable PATH in the shell?
a) echo $PATH
b) grep -vPATH
c) | | PATH
a
Which operator could you use to mimic an IF statement on the command line?
a) ||
b) |
c) grep
a
Which option will return all files including hidden ones?
a) lS -a ~
b) ls -a ~
c) ls-ls ~
b
Which statement about piping of output is accurate?
a) Only one piping request can be made per query
b) Piped output must be stored in a variable before it can be used
c) Piping is accessed using the | symbol
c
Which command will allow you to reopen a file without saving any changes?
a) :w!
b) :q
c) :e!
c
You’ve run history command in the bash shell and now you want to execute the command listed 39th. Which option will do this?
a) ~/39
b) !39
c) 39_history
b
Which options will return the contents of the variable myVar?
a) echo $MYVAR
b) echo $myVAR
c) cat &myVAR
b
Which command will remove files and directories recursively from /images without prompting for confirmation before removing each file?
a) rm -rvi /budgets
b) rm - rv /images
c) rm rv-i /budgets
b
Using gedit as your text editor, complete the query to search the snacks directory and open the files inside.
find/ home/snacks/*.txt | _______
xargs gedit