Part I: CompTIA Linux+/LPIC-1
When setting the shebang line of a shell script, which of the following commands will help to determine the location of the interpreter automatically?
#!/usr/bin/env bash
Which variable within a Bash script is used to access the first command-line parameter?
$1
Which sequence of characters will execute two commands but only if the first command exits successfully?
&&
Which character sequence is used to provide a default case when used within a case statement in a shell script?
*)
When working with a SysV system, which chkconfig option will display all services and their runlevels?
--list
Which option to Bash will cause the shell to be executed without reading the initialization files?
--norc
Which option added to yumdownloader will also download dependencies?
--resolve
Which option to the modprobe command shows the dependencies for a given module?
--show-depends
You have attempted to stop a process using its service command and also using the kill command. Which signal can be sent to the process using the kill command in order to force the process to end?
-9
Which options to fsck can be used to check all filesystems listed in /etc/fstab while excluding the root partition?
-AM
Which kill signal can be sent in order to restart a process?
-HUP
Which option to chgrp will change group ownership of all files within a given directory?
-R
Which option to chown recursively changes the ownership?
-R
Which option to the cp command will copy directories in a recursive manner?
-R
Which option to umask will display the permissions to be used in a POSIX format?
-S
Which rpm option can be used to verify that no files have been altered since installation?
-V
Which option to the mount command will mount all filesystems that are currently available in /etc/fstab?
-a
Which option to the dumpe2fs command can be used to display blocks that are reserved because of being marked as bad?
-b
Which option to quotacheck is used to create the files for the first time?
-c
Which of the following tests will determine if a file exists in the context of a shell script?
-e
Which option to xfs_metadump displays a progress indicator?
-g
Which option to both mv and cp will cause the command to prompt before overwriting files that already exist?
-i
Which option to the find command will search for files by their inode number?
-inum
Which options for an rpm command will display verbose output for an installation along with progress of the installation?
-ivh - The -ivh options will install a file using rpm, displaying both verbose output and hash marks for progress. The other options presented do not exist or do not accomplish the specified task.
Which option for the wc command prints the number of lines given as input?
-l
Which options to ls will produce output, including hidden (dot) files, in a list that is ordered such that the newest files are at the end of the output?
-latr
Which test within a shell script while loop will examine one value to see if it is less than another?
-lt
What option is used to change the number of lines of output for the head and tail commands?
-n
Which option to lspci is used to display both numeric codes and device names?
-nn
Which option for the grub-mkconfig command sends output to a file instead of STDOUT?
-o
Which option to declare statements displays output in a way that could then be used as input to another command?
-p
Which of the following tests will determine if a file exists and can be read by the user executing the test?
-r
Which option to the declare command will create a variable that is read-only?
-r
Which option to umount will cause the command to attempt to remount the filesystem in read-only mode if the unmounting process fails?
-r
Which option to ln creates a symlink to another file?
-s
Which option to rmmod will cause the module to wait until it's no longer in use to unload the module?
-w
When running fsck on an ext3 filesystem, the process is taking longer than expected and requiring input from the administrator to fix issues. What option could be added to fsck next time so that the command will automatically attempt to fix errors without intervention?
-y
What is the order in which user configuration files are located on login to a Bash shell?
.bash_profile, .bash_login, .profile
Within which partition will the EFI system partition typically be mounted?
/boot/efi
Which device is typically connected as the first floppy disk?
/dev/fd0
A Serial ATA (SATA) disk will use which of the following identifiers?
/dev/sdX
A hard drive is reported as hd(0,0) by the GRUB Legacy configuration file. To which of the following disks and partitions does this correspond?
/dev/sda1
Within which file are details of the current package repositories stored on a Debian system?
/etc/apt/sources.list
You need a command to be executed on logout for all users. Within which file should this be placed (assume that all users are using Bash)?
/etc/bash.bash_logout
Which file should you edit when using GRUB 2 in order to set things like the timeout?
/etc/default/grub
Which file contains information about the filesystems to mount, their partitions, and the options that should be used to mount them?
/etc/fstab
When working with hotplug devices, what is the location of scripts that are executed when a given device is inserted into the computer?
/etc/hotplug/usb
On a system using SysVinit, in which directory are startup and shutdown scripts for services stored?
/etc/init.d
Which of the following is not typically used to store libraries?
/etc/lib
Which file contains information on currently mounted filesystems, including their mount options?
/etc/mtab
You need to create a function that will be available each time that you log in to the system. Within which file should this function be placed?
/etc/profile
Within which directory should you place files to have them automatically copied to a user's home directory when the user is created?
/etc/templateuser
Configuration of udev devices is done by working with files in which directory?
/etc/udev
Within which directory will you find the repositories used by YUM?
/etc/yum.repos.d
Within which folder are systemd unit configuration files stored?
/lib/systemd/system
According to the FHS, what is the proper mount point for removable media?
/media
Which of the following best describes the /proc filesystem?
/proc contains information on currently running processes, including the kernel.
Within which directory is information about USB devices stored?
/proc/bus/usb
What is the location of the home directory for the root user?
/root
According to the FHS, what is the correct location for site-specific data for a server?
/srv
Which partition or directory structure typically holds most of the programs for a Linux system?
/usr - The /usr hierarchy contains many of the programs that run on a Linux system. Other notable directories for programs are /bin and /sbin.
When partitioning a disk for a mail server running Postfix, which partition/mounted directory should be the largest in order to allow for mail storage?
/var
If the kernel ring buffer has been overwritten, within which file can you look to find boot messages?
/var/log/dmesg
The umask command reports the mask as 022. What is the permission that will be in effect for a newly non-executable created file?
022
What is the default number of lines printed by the head and tail commands, respectively?
10 for both head and tail
When working in the Bash shell, you need to redirect both stdout and stderr. Which of the following commands will redirect both stdout and stderr?
2>&1
How many SCSI devices are supported per bus?
7 to 15
Which partition type should be created for a Linux system non-swap partition?
83
You are using the vi editor for changing a file and need to exit. You receive a notice indicating "No write since last change." Assuming that you want to save your work, which of the following commands will save your work and exit vi?
:wq
Which of the following represents the correct format for the /etc/fstab file?
<device> <directory> <type> <options> <dump> <fsck>
You're working with a large file in vi, and you need to search for instances of a string earlier in the file. Which key will search backward in the file?
?
Which of the following creates an array in a bash script?
ARRAY=(val1 val2)
Of the following choices, which size would be most appropriate for the /boot partition of a Linux system?
Between 100 MB and 500 MB
Which of the following is a good first troubleshooting step when a hard disk is not detected by the Linux kernel?
Check the system BIOS.
Assume that you have a variable called $FILEPATH within a Bash shell script. Which characters can be used to ensure that the variable will be interpolated correctly regardless of where the variable appears within the script?
Curly braces ${FILEPATH}
Which of the following commands will obtain the date in seconds since the epoch and place it into a variable called DATE within a shell script?
DATE="$(date +%s)"
Which of the following commands will delete all data from a table called virtualusers in MySQL on Linux?
DELETE FROM virtualusers;
Which of the following commands displays the columns and column types within a given table?
DESC
Which key combination will enable you to edit the kernel options and then boot when using GRUB Legacy?
E for editing and then B to boot
Which option within a systemd service file indicates the program to execute?
ExecStart
What is the maximum number of primary partitions available on an MBR partitioning system?
Four
The presence of menu.lst within the filesystem typically indicates which condition?
GRUB Legacy is in use on the system.
Assuming a menu entry of "Debian" in your GRUB configuration, which option in /etc/default/grub would set that as the default operating system to boot?
GRUB_DEFAULT
Which option within /etc/default/grub is used to configure the default operating system for boot?
GRUB_DEFAULT
Which environment variable is used when changing directory with the tilde character, such as cd ~ ?
HOME
A drive connected to USB will be considered to be which type of device?
Hotplug
Assume a MySQL table called AUTHENTICATION has three columns (id, username, password). Which of the following statements inserts a row into the table?
INSERT INTO AUTHENTICATION (username,password) VALUES ('user','pass');
When found in a GRUB configuration file, what does the ro option indicate?
Initially mount the root partition as read-only
Which type of join will be used in SQL when you see a statement such as table1.id = table2.id?
Inner
Which explanation best describes the following, gathered with the ls -la command? lrwxrwxrwx. 1 root root 35 Jul 8 2014 .fetchmailrc -> .configs/fetchmail/.fetchmailrc
It is a file called .fetchmailrc, which is linked using a symbolic link.
When using ls -la to obtain a directory listing, you see an object with permissions of lrwxrwxrwx. What type of object is this?
It is a symlink.
When working with partitions on disk, you see the type 0x82. Which type of partition is this?
Linux swap - 0x82 is Linux swap while 0x83 is Linux. NTFS is 0x07 and FAT32 is 0.0c.
Assume that you are retrieving data from a MySQL database and need the data to be displayed in ascending numeric order based on a column called "id". Which of the following commands added to the SELECT statement accomplishes this task?
ORDER BY id ASC;
Which option in /etc/updatedb.conf will remove a path from inclusion in the results?
PRUNEPATHS
Which of the following best describes the PS1 environment variable?
PS1 is used to define the default shell prompt for Bash.
What characters are used to mark a sequence of commands as a function within a shell script?
Parentheses to declare the function (optional) and curly braces to contain the commands
What is the logical order for creation of an LVM logical volume?
Physical volume creation, volume group creation, logical volume creation
When using Bash, how would you execute the last command starting with a certain string, even if that command was not the last one that you typed?
Precede the command with ! and then the string to search for.
During the initialization process for a Linux system using SysVinit, which runlevel corresponds to single-user mode?
Runlevel 1
You have connected a USB disk to the system and need to find out its connection point within the system. Which of the following is the best method for accomplishing this task?
Running dmesg and looking for the disk
Which of the following SQL keywords can be used with a GROUP BY clause?
SELECT
When querying a database, which of the following SQL statements retrieves all data from a table called users?
SELECT * FROM users;
When using rpm2cpio, by default, the output is sent to which location?
STDOUT
During boot of a system with GRUB, which key can be pressed to display the GRUB menu?
Shift
Which characters are used to denote the beginning and end of the test portion of a while loop in a shell script?
Square brackets [ ]
What is one reason why a device driver does not appear in the output of lsmod, even though the device is loaded and working properly?
Support for the device has been compiled directly into the kernel.
Which of the following is true of Linux swap space?
Swap is used as additional memory when there is insufficient RAM.
Which environment variable can be set if you wish to log users out of their shell automatically after a certain period of inactivity?
TMOUT
What is the default delimiter used by the cut command?
Tab
A legacy PATA disk is used to boot the system. You recently added an internal DVD drive to the computer, and now the system will no longer boot. What is the most likely cause?
The BIOS has identified the DVD drive as the first disk, and therefore the system can no longer find the Linux partition(s).
A command has the following listing obtained with ls -la: -rwsr-xr-x 1 suehring suehring 21 Nov 2 13:53 script.sh What does the s denote within the user permissions in the listing?
The SUID bit has been set for this program.
What will be the result if the touch command is executed on a file that already exists?
The access timestamp of the file will change to the current time when the touch command is executed.
Which sequence is used to mark the beginning and end of the commands to execute within a for loop in a shell script?
The keywords do and done
During the boot process, what is the next step after the kernel has taken over the initialization process and initializes devices?
The root partition is mounted. - The root partition is mounted after device initialization. System services, including multi-user mode, start after the root partition is mounted. The other two options, A and C, take place prior to the kernel initializing device drivers.
Which of the following represents the correct syntax for a SQL UPDATE statement?
UPDATE <table> SET <column> = <newvalue> WHERE <column> = <value>
After you insert a new hard drive into the system, what is the correct order to make the drive ready for use within Linux?
Use fdisk to create partitions, then format the partitions with something like mkfs, and then mount the partitions.
Another administrator made a change to one of the local scripts used for administrative purposes. The change was also immediately reflected in your copy of the script. However, when examining the file with ls, it appears to be a normal file. What is the likely cause of such a scenario?
Your file is a hard link to the original.
Which of the following commands ensures that the -la options are used when the ls command is executed without other options?
alias ls="ls -la"
Which command will search for a package named zsh on a Debian system?
apt-cache search zsh
Which of the following commands updates the package cache for a Debian system?
apt-get update
Which command and option are used to update a Debian system to the latest software?
apt-get upgrade
Which of the Debian package management tools provides a terminal-based interface for management?
aptitude
Which of the following commands is used to identify the UUID for partitions?
blkid
Which option within gdisk will change the partition name?
c
Which of the following commands will provide the usernames in a sorted list gathered from the /etc/passwd file?
cat /etc/passwd | awk -F: '{print $1}' | sort
Which of the following commands will send the contents of /etc/passwd to both stdout and a file called passwordfile?
cat /etc/passwd | tee passwordfile
Which command enables you to view the current IRQ assignments?
cat /proc/interrupts
Which of the following commands will correctly change the group ownership of the file called a.out to users?
chgrp users a.out
You need to enable the web server (running as the www-data user and group) to write into a directory called /home/webfiles. Which commands will accomplish this task in the most secure manner?
chgrp www-data /home/webfiles; chmod 775 /home/webfiles
When sourcing a file in Bash, which chmod command would be necessary to provide the minimum privileges in order for the file to be sourced correctly, assuming that your current user owns the file?
chmod 400
Which of the following commands enables the sticky bit for a user on a file called homescript.sh?
chmod u+s homescript.sh
Which command will create an image of the /dev/sda1 disk partition and place that image into a file called output.img?
dd if=/dev/sda1 of=output.img
The SAN has crashed and one of the filesystems in a Linux server has become significantly corrupt as a result. Which command and option can be used to attempt to examine the contents of the drive without causing more damage?
debugfs -c
Your GRUB Legacy configuration includes a dual-boot option with Linux listed first and another operating system listed second. Which of the following options will boot to the Linux partition by default?
default=0 - GRUB begins its count at 0, and in this scenario there are two operating systems. Therefore, because Linux is first in the configuration file, its number would be 0, which is then sent to the default= option.
Which yum option displays the dependencies for the package specified?
deplist - The deplist option displays the dependencies for the given package. The list option displays information about a specific package, while the other two options are not valid.
Which of the following commands shows the usage of inodes across all filesystems?
df -i
Which command can be used to view the kernel ring buffer in order to troubleshoot the boot process?
dmesg
Which of the following installs a previously downloaded Debian package?
dpkg -i <package name>
Which command searches for and provides information on a given package on a Debian system, including whether or not the package is currently installed?
dpkg -s
Which command should be used to make changes to the choices made when a Debian package was installed?
dpkg-reconfigure
The system is running out of disk space within the home directory partition and quotas have not been enabled. Which command can you use to determine the directories that might contain large files?
du
When creating a shell script, which of the following commands is used to display the contents of variables?
echo
Which of the following egrep commands will examine /etc/passwd to find users who are using either /bin/bash or /usr/bin/zsh for their shell environment?
egrep '/*/.?sh$' /etc/passwd
Which keyword(s) is/are used to begin an alternate condition within a Bash script?
elif
Which option of the systemctl command will change a service so that it runs on the next boot of the system?
enable
What command can be used to view the current settings for your environment when using Bash?
env
Which of the following commands removes an environment variable that has been set?
env -u
When using a case statement within a shell script, which sequence denotes the ending of the case/switch statement?
esac
Which option in /etc/yum.conf is used to ensure that the kernel is not updated when the system is updated?
exclude=kernel*
Which of the following commands will execute a script and then exit the shell?
exec
Which of the following commands adds /usr/local/lib to the LD_LIBRARY_PATH when using Bash shell?
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Which of the following describes a primary difference between ext2 and ext3 filesystems?
ext3 includes journaling for the filesystem.
What command is used to bring a command to foreground processing after it has been backgrounded with an &?
fg
Which of the following provides the end for an if conditional in a Bash script?
fi
You have received a file that does not have a file extension. Which command can you run to help determine what type of file it might be?
file
Which command will find directories with names beginning with 2014 located beneath the current directory?
find ./ -type d -name "2014*"
Which find command will locate files within the current directory that have been modified within the last 24 hours?
find ./ -type f -mtime 1
Which of the following commands searches each user's .bash_history file to determine if the user has invoked the sudo command?
find /home -name ".bash_history" | xargs grep sudo
Assuming that a space-separated list of values has been defined as such LIST="one two three four", which of the following for loop constructs will iterate through the elements in the list?
for VAR in $LIST
Users are reporting that various programs are crashing on the server. When examining logs, you see that certain processes are reporting out-of-memory conditions. Which command can you use to see the overall memory usage, including available swap space?
free
Which option in /etc/fstab sets the order in which the device is checked at boot time?
fsck
When using sed for a substitution operation, which option must be included so that the substitution applies to the entire line rather than just the first instance?
g
Which of the following commands installs GRUB into the MBR of the second SATA disk?
grub-install /dev/sdb
Which command should be run after making a change to the /etc/default/grub file?
grub-mkconfig
Which of the following commands will initiate an immediate shutdown of the system?
halt
Which of the following commands will display the last 50 lines of your command history when using Bash, including commands from the current session?
history 50
Which command can be used to reboot a system?
init 6
Which command on a system controlled by Upstart will reload the configuration files?
initctl reload
Which option given to a yum command will install a given package?
install
You have backgrounded several tasks using &. Which command can be used to view the current list of running tasks that have been backgrounded?
jobs
Which command can be used to kill all processes by using their name?
killall
Which command is used to update the links and cache for shared libraries on the system?
ldconfig
Which command is used to determine the libraries on which a given command depends?
ldd
The system on which you're working recently had a hard drive failure. A new hard drive has been installed, and it has had Linux restored from backup to the drive. However, the system will not boot and instead shows a grub > prompt. Within the grub > prompt, which command will show the current partitions as seen by GRUB?
ls
Which command can be used to obtain a list of currently loaded kernel modules?
lsmod
Which command is used to obtain a list of USB devices?
lsusb
Which command will retrieve information about the USB connections on a computer in a tree-like format?
lsusb -t
Which command is used to create a logical volume with LVM?
lvcreate
Which command is used to search for physical volumes for use with LVM?
lvmdiskscan
Which command is used to access documentation on a Linux computer for a given command?
man
Which option to the man command accesses a different level of documentation, for example, system call documentation?
man 2 <argument>
The current hierarchy on the server contains a directory called /usr/local. You need to create additional directories below that called /usr/local/test/october. Which command will accomplish this task?
mkdir -p /usr/local/test/october
Which of the following commands will create a btrfs filesystem on the first SATA drive?
mkfs.btrfs /dev/sda
Which command is used to format a swap partition?
mkswap
Which command is used to load a module and its dependencies automatically?
modprobe
Which of the following commands will mount a USB device at /dev/sdb1 into the /media/usb directory, assuming a VFAT filesystem for the USB drive?
mount -t vfat /dev/sdb1 /media/usb
Assuming that a USB disk contains a single partition and is made available on /dev/sdb, which command mounts the disk in /media/usb?
mount /dev/sdb1 /media/usb
Which command will move all files with a .txt extension to the /tmp directory?
mv *.txt /tmp
Which command can be run to determine the default priority for processes spawned by the current user?
nice
You are debugging a configuration file and the daemon indicates there is a problem on line 932. Which of the following commands will prepend line numbers onto the file?
nl
Which option within a partition mounting command will cause the partition to be mounted in such a way as to prevent execution of programs?
noexec
When editing with vi, which command changes into insert mode and opens a new line below the current cursor location?
o
Which command can be used to change the partitioning scheme for a disk, such as to change the size of existing partitions without deleting them?
parted
You need to write a script that gathers all of the process IDs for all instances of Apache running on the system. Which of the following commands will accomplish this task?
pgrep apache
Which of the following commands initializes a physical disk partition for use with LVM?
pvcreate
Which command prints your current directory?
pwd
Which command is used to execute a check of user quotas on the filesystem?
quotacheck -u
Which command is used to enable quotas on a filesystem that has been previously set up for quota usage?
quotaon
Which command within a shell script awaits user input and places that input into a variable?
read
Which shell built-in command is used to display a list of read-only variables?
readonly
Which command and option will output a summary of quota usage across all filesystems that are currently read-write with quotas enabled?
repquota -a
You are attempting to use rmdir to remove a directory, but there are still multiple files and other directories contained within it. Assuming that you're sure you want to remove the directory and all of its contents, what are the command and arguments needed to remove the directory and all of its contents
rm -rf
Which option can be added to a GRUB configuration line to set or change the root partition at boot time to /dev/sda2?
root=/dev/sda2
Which option within GRUB Legacy is used to indicate that a root partition contains a non-Linux kernel?
rootnoverify
Which command option for rpm can be used to show the version of the kernel?
rpm -q kernel
Which command displays the current runlevel for a system?
runlevel
You need to start a long-running process that requires a terminal and foreground processing. However, you cannot leave your terminal window open due to security restrictions. Which command will enable you to start the process and return at a later time to continue the session?
screen
Which option for yum performs a search of the package cache?
search
Which of the following commands will print a list of six numbers beginning at 0?
seq 0 1 5
Assume that you're using the Bash shell and want to prevent output redirects from accidentally overwriting existing files. Which command and option can be used to invoke this behavior?
set -C
Which option given at boot time within the GRUB configuration will boot the system into single-user mode?
single
Assume that you have a file called zips.txt that contains several postal zip codes, and you need to determine how many unique zip codes there are in the file. Which of the following commands can be used for that purpose?
sort zips.txt | uniq -c
Which command is used to read and execute commands from a file in the Bash shell?
source
What is the command to display the default target on a computer running systemd?
systemctl get-default
Which command on a systemd-controlled system would place the system into single-user mode?
systemctl isolate resuce.target
Which command is used with systemd in order to list the available service units?
systemctl list-units
Which command and option can be used to determine whether a given service is currently loaded?
systemctl status
Which command will watch the Apache log at /var/log/httpd/access.log and continually scroll as new log entries are created?
tail -f /var/log/httpd/access.log
Which of the following will unzip and extract the contents of a file that has been tarred and gzipped?
tar -zxf <file.tgz>
Which command would you use if you make changes to the /etc/inittab file and want those changes to be reloaded without a reboot?
telinit
Which of the following command lines would monitor a single process called nagios in a continuous manner?
top -p'pidof nagios'
When using the test built-in with one argument, what will be the return if its argument is not null?
true
Which command and option are used to set the maximum number of times that a filesystem can be mounted between running fsck?
tune2fs -c
You are using a SAN (storage area network) that keeps causing errors on your Linux system due to an improper kernel module created by the SAN vendor. When the SAN sends updates, it causes the filesystem to be mounted as read-only. Which command and option can you use to change the behavior of the filesystem to account for the SAN bug?
tune2fs -e continue
Which command and option are used to display the number of times that a filesystem has been mounted?
tune2fs -h
Which shell built-in command can be used to determine what command will be run?
type
The system is using a temporary flash USB disk for data mounted at /dev/sda1. You need to remove the disk. Which of the following commands will enable the disk to be safely removed from the system?
umount /dev/sda1
Which of the following commands removes a currently defined aliased command?
unalias
Which of the following commands will print various information about the kernel and architecture, along with other details?
uname -a
Which command will output a new GRUB 2 configuration file and send the output to the correct location for booting?
update-grub > /boot/grub/grub.cfg
The locate command is reporting out-of-date information. Which command should be run in order to have the locate command update its database?
updatedb
Which command can be used to determine the current load average along with information on the amount of time since the last boot of the system?
uptime
Which option is set on a filesystem in order to enable user-level quotas?
usrquota
Which command can you use to send a message to all users who are currently logged into a system?
wall
Which of the following commands can be used if you need to locate various elements of a given command, such as its binaries and man pages?
whereis
Which command can be used to determine the location of a given executable that would be run if typed from your current environment and location?
which
The xfs_info command is functionally equivalent to which command and option?
xfs_growfs -n
You receive a file with a .lzma extension. Which command can you use to decompress this file?
xz
Which command can be used to download an RPM package without installing it?
yumdownloader
Which character sequence denotes an alternate command to execute if the preceding command does not exit successfully?
||