Print
Category: Answers
Hits: 622

LPIC 101-500 & LPIC 102-500
>>Practice Exam #2
Answers with explanation

 

 Take the test here (You need an account. It's free)

1.    To which file should you add an entry in order for a host to be blocked using TCP wrappers?
A.    /etc/hosts.deny
B.    /etc/tcp.wrappers
C.    /etc/wrap.config
D.    /etc/tcpwrap.conf

 A. The /etc/hosts.deny file is part of TCP wrappers along with /etc/hosts.allow. Both provide a basic mechanism for configuration of access from remote hosts to network services.


2.    Which of the following commands creates an alias for the ps command such that the options auwx are included when the user types psa?
A.    alias "ps auwx" = "psa"
B.    alias psa=ps uawx
C.    alias psa="ps auwx"
D.    psa="ps auwx"

 C. The alias command uses the alias name followed by an equal sign followed by the command to be aliased. In this case, because the command to be aliased contains spaces, it needs to be contained in quotation marks.


3.    Which of the following conditionals in a Bash script will test if the variable DAY is equal to SUNDAY?
A.    if ($DAY == "SUNDAY")
B.    if ($DAY -eq "SUNDAY")
C.    if [[ $DAY == "SUNDAY" ]]
D.    if [ DAY = "SUNDAY" ]

 C. Shell scripting syntax uses the format shown, with square brackets around the condition to the tested and double-equal signs for a string test. Variables are preceded by a dollar sign as shown.


4.    Which of the following commands is necessary for making a variable defined in your current shell available to child processes?
A.    export
B.    source
C.    let
D.    def

 A. The export command is necessary so that any variables that are manually defined in your current session become available to child processes. The source command executes the file and can be used for the purpose described but requires an additional argument. The let and def commands are not valid.


5.     You are watching another administrator perform some work on a server. As part of that work, the admin uses the following command: .var.sh Which of the following is the equivalent of .var.sh?
A.   let var.sh
B.    set var.sh
C.    source var.sh
D.    var var.sh

C. The source command is the functional equivalent of a single dot (.). The set command exists but is not used for this purpose. The other commands are not valid.

6.    Which of the following commands adds ~/code/bin to the path?
A.    PATH=~/code/bin:$PATH
B.    PATH=/code/bin:$PATH
C.    PATH=/home/code/bin:$PATH
D.    PATH=PATH:~/code/bin

 A. The syntax for setting the PATH separates the new path with a colon, as shown in the correct option. A primary difference between the correct and incorrect options for this question was in how the actual specified path was shown.


7.      Which of the following shows a valid Bash function called greetings?
A.    function greetings () { echo "hello"; }
B.    function greetings{}
C.    function greetings() { echo Hello }
D.    function greetings() { echo Hello } ;

A. The correct syntax is as shown. Note that a semicolon is required when the commands are included on one line, as displayed in the answer.


8.    Which of the following commands sends an email to root with the subject of Update and the content of the /etc/hostname file?
A.    mail root > /etc/hostname
B.    mail -s Update root > /etc/hostname
C.    mail -s Update root < /etc/hostname
D.    mail root -s Update /etc/hostname

 C. The mail command with -s for the subject is necessary, followed by the email address for the mail. Then, input is redirected to the mail command using /etc/hostname.


9.    Files that should be copied to a user’s home directory when their account is created should be placed in which of the following directories?
A.    /etc/usertemplate
B.    /etc/template
C.    /etc/skel
D.    /etc/userskel

 C. The /etc/skel directory contains files that are a skeleton of a user’s home directory when their account is created. The other directories listed do not exist by default.


10.    Which of the following areas within an Ubuntu system contains information and settings for accessibility?
A.    Accessibility
B.    Access and Help
C.    Universal Use
D.    Universal Access

 D. The Universal Access section, which can be found by typing Universal Access from within an Ubuntu GUI interface, enables configuration of accessibility options.


11.    Which command can be used to set the delay and repeat rate for a keyboard?
A.    keyboard
B.    kbdrate
C.    kbd
D.    keyrate

 B. The kbdrate command is used for the purpose described and can help with accessibility. The other commands shown are not valid.


12.    Which variable is used to indicate the screen on which GUI applications will be shown?
A.    DISPLAY
B.    SCREEN
C.    LIST
D.    XWIN

 A. The DISPLAY variable controls the destination and screen for displaying GUI applications. Setting this variable facilitates forwarding of X applications over ssh.


13.    Users can be added or removed for access to the X server. Which command facilitates this?
A.    xauthorization
B.    xhost
C.    xwin
D.    xconnect

 B. The xhost command is used to control who can make connections for both users and hosts to a given X server. The other commands are not valid.


14.    Which option to useradd sets the number of days between password expiration and when the account is disabled?
A.    -n
B.    -f
C.    -e
D.    -g

 B. The -f option sets the days between expiration and disabled for an account. The -g option is used to set the group ID, whereas -e is used to set the overall expiration date.


15.    Which of the following commands displays the current mail aliases known on the server?
A.    getent aliases
B.    getalias
C.    listalias
D.    mail aliases

 A. The getent command can be used for the purpose described and will display the aliases on the server by examining the aliases database. The other commands are not valid and, in the case of the mail command shown, will simply attempt to send mail to an address known as aliases.


16.    Which of the following configuration lines in /etc/hosts. deny creates a deny-by-default policy where clients will need to be specifically allowed in /etc/hosts. aiiow?
A.    * *    
B.    All:    *
C.    ALL:    ALL
D.    LOC:    ALL

 C. The ALL: ALL syntax will cause all hosts to be denied. This means that you must explicitly authorize hosts and networks using /etc/hosts.allow.


17.    Which of the following describes the result of running the atq command as root?
A.    The current cron and at jobs for root will be listed.
B.    The current at jobs for all users will be listed.
C.    The current cron and at jobs for all users will be listed.
D.    The last 10 entries in the at log will be shown.

     B. The current at jobs for all users are shown when atq is executed as superuser.


18.    Which command option can be used to remove all cron jobs for a given user using the crontab command?
A.    -d
B.    -e
C.    -r
D.    -l

 C. The -r option to the crontab command removes all cron entries for a given user. The -l option lists cron jobs, whereas the -e option edits the crontab. There is no -d option.


19.    Which option to the crontab command enables you to work with a different user’s cron jobs?
A.    -u
B.    -m
C.    -d
D.    -e

 A. The -u option specifies the user. The -l option lists the cron jobs and -e edits them. There is no -d or -m option.


20.    When deleting a user from the server, you need to maintain their home directory rather than deleting it. Which option of the following commands deletes the user <username> but preserves their home directory?
A.    userdel <username>
B.    userdel -r <username>
C.    userdel -h <username>
D.    userdel -p <username>

 A. The userdel command, given no other options, does not delete the home directory. When given the - r option, the command will delete the home directory and mail spool file. There is no -h or -p option for the userdel command.


21.    After deleting a group, you need to search the filesystem for files owned by the group using its group ID. Which option to the find command will search using the group ID?
A.    -name
B.    -group
C.    -groupid
D.    -gid

     D. The -gid option is used to specify group ownership for the find command. The -group option does exist, but since the question specified that the group had already been deleted, the gid must be used instead. There is a -name option, but it searches by name and not group ID.


22.    Which of the following commands changes the group name from admins to serveradmins?
A.    groupmod -g admins serveradmins
B.    groupmod -n serveradmins admins
C.    groupchg -n serveradmins admins
D.    groupchg admins -n serveradmins

 B. The groupmod command will be used for this purpose, and the -n option followed by the new group name is used to change the name. There is no groupchg command.


23.    Which command is used to parse log file entries on a systemd-based system?
A.    logger
B.    journalentry
C.    jrnctl
D.    journalctl

 D. The journaictl command is used to view and parse log file entries on systemd-based systems that maintain logs in a special format. The logger command can be used to create log entries, and the other commands shown do not exist.


24.    Which option to the ntpdate command configures the version to use such that an older Network Time Protocol (NTP) server could be queried?
A.    -o
B.    -v
C.    -e
D.    -r

 A. The -o option followed by either 1 or 2 enables ntpdate compatibility with older NTP servers. The default, when no -o option is specified, is version 3. The -v option tells ntpdate to be verbose, whereas the -e option sets the authentication timeout.


25.    Within which directory are systemd journals stored by default?
A.    /var/log/systemd
B.    /var/systemd/journal
C.    /var/log/journald
D.    /var/log/journal

 D. The /var/log/journal directory is used to store Journal log files for systemd-based systems. The other directories do not exist by default.


26.    Which option to the logrotate command specifies the mailer to use?
A.    -o
B.    -s
C.    -m
D.    -v

 C. The -m option sets the mail program to use when mailing logs. It is set to /usr/bin/mail -s by default. There is no -o option, and -v is verbose. The -s option to the logrotate command sets the state file to use.


27.    Which option to date changes the output to Coordinated Universal Time (UTC) regardless of the current time zone?
A.    -u
B.    -t
C.    -s
D.    -v

 A. The -u option configures the output to UTC regardless of the time zone. The -s option sets the time, and there is no -v or -t option.


28.    Which of the following commands can be used to delete a print job on a system that uses the lp print system?
A.    lpdel
B.    rmprint
C.    rm -print
D.    lprm

 D. The lprm command is used to remove print Jobs on a system that uses the ip system for printing. There is no lpdel or rmprint command. There is an rm command, but it’s not used for working with print queues.


29.    Which of the following subnet masks represents a /23?
A.    255.255.255.0
B.    255.255.0.0
C.    255.255.255.255
D.    255.255.254.0

 D. The 255.255.254.0 subnet mask is equivalent to /23. The 255.255.255.0 subnet mask is /24. The subnet mask 255.255.255.255 is /32, and 255.255.0.0 is /16.


30.    An entry in /etc/nsswitch.conf indicates hosts: files dns. In which order will /etc/hosts be queried for a hostname lookup?
A.    The /etc/hosts file will be examined first.
B.    The /etc/hosts file is not related to hostname lookup.
C.    The /etc/hosts file will be queried second.
D.    The /etc/hosts file will be queried last.

 A. The /etc/hosts file will be examined first, and then a Domain Name System (DNS) query will be sent based on the configuration shown.


31.    Which port needs to be allowed through the firewall for standard Lightweight Directory Access Protocol (LDAP) traffic to be received by the server?
A.    TCP port 25
B.    TCP port 443
C.    TCP port 143
D.    TCP port 389

 D. Standard LDAP traffic is TCP port 389 on the server. TCP port 25 is SMTP, 443 is HTTPS, and 143 is IMAP.


32.    Which option to ssh changes the username to use for logging in to the server?
A.    -v
B.    -i
C.    -l
D.    -u

 C. The -i option to ssh changes the username sent for authentication. This can be useful for scripting scenarios where the @ notation cannot be used. The -v option is verbose mode, and -i is the identity file to use. There is no -u option.


33.    Which option to ping disables name resolution?
A.    -d
B.    -D
C.    -f
D.    -n

 D. The -n option disables name resolution for addresses involved in the ping request/reply. The -D option returns a time stamp, whereas -d sets the SO_DEBUG option. Finally, -f is a flood ping.


34.    Which of the following commands shows various statistics for a network interface such as packets and bytes received and transmitted along with errors and other such conditions?
A.    ifconfig
B.    ifstat
C.    if -s
D.    ifcond

 A. The ifconfig command shows various statistics about the interfaces on a Linux system, including whether the interface is up or down, its packets and bytes, queue length, and other information. The other commands listed do not exist.


35.    When using the host command, which option displays the Start of Authority (SOA) record from each of the authoritative DNS name servers for the given domain?
A.    -N
B.    -n
C.    -c
D.    -a

 C. The -c option shows the SOA for each of the DNS name servers listed as authoritative for the domain. The - a option sends an ANY query, whereas -N sets the number of dots for the domain to be considered absolute. There is no -n option.


36.    You need to specify an additional localhost address and hostname for a server in order to support a specialized network configuration. Which line in /etc/hosts sets the hostname with a unique IP address in the correct range for localhost?
A.    127.0.1.1 host.example.com host
B.    192.168.0.1 host.example.com host
C.    host.example.com 127.0.0.1
D.    host.example.com 172.16.31.32

 A. The entire 127.0.0.0/8 range is available for local host addresses. Therefore, an answer would need to be in this range. The proper format for /etc/hosts is IP address followed by name, followed by optional aliases, which makes option A correct.


37.    Which of the following options to ifup tells the command to ignore errors and continue?
A.    -continue
B.    -c
C.    -ignore-errors
D.    -h

 C. The -ignore-errors option tells ifup to continue even if there are otherwise fatal errors. The -h option outputs help. There is no -c or -continue option.


38.    Which option to passwd can be used to unlock an account that was locked with the passwd command?
A.    -s
B.    -l
C.    -u
D.    -w

 C. The -u option unlocks an account that was locked using the -l option. The -w option sets the warn days, and -S prints the status.


39.    Which of the following is the correct syntax to connect using ssh to host. example. com on port 2200?
A.    ssh -l 2200 host.example.com
B.    ssh host;example.com
C.    ssh host.example.com:2200
D.    ssh host:2200 -d example.com

 C. When connecting to an alternate port, you can use the -p option to set the port or use a colon to separate the host from the port.


40.    Which option in /etc/sudoers sets the destination address for administrative and security emails related to sudo?
A.    mail
B.    mailto
C.    secmail
D.    adminmail

 B. The mailto configuration option sets the destination for emails related to sudo. The other options listed are not valid for sudo.


41.    Which of the following commands displays a listing of who is logged in to the server along with the date and time that they logged in?
A.    whois
B.    who
C.    loggedin
D.    curusers

 B. The who command displays who is currently logged in and the date and time they logged in. The whois command displays information about domains. The other commands are not valid.


42.    Which port should be allowed through a firewall for NTP communication?
A.    Port 139
B.    Port 161
C.    Port 123
D.    Port 194

 C. Port 123 is used for NTP communication by default. Port 161 is SNMP, 139 is NetBIOS, and 194 is IRC.


43.    Which option to nmap causes it to scan using UDP?
A.    -sT
B.    -sS
C.    -sP
D.    -sU

 D. A UDP scan can be initiated with - sU. A scan of -sT is a normal TCP scan, and -ss is a SYN scan. There is no -sP option.


44.    Which of the following options to isof searches an entire directory tree for open instances of files or directories?
A.    -d
B.    +D
C.    -f
D.    -i

 B. The +D option is used to search an entire directory tree for files that are open by processes. The -d option does essentially the same thing but does not go into subdirectories. The -f option is typically used in combination with other options to control path name interpretation. The -i option lists files or processes with open ports.


45.    Which option to the ip command displays DNS names rather than merely IP addresses?
A.    -n
B.    -f
C.    -r
D.    -a

C. The -r option causes the ip command to attempt to resolve IP addresses. The -f option specifies the protocol family. There is no -n or -a option to the ip command.


46.    Which of the following commands and options enables you to examine timing related to listening sockets?
A.    ss -o
B.    netstat -rn
C.    ping -f
D.    Is -l

 A. The ss command will be used, and when given the -o option, timer information is displayed. The netstat - rn command shows route information but not sockets or timing, and ping -f is a flood ping and not related. The is -1 command displays files in a long listing format.


47.    Which of the following IP address and subnet mask pairs represents a private network in a /24 size?
A.    192.168.3.0/255.255.255.128
B.    172.16.19.128/255.255.0.0
C.    192.168.2.0/255.255.255.0
D.    10.168.1.0/0.0.0.255

 C. All of the addresses shown are in private ranges. The only one with the correct netmask is 255.255.255.0, which is equivalent to 24 masked bits.


48.    When viewing the results of a traceroute, you see !H. To what does !H refer?
A.    Network unreachable
B.    Host available
C.    Host unreachable
D.    High length

 C. The !H sequence indicates host unreachable. Network unreachable is !N.


49.    On which port does the ping command operate for Internet Control Message Protocol (ICMP) echo requests?
A.    53
B.    1337
C.    33433
D.    No port is used for ICMP.

 D. There is no port for ICMP. The protocol itself does not use ports.


50.    When using netstat -a, which file is consulted for the port number to name translation?
A.    /etc/portnum
B.    /etc/services
C.    /etc/portnames
D.    /proc/sys/net/ipv4/ports

 B. The /etc/services file contains the port number to name translation for a given server. The file contains well-known ports and can be customized on a per-server basis.


51.    Which of the following commands launches Orca with speech capabilities?
A.    orca -no-setup -disable main-window
B.    orca -screen
C.    orca -screen-reader
D.    orca -no-setup -s

 A. The command shown launches speech output for Orca. The other commands contain options that are invalid and thus will not work.


52.    Which of the following locations stores the configuration for LightDM?
A.    /etc/lightdm/
B.    /etc/lightdm.conf
C.    /etc/lightdm-conf
D.    /etc/lightdm.d

 A. The configuration files can be found in the /etc/lightdm hierarchy or in /usr/share/lightdm. The other directory locations do not exist by default.


53.    Which of the following commands displays statistics and information about windows in X windows?
A.    xinfo
B.    xstats
C.    xwin
D.    xwininfo

 D. The xwininfo command is used to gather information about windows. The other commands shown are not valid.


54.    Which of the following commands can be used to set the time zone on a Debian system?
A.    tzconfig
B.    /etc/timeconfig
C.    timeconfig
D.    timecfg

 A. The tzconfig command can be used on a Debian system to set the time zone. The other commands listed do not exist.


55.    Which of the following commands displays the available character maps?
A.    charmap
B.    charmap -l
C.    locale -m
D.    mapinfo

C. The locale command will be used for this purpose, and the -m option displays the available character maps. There is no charmap or mapinfo command.
 
56.    Within which directory hierarchy will you find information regarding the available time zones on the server?
A.    /usr/zoneinfo
B.    /usr/share/zoneinfo
C.    /etc/zoneinfo
D.    /etc/tz.conf.d

 B. Time zone information is found within the /usr/share/zoneinfo hierarchy. The other directories listed do not typically exist by default.


57.    The driftfile, as specified in /etc/ntp. conf on a Red Hat system, is stored in which location by default?
A.    /var/lib/ntp/drift
B.    /var/ntp/drift
C.    /usr/share/ntpdrift
D.    /usr/share/lib/ntpdrift

 A. The default location on a Red Hat system is /var/lib/ntp/drift. The other locations shown do not exist by default. Within /etc/ntpd.conf, the location of the drift file can be changed with the driftfile option.


58.    Which character combination sets the body of the message to STDIN when using the mail command?
A.    <
B.    >
C.    <<<
D.    |

 C. The <<< character combination reads input from STDIN or standard input and uses it as the body of the message for the mail command.


59.    Which of the following commands deletes a group from a CentOS Linux system?
A.    groupdm
B.    grouprm
C.    groupdel
D.    delgroup

     C. The groupdel command is used to remove a group from a system. No members of the group can remain or the command will fail.


60.    Which of the following syslog facilities captures messages from the lp printing facility?
A.    auth
B.    messages
C.    lpr
D.    root

 C. The lpr syslog facility sends messages from the ip subsystem to syslog. The auth facility is used for security-related messages. The other listed options are not syslog facilities.