Linux Midterm Exam (Ch. 6 - 11)
What option for the ls command will display all files, including hidden files?
-a
Which flag would you pass to tar in order to have it make a new archive?
-c
Which option for the cut command is used to specify a delimiter?
-d
Which option for the cut command is used to specify the field?
-f
Which option for the ls command, when used in conjunction with the -l option, will display human-readable sizes?
-h
Which option can be used with the rm command to prompt before deleting?
-i
Which option(s) can be used to prevent cp from overwriting an existing file?
-i
Which option for the wc command will print the number of lines in a file?
-l
Which option(s) can be used to prevent cp from overwriting an existing file?
-n
Which of the following is the valid device file name for the first IDE hard drive on the system?
/dev/hda
To make changes permanent for kernel parameter files found under /proc/sys, the following file can have entries added to it:
/etc/sysctl.conf
The Linux kernel mounts the following pseudo-filesystems to provide access to information about hardware devices connected to the system: (choose two)
/proc
Which file contains the information passed to the kernel at boot time?
/proc/cmdline
The Linux kernel mounts the following pseudo-filesystems to provide access to information about hardware devices connected to the system: (choose two)
/sys
Which of the following are valid CPU types for Intel-based platforms? (choose two)
32 bit
Most of nano's commands take the form of:
Control and another character
The three main modes of tar are: (choose three)
Create
The touch command can be used to:
Create new files
What does this shell script do? FOO=/tmp/foo if [ ! -d $FOO ]; then mkdir $FOO fi
Creates /tmp/foo if it does not exist
Which of the following are valid video cable connector types? (choose two)
DVI
The three main modes of tar are: (choose three)
Extract
(T/F) A load average of 1.0 always means the system is fully loaded.
False
(T/F) All log files contain only text data.
False
(T/F) The command echo "text" > file.txt will not overwrite file.txt if it already exists.
False
(T/F) The ls command colour codes results by default.
False
In the command tar -cvjf foo.tbz a b c, what are a, b, and c?
File names to be added to the archive
The following are valid Linux option styles: (choose three)
GNU long options with two dashes (--)
Which of the following are valid partitioning types? (choose two)
GPT
The first character in a long listing (ls -l) indicates:
If something is a file, directory, or symbolic link
Lossy compression (Choose 3, but question is split)
Is often used with images
The echo command:
Is used to output text to the console
Given the following part of a script: if [ -f $1 ]; then echo "I am here" fi What is the meaning of $1?
It is a special variable that indicates the exit code of the command before it
The three main modes of tar are: (choose three)
List
Which of the following are valid partitioning types? (choose two)
MBR
The free command outputs statistics about:
Memory usage
Given the command tar -cvjf homedirs.tbz /home, which of the following are true? (choose two)
The command will print out each filename as it is processed
Given the command tar -cvjf homedirs.tbz /home, which of the following are true? (choose two)
The output file will be compressed
Which command displays information from SMBIOS?
dmidecode
Which of the following are package management commands for distributions with software distributed in files ending in .deb? (choose three)
dpkg
Which of the following commands scans the file to determine file locations?
find
Which of the following commands can be used to scroll through a text file? (choose two)
less
Given a file called documents.zip, how can you extract just the files under ProjectX?
unzip documents.zip ProjectX/*
The _____ command is normally executed daily to update the database of all files that are on the system.
updatedb
Which are appropriate editors for writing shell scripts? (choose two)
vi
Which of the following are correct about for and while loops? (choose two)
while loops have a test each cycle to determine if it should run again
Which of the following are package management commands for distributions with software distributed in files ending in .rpm? (choose three)
yum
Which of the following are package management commands for distributions with software distributed in files ending in .rpm? (choose three)
yumex
Which of the following commands can be used to compress a file? (choose three)
zip
Which of the following commands will create a zipfile with the contents of your Documents directory?
zip -r mydocs.zip Documents
Which option of the head command will display only the first five lines of a file?
-n 5
Which option for the wc command will print the total number of words in a file?
-w
A CPU flag...
...defines the features that the CPU supports
The ls command without options or arguments...
...lists the contents of the current directory
The command rm -r will...
...remove a directory along with any files or subdirectories
A pipe allows you to...
...send the output of one command to another
The grep command...
...will display all the lines in a file containing the specified Regular Expression.
The top-level directory on a Linux system is represented as:
/
What directory typically contains log files?
/var/log
The if command looks for what exit code to consider a condition to be true?
0 (zero)
The Process ID (PID) of the init process is:
1
The following system load averages are displayed by the top command: (choose three)
1 minute
What is the meaning of $(( $i + 1 ))?
1 will be added to the i variable
What is the meaning of $(( $i + 1))?
1 will be added to the i variable
The following system load averages are displayed by the top command: (choose three)
15 minutes
The following system load averages are displayed by the top command: (choose three)
5 minutes
Which of the following are valid CPU types for Intel-based platforms? (choose two)
64 bit
In general, for which of the following would you want to use lossless compression?
A log file
Hidden files are files that begin with what character?
A period (.)
The tilde (~) is used to represent:
A user's home directory
What is the correct way to assign the word "Hello" to a variable?
A="Hello"
What is the correct way to save the current directory to a variable?
A=`pwd`
Is the following path absolute or relative? /etc/ppp
Absolute
The following are valid Linux option styles: (choose three)
BSD Unix without a dash
The command ls -S will sort files:
By size, largest to smallest
Given the following script that is run through ./test.sh hello goodbye if [ -f $2 ]; then echo "I am here" fi
If a file called "goodbye" exists in the current directory
Given the following script: while [ ! -f /tmp/foo ]; do echo -n "." process_data > /tmp/foo done Which of the following are true? (choose two)
If a file called /tmp/foo exists, process_data won't be run
Which of the following are common busing systems? (choose two)
PCI
What does the acronym RPM mean?
RPM Package Management
Is the following path absolute or relative? ../../home/sysadmin
Relative
Is the following path absolute or relative? sysadmin/Documents
Relative
Compression on a file works by:
Removing redundant information
A file begins with #!/bin/csh. This means:
Running the script will invoke /bin/csh to interpret the rest of the file
Channel 2 is:
STDERR
Error messages generated by commands are sent where by default?
STDERR
Lossy compression (Choose 3, but question is split)
Sacrifices some quality
In the command tar -czf foo.tar.gz bar, what is the purpose of the f flag?
Tells tar to write to the file that follows the flag
Given the command tar -cvjf homedirs.tbz /home, which of the following are true? (choose two)
The command will print out each filename as it is processed
The double dot (..) can be used with the cd command to represent:
The directory above the current working directory
You try to compress a file that is already compressed. Which of the following statements is true?
The file will not be compressed any further than it already was
Given the command tar -cvjf homedirs.tbz /home, which of the following are true? (choose two)
The output file will be compressed
What information is held inside $? ?
The previous command's exit code
The following are valid Linux option styles: (choose three)
Traditional Unix with a single dash (-)
(T/F) 64 bit platforms can access more memory than 32 bit platforms.
True
(T/F) A successful command will print output to STDOUT.
True
(T/F) One way to install new software on a Linux system is to use a package management system.
True
(T/F) The /proc directory contains a subdirectory for each process present on the system.
True
(T/F) The command echo "text" >>file.txt will not overwrite file.txt if it already exists.
True
(T/F) The command echo "text" > file.txt will create file.txt if it does not already exist.
True
(T/F) The command echo "text" >> file.txt will not overwrite file.txt if it already exists.
True
(T/F) The fdisk command is a tool used for working with the MBR partitioned disks.
True
(T/F) The find command can search for files based on the size of the file.
True
(T/F) The grep command can be used with glob characters.
True
(T/F) The ls command color coded results by default.
True
(T/F) The process (ps) command shows only processes running in the current shell by default.
True
(T/F) The rm command can delete multiple files at once.
True
(T/F) When using the cp command, you must provide both a source and a destination.
True
(T/F) When you execute the dmesg command, the system displays messages that are generated by the kernel.
True
Which of the following are common busing systems? (choose two)
USB
The touch command can be used to:
Update the time stamp of existing files
Lossy compression (Choose 3, but question is split)
Usually results better compression than lossless
Which of the following are valid video cable connector types? (choose two)
VGA
Choose all of the following statements that are true in regard to virtual RAM: (choose three)
Virtual RAM is also called swap space
Choose all of the following statements that are true in regard to virtual RAM: (choose three)
Virtual RAM is stored on a hard drive
Choose all of the following statements that are true in regard to virtual RAM: (choose three)
Virtual RAM is used when available physical RAM is low.
The cd command by itself will take you to what directory?
Your home directory
Which of the following commands will prevent any aliased options to the ls command?
\ls
Which of the following are package management commands for distributions with software distributed in files ending in .deb? (choose three)
apt-get
Which of the following are package management commands for distributions with software distributed in files ending in .deb? (choose three)
aptitude
Which of the following commands will display CPU information? (choose three)
arch
Which of the following commands can be used to compress a file? (choose three)
bzip2
A conditional that lets you make multiple comparisons with a pattern is called:
case
Which of the following commands will display CPU information? (choose three)
cat /proc/cpuinfo
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen? (choose two)
cat list.file | sort
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen? (Choose 2)
cat list.file | sort
What command will allow you to change your current working directory?
cd
Which of the following commands can be used to access the home directory of the user "bob" while logged in as root? (choose two)
cd /home/bob
Which of the following commands can be used to access the home directory of the user "bob" while logged in as root? (choose two)
cd ~bob
Which of the following commands will append its output to output.file?
echo Testing >> output.file
Which of the following commands will display lines that contain either start or end?
egrep 'start|end' file.txt
How would you finish your script with an exit code of 42?
exit 42
Which of the following are correct about for and while loops? (choose two)
for loops operate over a fixed list of items
Which of the following commands will display only lines that begin with start?
grep ^start file.txt
Which of the following commands will display only lines that begin with test?
grep ^test file.txt
Which of the following commands can be used to compress a file? (choose three)
gzip
How would you obtain output similar to the following? compressed uncompressed ratio uncompressed_name 278168 1016950 72.6% tags
gzip -I tags
How would you obtain output similar to the following? compressed uncompressed ratio uncompressed_name 278168 1016950 72.6% tags
gzip -l tags
Which of the following commands will direct error messages to the file, error.log?
ls /root 2> error.log
Which of the following commands will display CPU information? (choose three)
lscpu
Which of the following commands can be used to scroll through a text file? (choose two)
more
Which of the following commands can be used to rename a file?
mv
You type gzip myfile.tar. What happens? (Choose 2)
myfile.tar is removed
You type gzip myfile.tar. What happens? (Choose 2)
myfile.tar.gz holds a compressed version of myfile.tar
Which are appropriate editors for writing shell scripts? (choose two)
nano
Which command can be used to print line numbers?
nl
A division of a hard drive may be referred to as a _______ . (choose two)
partition
A division of a hard drive may be referred to as a _________.
partition
Given the following script: while [ ! -f /tmp/foo ]; do echo -n "." process_data > /tmp/foo done Which of the following are true? (choose two)
process_data will be called at most once
Which shell command accepts input from the user's keyboard?
read
Which of the following are package management commands for distributions with software distributed in files ending in .rpm? (choose three)
rpm
To get a list of all packages installed on a system using RPM Package Management you can execute:
rpm -qa
Which log file contains messages regarding authentication and authorization?
secure
A division of a hard drive may be referred to as a _______ . (choose two)
slice
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen? (choose two)
sort < list.file
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen? (Choose 2)
sort < list.file
Which two commands do the same thing? (choose two)
tar -c foo | gzip > foo.tar.gz
Which command would you use to archive the Documents directory and compress it with bzip2 compression?
tar -cjf documents.tbz Documents
Which two commands do the same thing? (choose two)
tar -czf foo.tar.gz foo
Which command will show what is inside the compressed tarball with a name of foo.tar.gz?
tar -tzf foo.tar.gz
You archived your users' directories into a file called backup.tar.gz. You then view the archive and see the filenames follow this convention: home/username/somefile
tar -xzf backup.tar.gz home/fred
The number of users logged in is in a variable called USERS. How would you test to see if 5 users are logged in?
test $USERS -eq 5
How would you write a test that says "if /tmp/foo is a directory or USERS is greater than 5"?
test -d /tmp/foo -o $USERS -gt 5
A command that will continuously update statistics about running processes:
top
Given a file called documents.zip, how can you see what's in it without extracting the files?
unzip -l documents.zip