Linux Practice Exams - LPIC1, LPI & CompTIA Linux+ Set 1

What file contains system-wide shell configuration parameters?


Options are :

  • /etc/shells
  • /etc/bash
  • /etc/skel
  • /etc/profile

Answer :/etc/profile

What happens when you first add a new file to /etc/skel?


Options are :

  • It is immediately copied into the home directories of all users.
  • It will be copied into the home directories of all users at next reboot.
  • Next time a user is created, the new file will be copied to the home directories of all users.
  • None of the above

Answer :None of the above

You often mistype a certain command at the command line, and want to make sure that your typo 'autocorrects'. How would you arrange this?


Options are :

  • autocorrect
  • alias
  • typo
  • source

Answer :alias

Which of the following is not a commonly-used shell configuration file?


Options are :

  • ~/.bash_profile
  • ~/.profile
  • ~/.bash.conf
  • ~/.bashrc

Answer :~/.bash.conf

What does 'exec foo.sh' do?


Options are :

  • It has the same effect as ./foo.sh.
  • It replaces the current shell session with foo.sh.
  • It runs foo.sh as the root user.
  • It executes foo.sh in a subshell.

Answer :It replaces the current shell session with foo.sh.

What will be the output of the following command?

true || echo 'hello'


Options are :

  • hello
  • true
  • An error message
  • None of the above

Answer :None of the above

What is the correct Bash 'if' syntax?


Options are :

  • if test; then command; fi
  • if test; command; fi
  • if test; then command; endif
  • if test; command; endif

Answer :if test; then command; fi

What will be the output of the following command?

seq 1 2 7


Options are :

  • 127
  • 1212121
  • 1357
  • An error message

Answer :1357

What is the main Xorg configuration file?


Options are :

  • /etc/xorg.conf
  • /etc/X11.conf
  • /etc/xorg/X11.conf
  • /etc/X11/xorg.conf

Answer :/etc/X11/xorg.conf

Which of the following is not a tool for connecting remotely to a graphical Linux desktop?


Options are :

  • XDMCP
  • KDE
  • VNC
  • Spice

Answer :KDE

Which command is used to set the date when a user's account will be disabled?


Options are :

  • chage
  • usermod
  • getent
  • groupmod

Answer :usermod

Which command is used to set the date when a user's password will expire and need to be changed?


Options are :

  • chage
  • usermod
  • getent
  • groupmod

Answer :chage

How would you add a password to a preexisting group?


Options are :

  • shadow
  • crypt
  • usermod
  • groupmod

Answer :groupmod

You want to run ~/foo.sh, on the third day of every month, at 06:00am. What would you add to your crontab?


Options are :

  • * 3 6 0 * ~/foo.sh
  • 0 6 3 * * ~/foo.sh
  • 0 6 * 3 * ~/foo.sh
  • * 3 * 6 0 ~/foo.sh

Answer :0 6 3 * * ~/foo.sh

Which is not a directory where crontab files are stored?


Options are :

  • /etc/cron.d
  • /etc/cron.hourly
  • /var/spool/cron
  • /etc/cron

Answer :/etc/cron

What is the Systemd version of 'at'?


Options are :

  • systemd-at
  • systemd-run
  • systemctl
  • atctl

Answer :systemd-run

How would you configure user access to cron?


Options are :

  • /etc/cron.allow and /etc/cron.deny
  • /etc/cron.conf
  • crontab
  • cronctl

Answer :/etc/cron.allow and /etc/cron.deny

What is the nature of /etc/localtime?


Options are :

  • A special file that always contains the current time
  • A symlink to your local timezone file
  • A configuration file containing the name of your timezone
  • None of the above

Answer :A symlink to your local timezone file

How would you convert text between character encodings?


Options are :

  • iconv
  • locale
  • ascii-xfr
  • tzselect

Answer :iconv

Which command would you use to set your system's hardware clock?


Options are :

  • date
  • timedatectl
  • ntpdate
  • hwclock

Answer :hwclock

Where are timezone files stored?


Options are :

  • /etc/timezone
  • /usr/share/zoneinfo
  • /etc/zoneinfo
  • /usr/share/timezone

Answer :/usr/share/zoneinfo

What can be used to view Systemd log files?


Options are :

  • systemd-cat
  • journalctl
  • logger
  • Any text editor or pager

Answer :journalctl

What is the purpose of logrotate?


Options are :

  • It periodically changes the names of log files for enhanced security.
  • It enforces a maximum size to each log file, removing the oldest lines and appending new ones at the bottom.
  • It archives log files and removes the oldest logs.
  • None of the above

Answer :It archives log files and removes the oldest logs.

If you wanted to send all mail log messages to /var/log/maillog, what line would you add to /etc/rsyslog.conf?


Options are :

  • mail.* /var/log/maillog
  • *.mail /var/log/maillog
  • mail.none /var/log/maillog
  • mail /var/log/maillog

Answer :mail.* /var/log/maillog

In what file would you configure global e-mail aliases?


Options are :

  • /etc/postfix.conf
  • /etc/aliases
  • /etc/forwarding
  • /etc/mail.conf

Answer :/etc/aliases

How would a non-root user configure their own e-mail forwarding?


Options are :

  • newaliases
  • ~/.forward
  • ~/.postfix
  • alias

Answer :~/.forward

Which of these MTA's has a history of security problems and is generally considered outdated?


Options are :

  • Postfix
  • Exim
  • Sendmail
  • PowerMTA

Answer :Sendmail

What tool can you use to print a file from the command line?


Options are :

  • printf
  • lpr
  • cupsctl
  • printenv

Answer :lpr

What is the standard port number for the SSH service?


Options are :

  • 22
  • 23
  • 123
  • 161

Answer :22

Which file provides a mapping between common network services and their standard port numbers?


Options are :

  • /etc/ports
  • /etc/netconfig
  • /etc/networks
  • /etc/services

Answer :/etc/services

Which type of addressing is not supported in IPv6?


Options are :

  • Unicast
  • Multicast
  • Broadcast
  • Anycast

Answer :Broadcast

Convert this CIDR mask into dotted decimal notation: /19


Options are :

  • 255.255.224.0
  • 255.255.248.0
  • 0.0.31.255
  • 0.0.7.255

Answer :255.255.224.0

Which statement is true regarding ICMP?


Options are :

  • ICMP services listen on ports 1-65535.
  • ICMP is connection-oriented, like TCP.
  • ICMP messages are distinguished by their type field.
  • ICMP messages are typically encrypted.

Answer :ICMP messages are distinguished by their type field.

Which modern tool would you use to configure your system's network routes?


Options are :

  • route
  • traceroute
  • ifconfig
  • ip

Answer :ip

Which modern tool would you use to gather information about services listening on network ports?


Options are :

  • ss
  • netstat
  • ifconfig
  • ip

Answer :netstat

Which statement is true about netcat?


Options are :

  • It supports IPv4 and IPv6.
  • It can use TCP, UDP, and SCTP.
  • It can act as a client, a server, or a proxy.
  • All of the above

Answer :All of the above

Which file determines where, and in what order, programs should obtain name-service information?


Options are :

  • /etc/networks
  • /etc/netconfig
  • /etc/resolv.conf
  • /etc/nsswitch.conf

Answer :/etc/nsswitch.conf

Which command line tool can be used to query DNS servers?


Options are :

  • dig
  • getent
  • hostname
  • nsupdate

Answer :dig

If you frequently connect to an IPv6 address that does not have any DNS records, where could you add an alias for this address so you don't have to copy/paste it every time?


Options are :

  • /etc/nsswitch.conf
  • /etc/hosts
  • /etc/resolv.conf
  • /etc/host.conf

Answer :/etc/hosts

What tool should be used to configure sudo?


Options are :

  • visudo
  • sudoedit
  • sudo --config
  • sudoconf

Answer :visudo

Which tool will not show you a list of logged-in users?


Options are :

  • w
  • who
  • fuser
  • last

Answer :fuser

How would you set a limit on the number of processes a specific user may run?


Options are :

  • ulimit
  • /etc/security/limits.conf
  • /etc/selinux/config
  • usermod

Answer :/etc/security/limits.conf

What tool would you use to discover open ports on a remote system?


Options are :

  • ss
  • ping
  • netstat
  • nmap

Answer :nmap

Which statement is not true of the /etc/shadow file?


Options are :

  • It may contain hashed passwords, with several different types of hashes.
  • It should be accessible only to root.
  • It may contain clear-text passwords.
  • It has a backup at /etc/shadow-.

Answer :It may contain clear-text passwords.

What happens if the /etc/nologin file exists and is readable?


Options are :

  • No users may log in, effectively putting the system into rescue mode.
  • Only root may log in.
  • Users listed in the /etc/nologin file may not log in.
  • None of the above

Answer :Only root may log in.

Which of the following is not a valid SSH host key type?


Options are :

  • RSA
  • DSA
  • Ed25519
  • Twofish

Answer :Twofish

Where would you add your public SSH key to allow key logins on a remote server?


Options are :

  • ~/.ssh/authorized_keys
  • /etc/ssh/sshd_config
  • ~/.ssh/known_hosts
  • /etc/ssh/moduli

Answer :~/.ssh/authorized_keys

What is the main purpose of the ~/.ssh/known_hosts file?


Options are :

  • To help keep track of which SSH servers you have access to
  • To help protect against man-in-the-middle attacks
  • To cache your password on each server
  • None of the above

Answer :To help protect against man-in-the-middle attacks

What is GPG used for?


Options are :

  • Encrypting and decrypting files
  • Signing files and verifying file signatures
  • Maintaining keyrings and trust levels
  • All of the above

Answer :All of the above

Where does GPG store your user's keyring data?


Options are :

  • ~/.gpg
  • ~/.keys
  • ~/.gnupg
  • ~/.keyrings

Answer :~/.gnupg

Which of these Linux distributions is derived from Red Hat?


Options are :

  • Debian
  • Gentoo
  • Slackware
  • CentOS

Answer :CentOS

Which of the following open source applications is a desktop e-mail client?


Options are :

  • GIMP
  • LibreOffice
  • Firefox
  • Thunderbird

Answer :Thunderbird

Debian Linux comes with which package manager built in?


Options are :

  • Zypper
  • Apt
  • Yum
  • Pacman

Answer :Apt

Which of the following open source packages includes a file share?


Options are :

  • HTTPD
  • MySQL
  • Nextcloud
  • PHP

Answer :Nextcloud

You are releasing, as open source, a software program meant to be used over a network. What license should you use if you want to ensure that anyone who modifies and lets others use the program must also share the source?


Options are :

  • GPL
  • AGPL
  • MIT
  • BSD

Answer :AGPL

Which of the following is not considered a common character class for enforcing strong passwords?


Options are :

  • Letters
  • Numbers
  • Symbols
  • Non-ASCII characters

Answer :Non-ASCII characters

Which 'history' flag would you use to remove a single item from the shell history?


Options are :

  • =-d
  • -c
  • -r
  • =-p

Answer :=-d

What is the name of the predecessor to Bash?


Options are :

  • C Shell
  • Z Shell
  • Bourne Shell
  • There isn't one; Bash was the first Linux shell.

Answer :Bourne Shell

What happens if you unset the PATH variable in a Bash session?


Options are :

  • Bash will use a default PATH variable instead.
  • No commands will work and you'll have to restart the shell.
  • Only Bash built-ins will work.
  • Only Bash built-ins and absolute-path commands will work.

Answer :Only Bash built-ins and absolute-path commands will work.

Which directory does not contain useful help information?


Options are :

  • /usr/share/doc
  • /usr/share/help
  • /usr/share/man
  • /usr/share/info

Answer :/usr/share/help

Which command should you run before using 'locate' for the first time?


Options are :

  • initlocate
  • setup
  • updatedb
  • locatedb

Answer :updatedb

You want information on the 'time()' system call, but 'man time' instead just gets you information on the shell command. How should you correct this?


Options are :

  • man syscall time
  • man time --syscall
  • man 2 time
  • man 8 time

Answer :man 2 time

Which of the following is an absolute path?


Options are :

  • ./foo
  • /foo/bar
  • ../foo
  • foo/bar

Answer :/foo/bar

Where would the home directory for user 'bob' be located?


Options are :

  • /bob
  • /home/bob
  • /Users/bob
  • C:\Users\Bob

Answer :/home/bob

Which combination of options to 'ls' will include a human-readable size in the output?


Options are :

  • =-ah
  • =-as
  • =-lh
  • =-ls

Answer :=-lh

Which flag to 'ls' will list hidden files?


Options are :

  • =-h
  • =-l
  • =-a
  • =-c

Answer :=-a

What happens if you run 'rmdir' on a directory that contains files?


Options are :

  • The directory is removed.
  • An error is printed, and the directory is not removed.
  • The files inside the directory are removed, but the directory itself is not.
  • The directory is removed, and the files inside are moved to the current directory.

Answer :An error is printed, and the directory is not removed.

Which path would be listed by 'ls *.*'?


Options are :

  • ./
  • ../
  • foo
  • foo.txt

Answer :foo.txt

What is the fastest way to move a large file to another location on the same filesystem?


Options are :

  • Copy with 'cp', then remove the old file
  • Copy with 'dd', then remove the old file
  • Move with 'mv'
  • Synchronize with 'rsync'

Answer :Move with 'mv'

Which combination of options would you pass to 'tar' to create a gzipped tarball?


Options are :

  • =-czf
  • =-xf
  • =-tzf
  • =-df

Answer :=-czf

Which archive format is not supported by 'tar'?


Options are :

  • gzip
  • bzip2
  • ZIP
  • xz

Answer :ZIP

Choose the string matched by this regular expression: ^$


Options are :

  • ^
  • $
  • ^$
  • None of the above

Answer :None of the above

Which redirection operator would you use to send only stderr to a file, overwriting whatever is there?


Options are :

  • >
  • >>
  • 1>
  • 2>

Answer :2>

What will be the output of the following command?

echo 'foo bar baz' - grep b - sort -r


Options are :

  • foo
  • barbaz
  • bazbar
  • None of the above

Answer :bazbar

What special variable contains the current process ID?


Options are :

  • $_
  • $!
  • $?
  • $$

Answer :$$

What special variable contains the list of arguments passed to a script?


Options are :

Answer :[email protected]

What will the following shell script do?

while true; do

echo 'hello'

done


Options are :

  • Print hello" for all eternity"
  • Print hello" as long as the 'true' variable has a value"
  • Exit with an error
  • Exit successfully, printing nothing

Answer :Print hello" for all eternity"

What special variable contains the name of the current shell or script being run?


Options are :

  • $!
  • $#
  • $0
  • $?

Answer :$0

What happens if you forget to include the shebang (#!) line in a script?


Options are :

  • The script will fail
  • The script will run under the user's current shell
  • The script will always run under Bash
  • None of the above

Answer :The script will run under the user's current shell

Which exit status means that the previous command exited successfully, without error?


Options are :

  • 0
  • 1
  • -1
  • 255

Answer :0

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions