Last Updated on May 13, 2019 by
-
Error messages generated by commands are sent where by default?
- STDERR
- STDIN
- Log files
- STDOUT
-
A successful command may, or may not print output to STDOUT.
True or False?- True
- False
-
Which of the following commands will direct error messages to the file,
error.log
?- ls /root >> error.log
- ls /root > error.log
- ls /root 2> error.log
- ls /root $> error.log
-
A pipe allows you to…
- …send the same input to multiple commands.
- …type multiple commands at one prompt.
- …send the output of one command to another.
- …send the output of a command to a file.
-
Channel 2 is:
- STDOUT
- STDALL
- STDERR
- STDIN
-
Which of the following commands will append its output to
output.file
?- echo Testing >> output.file
- echo Testing > output.file
- output.file < echo Testing
- echo Testing -> output.file
-
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
- cat list.file >> sort
- echo list.file > sort
- cat list.file | sort
-
Which option of the
head
command will display only the first five lines of a file?- No option needed; head displays only five lines by default.
- -n
- -l 5
- -n 5
-
The grep command…
- …will display all the lines that begin with the specified Regular Expression.
- …will display all the lines in a file containing the specified Regular Expression.
- …will display the line numbers in a file that contain a specified Regular Expression.
- …is not case sensitive.
-
The
grep
command can be used with glob characters.True or False?
- True
- False
-
Which of the following commands will display only lines that begin with
start
?- grep start file.txt
- grep $start file.txt
- grep *start file.txt
- grep ^start file.txt
-
Which of the following commands will display only lines that begin with
test
?- grep $test* file.txt
- grep *test file.txt
- grep &test file.txt
- grep ^test file.txt
-
Which of the following commands will display lines that contain either start or end?
- egrep ‘start|end’ file.txt
- egrep (start|end) file.txt
- egrep start end file.txt
- egrep start&end file.txt
-
Which of the following commands can be used to scroll through a text file?
(choose two)
- some
- more
- cat
- less
-
Which option for the
cut
command is used to specify a delimiter?- -D
- -f
- =
- -d
-
Which option for the
cut
command is used to specify the field?- -d
- #
- -D
- -f
-
Which option for the
wc
command will print the number of lines in a file?- -w
- -l
- -L
- -C
-
Which option for the
wc
command will print the total number of words in a file?- -l
- -C
- -L
- -w
-
Which command can be used to print line numbers?
- num
- nl
- ln
- sort
-
The command
echo "text" > file.txt
will createfile.txt
if it does not already exist.True or False?
- True
- False
-
The command
echo "text" > file.txt
will not overwritefile.txt
if it already exists.True or False?
- True
- False
-
The command
echo "text" >> file.txt
will not overwritefile.txt
if it already exists.True or False?
- True
- False
Last Updated on February 28, 2022 by
-
Linux Essentials : All Parts
-
Error messages generated by commands are sent where by default?
- STDERR
- STDIN
- STDOUT
- Log files
-
A successful command may, or may not print output to STDOUT. True or False?
- True
- False
-
Which of the following commands will direct error messages to the file,
error.log
?ls /root > error.log
ls /root >> error.log
ls /root $> error.log
ls /root 2> error.log
-
A pipe allows you to…
- …send the output of a command to a file.
- …type multiple commands at one prompt.
- …send the same input to multiple commands.
- …send the output of one command to another.
-
Channel 2 is
- STDIN
- STDALL
- STDOUT
- STDERR
-
Which of the following commands will append its output to
output.file
?echo Testing > output.file
echo Testing >> output.file
echo Testing -> output.file
output.file < echo Testing
-
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
echo list.file > sort
cat list.file >> sort
sort < list.file
-
Which option of the
head
command will display only the first five lines of a file?-l 5
- No option needed; head displays only five lines by default.
-n 5
-n
-
The
grep
command…- …will display all the lines that begin with the specified Regular Expression.
- …will display all the lines in a file containing the specified Regular Expression.
- …is not case sensitive.
- …will display the line numbers in a file that contain a specified Regular Expression.
-
The
grep
command can be used with glob characters.True or False?- True
- False
-
Which of the following commands will display only lines that begin with
start
?grep $start file.txt
grep ^start file.txt
grep start file.txt
grep *start file.txt
-
Which of the following commands will display only lines that begin with
test
?grep *test file.txt
grep $test* file.txt
grep &test file.txt
grep ^test file.txt
-
Which of the following commands will display lines that contain either start or end?
egrep start end file.txt
egrep 'start|end' file.txt
egrep start&end file.txt
egrep (start|end) file.txt
-
Which of the following commands can be used to scroll through a text file? (choose two)
some
more
less
cat
-
Which option for the
cut
command is used to specify a delimiter?=
-D
-f
-d
-
Which option for the
cut
command is used to specify the field?-d
-D
-f
#
-
Which option for the
wc
command will print the number of lines in a file?-L
-w
-C
-l
-
Which option for the
wc
command will print the total number of words in a file?-l
-C
-w
-L
-
Which command can be used to print line numbers?
nl
ln
num
sort
-
The command
echo "text" > file.txt
will createfile.txt
if it does not already exist. True or False?- True
- False
-
The command
echo "text" > file.txt
will not overwritefile.txt
if it already exists. True or False?- True
- False
-
The command
echo "text" >> file.txt
will not overwritefile.txt
if it already exists. True or False?- True
- False
-
Linux Essentials : All Parts
Total word count:
373
Pages:
1
Error messages generated by commands are sent where by default? |
STDERR |
A successful command will print out put to STDOUT |
True |
Which of the following commands will direct error messages to the file, error.log? |
✔ ls /root 2> error.log |
A pipe allows you to |
send the output of one command to another |
Channel 2 is |
STDERR |
Which of the following commands will append its output to output.file? |
echo Testing >> output.file |
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen? |
sort < list.file cat list.file | sort |
Which option of the head command will display only the first five lines of a file |
-n 5 |
The grep command |
will display all the lines in a file containing the specified Regular Expression |
The grep command can be used with glob characters |
TRue |
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 command will display lines that contain either start or end |
egrep ‘start|end’file.txt |
which of the following commands can be used to scroll through a text file |
less more |
the find command can search for files based on the size of the file |
true |
which of the following commands scans the file to determine file location |
find |
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 wc command will print the number of lines in a file |
-l |
which option for the wc command will print the total number of words in a file |
-w |
which command can be used to print line numbers |
nl |
the command echo «text» > file.txt will create file.txt if it does not already exist. |
true |
the command echo «text» > file.txt will not overwrite file.txt if it already exists. |
false |
the command echo «text» >> file.txt will not overwrite file.text if it already exists |
true |
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price
С этим файлом связано 1 файл(ов). Среди них: срс-1 адилет.pptx.
Показать все связанные файлы
Подборка по базе: Текстовый документ OpenDocument.odt, Energy and its sources_1.pdf, Текстовый документ OpenDocument.odt, Текстовый документ OpenDocument.odt, Текстовый документ OpenDocument.odt, Текстовый документ OpenDocument (4) 1123.odt, Текстовый документ OpenDocument.odt, Текстовый документ OpenDocument.odt, Текстовый документ OpenDocument (2).odt, Текстовый документ OpenDocument.odt
Which of the following commands will direct error messages to the file, error.log?. (choose one)
- ls /root > error.log
- ls /root >> error.log
- ls /root 2> error.log
- ls /root $> error.log
The echo command:
- Tests a variable for duplication
- Duplicates the input stream to the output stream
- Is used for variable assignment
- Is used to output text to the console
- Copies variables from one to another
Which are appropriate editors for writing shell scripts?. (choose two)
- nano
- LibreOffice Writer
- /bin/bash
- vi
- Firefox
64 bit platforms can access more memory than 32 bit platforms.. True or False?
- True
- False
What does the acronym RPM mean?
- Relocate Package Manager
- Return Package Management
- RPM Package Management
- Recursive Package Manager
One way to install new software on a Linux system is to use a package management system.. True or False?
- True
- False
When you execute the dmesg command, the system displays messages that are generated by the kernel.. True or False?
- True
- False
Which of the following are package management commands for distributions with software distributed in files ending in .deb?. (choose three)
- rpm
- apt-get
- dpkg
- aptitude
Which of the following are package management commands for distributions with software distributed in files ending in .rpm?. (choose three)
- yum
- apt-get
- rpm
- yumex
Which of the following would be considered a host?
- A printer attached to the network via an IP address
- A CDROM
- The computer’s hard drive
- A network cable
A network packet contains …. (choose two)
- …the IP address of the destination machine.
- …a hard drive partition.
- …the name of the router.
- …the IP address of the source machine.
Only servers have hostnames.. True or False?
- True
- False
Which files contain user account information?. (choose two)
- /etc/passwd
- /etc/shadow
- /etc/group
Which user can view the /etc/shadow file?
- The root user
- No users
- Any member of the password group
- All users
Which command will display the UID, GID and groups your current user belongs to?
- id
- whoami
- who
- about
Each user belongs to at least one group.. True or False?
- True
- False
Which command will display the users that are currently logged in to the system?
- who
- about
- whoami
- id
UIDs 1-500 are usually reserved for what kind of users?
- Are not used for user accounts, but for group accounts
- System accounts, such as server processes
- Remote log-in accounts
- Log-in (human) users
Linux Essentials Final Comprehensive Exam (Modules 1 – 16) Answer
-
Question ID 2
One of the jobs of the kernel is to:
- Manage the system’s resources
- Turn source code into machine code
- Load the operating system after the computer is turned on
- Transfer mail from one machine to another
-
Question ID 3
Unix is:
(choose two)
- An operating system
- A type of hardware
- A trademark
- A distribution of Linux
- A text editor
-
Question ID 5
Linux is written in:
- C
- .NET
- C++
- Java
- Perl
-
Question ID 6
Source code refers to:
- The version of a program that the computer runs on the CPU
- The license that dictates how you may use and share the software
- The interface that software uses to talk to the kernel
- A human readable version of computer software
-
Question ID 22
What is the standard option to provide a command line program to view its documentation?
- –info
- –doc
- –help
- -h
-
Question ID 23
The command man -k is the same as the command apropos.
True or False?
- True
- False
-
Question ID 24
The whatis command is the same as man -w.
- True
- False
-
Question ID 26
The directory where additional documentation for software packages most likely can be found is:
- /var/lib/doc
- /usr/software/doc
- /usr/share/doc
- /var/share/doc
-
Question ID 47
Hidden files are files that begin with what character?
- A plus (+)
- A dash (-)
- A period (.)
- An asterisk (*)
-
Question ID 48
What option for the ls command will display all files, including hidden files?
- -w
- -H
- -L
- -a
-
Question ID 49
The top-level directory on a Linux system is represented as:
- /
- /root
- /home
- C:
-
Question ID 50
Is the following path absolute or relative?
/etc/ppp
- Relative
- Absolute
-
Question ID 51
Is the following path absolute or relative?
sysadmin/Documents
- Relative
- Absolute
-
Question ID 73
Compression on a file works by:
- Removing the high order bit from each byte
- Consolidating multiple files into one
- Removing redundant information
- Storing most of the data on removable media and just leaving a pointer
- Eliminating gaps within the file
-
Question ID 75
In general, for which of the following would you want to use lossless compression?
- An mp3 audio file
- A movie
- A log file
- A JPEG image
- An encrypted email
-
Question ID 76
Lossy compression:
(choose three)
- Is often used with documents
- Decompresses to an identical version as the original
- Sacrifices some quality
- Usually results better compression than lossless
- Is often used with images
-
Question ID 77
You type gzip myfile.tar. What happens?
(choose two)
- myfile.tar.gz holds a compressed version of myfile.tar
- An error; you forgot to pass the name of the output file
- An error; you forgot to specify the file with –f
- myfile.tar is unarchived into the current directory
- myfile.tar is removed
-
Question ID 93
Error messages generated by commands are sent where by default?
- STDIN
- Log files
- STDERR
- STDOUT
-
Question ID 94
A successful command will print output to STDOUT.
True or False?
- True
- False
-
Question ID 95
Which of the following commands will direct error messages to the file, error.log?
(choose one)
- ls /root > error.log
- ls /root >> error.log
- ls /root 2> error.log
- ls /root $> error.log
-
Question ID 96
A pipe allows you to…
- …send the same input to multiple commands.
- …send the output of one command to another.
- …send the output of a command to a file.
- …type multiple commands at one prompt.
-
Question ID 97
Channel 2 is:
- STDERR
- STDIN
- STDALL
- STDOUT
-
Question ID 117
The echo command:
- Tests a variable for duplication
- Duplicates the input stream to the output stream
- Is used for variable assignment
- Is used to output text to the console
- Copies variables from one to another
-
Question ID 118
A file begins with #!/bin/csh. This means:
- C Shell compatibility mode is enabled
- Running the script will invoke /bin/csh to interpret the rest of the file
- The operator should not be using /bin/csh
- This is a Perl script
- Nothing, this is a comment
-
Question ID 119
Which are appropriate editors for writing shell scripts?
(choose two)
- nano
- LibreOffice Writer
- /bin/bash
- vi
- Firefox
-
Question ID 120
Most of nano’s commands take the form of:
- Escape followed by another character
- Mouse clicks
- The F1 through F12 function keys
- Alt and another character
- Control and another character
-
Question ID 121
What does this shell script do?
FOO=/tmp/foo
if [ ! –d $FOO ]; then
mkdir $FOO
fi
- Nothing, since there is a problem with the conditions in the if statement
- Makes the /tmp/foo directory if a file by that name exists
- Creates /tmp/foo if it does not exist
- Creates /tmp/foo and raises an error if there is a problem
- Outputs a message to the screen
-
Question ID 140
Which of the following are valid CPU types for Intel-based platforms?
(choose two)
- 48 bit
- 24 bit
- 64 bit
- 32 bit
-
Question ID 141
64 bit platforms can access more memory than 32 bit platforms.
True or False?
- True
- False
-
Question ID 157
What does the acronym RPM mean?
- Relocate Package Manager
- Return Package Management
- RPM Package Management
- Recursive Package Manager
-
Question ID 158
One way to install new software on a Linux system is to use a package management system.
True or False?
- True
- False
-
Question ID 159
When you execute the dmesg command, the system displays messages that are generated by the kernel.
True or False?
- True
- False
-
Question ID 160
Which of the following are package management commands for distributions with software distributed in files ending in .deb?
(choose three)
- rpm
- apt-get
- dpkg
- aptitude
-
Question ID 161
Which of the following are package management commands for distributions with software distributed in files ending in .rpm?
(choose three)
- yum
- apt-get
- rpm
- yumex
-
Question ID 177
Which of the following would be considered a host?
- A printer attached to the network via an IP address
- A CDROM
- The computer’s hard drive
- A network cable
-
Question ID 178
A service is…
- …a file that contains configuration information.
- …another name for a computer’s hostname.
- …a feature provided by one computer to another.
- …like an IP address.
-
Question ID 180
A network packet contains …
(choose two)
- …the IP address of the destination machine.
- …a hard drive partition.
- …the name of the router.
- …the IP address of the source machine.
-
Question ID 181
Only servers have hostnames.
True or False?
- True
- False
-
Question ID 197
Which files contain user account information?
(choose two)
- /etc/passwd
- /etc/shadow
- /etc/group
-
Question ID 198
Which user can view the /etc/shadow file?
- The root user
- No users
- Any member of the password group
- All users
-
Question ID 199
Which command will display the UID, GID and groups your current user belongs to?
- id
- whoami
- who
- about
-
Question ID 200
Each user belongs to at least one group.
True or False?
- True
- False
-
Question ID 201
Which command will display the users that are currently logged in to the system?
- who
- about
- whoami
- id
-
Question ID 217
UIDs 1-500 are usually reserved for what kind of users?
- Are not used for user accounts, but for group accounts
- System accounts, such as server processes
- Remote log-in accounts
- Log-in (human) users
-
Question ID 218
If a user is deleted, the files and directories that the user owned…
- …are deleted as well.
- …will have no UID owner.
- …will show a UID as the owner, but not user name.
- …will have no user owner.
-
Question ID 219
Which of the following options for the useradd command allows root to specify the UID to be associated with the account?
- -g
- -u
- -U
- -G
-
Question ID 220
Which of the following options for the useradd command allows root to specify supplementary groups the user will be a member of?
- -u
- U
- -g
- -G
-
Question ID 221
On a system that does not use UPG, the useradd command will also create a user group. For example, user bob, group bob.
True or False?
- True
- False
-
Question ID 237
Which of the following commands set “other” permissions on file to r-x?
- chmod o+rx file
- chmod o-r-w file
- chmod o=r+x file
- chmod o=rx file
-
Question ID 238
Which of the following commands sets “other” permissions on file to r-x?
- chmod 774 file
- chmod 776 file
- chmod 775 file
- chmod 777 file
-
Question ID 239
Only one set (user, group, other) of permission can be changed at once using the symbolic method.
True or False?
- True
- False
-
Question ID 240
Which of the following are methods for setting permissions using the chmod command?
(choose two)
- letter
- octal
- symbolic
- binary
-
Question ID 241
The chown command can be used to change the owner and group of a file.
True or False?
- True
- False
-
Question ID 267
The Samba application is a:
- Mail Server
- Security Server
- File Server
- Web Server
-
Question ID 268
Which of the following are examples of desktop software?
(choose two)
- Web server
- Web browser
- File share
- Compiler
- Music player
-
Question ID 269
If you wanted to set up a blog, which software would be most helpful?
- MySQL
- Postfix
- WordPress
- Dovecot
- Samba
-
Question ID 270
Which of the following pieces of software deal with file sharing?
(choose three)
- NFS
- X-Windows
- Netatalk
- Samba
- PostgreSQL
-
Question ID 271
If you wanted to create and print an invoice, which software could you use?
- GNOME
- Compiz
- Firefox
- LibreOffice
- Evolution
-
Question ID 307
Which of the following is true about graphical mode?
(choose three)
- You have menus and tools to help you find what you are looking for
- You access this mode by logging into a graphical display
- After login, you are provided with a command prompt
- After login, you are provided with a desktop
- You cannot use your mouse
-
Question ID 308
Which of the following is provided by a graphical interface that isn’t normally provided to a non graphical interface?
(choose four)
- Desktop
- Shell
- Windows
- Popups
- Menus
-
Question ID 309
A server is likely to be running in graphical mode.
True or False?
- True
- False
-
Question ID 310
In graphical mode, you can get to a shell by running which applications?
(choose two)
- guiterm
- gbash
- terminal
- xconsole
- xterm
-
Question ID 311
Which of the following are traits of a multiuser operating system?
(choose three)
- An administrative user gets a dedicated CPU
- Users can protect their information from other users
- Resources are shared between users
- Many users can log in simultaneously with a unique account
- Each user can only log in once per day
-
Question ID 327
Select all the applications that provide access to the Command Line Interface (CLI)?
(choose two)
- Virtual Terminal
- firefox
- opera
- Terminal window
-
Question ID 328
Which environment variable contains a list of directories that is searched for commands to execute?
- PATH
- EXEC
- PS1
- PS2
-
Question ID 329
Select the command that can report the location of a command:
- where
- what
- which
-
Question ID 331
A pair of single quotes ( ‘ ) will prevent the shell from interpreting any metacharacter.
True or False?
- True
- False
-
Question ID 348
The /tmp directory is a temporary directory and will not exist on a system at all times.
True or False?
- True
- False
-
Question ID 349
The /var directory has files that change over time.
True or False?
- True
- False
-
Question ID 350
The “sticky bit” permission…
- …prevents others from removing files they don’t own from a common directory.
- …changes the group ownership of existing files in a directory.
- …prevents others from overwriting files they don’t own in common directories.
- …sets the group ownership of any new file created in a directory.
-
Question ID 352
Which of the following commands will set the “sticky bit” on /shared ?
- chmod 4777 /shared
- chmod 2777 /shared
- chmod 7777 /shared
- chmod 1777 /shared
-
Question ID 353
The “setuid” permission…
- …allows a command to be run as the file owner.
- …allows files in a directory to be manipulated as by the directory owner.
- …prevents the owner of a file from being changed.
- …reports the output of a script to the owner.
Mar 14, 2019
Last Updated: Mar 24, 2019
Linux Essentials, Linux
How to find: Press “Ctrl + F” in the browser and fill in whatever wording is in the question to find that question/answer. If the question is not here, find it in Questions Bank.
NOTE: If you have the new question on this test, please comment Question and Multiple-Choice list in form below this article. We will update answers for you in the shortest time. Thank you! We truly value your contribution to the website.
- Error messages generated by commands are sent where by default?
- Log files
- STDOUT
- STDERR*
- STDIN
- A successful command will print output to STDOUT.True or False?
- True*
- False
- Which of the following commands will direct error messages to the file, error.log? (choose one)
- ls /root >> error.log
- ls /root 2> error.log*
- ls /root $> error.log
- ls /root > error.log
- A pipe allows you to…
- …send the same input to multiple commands.
- …type multiple commands at one prompt.
- …send the output of one command to another.*
- …send the output of a command to a file.
- Channel 2 is:
- STDIN
- STDALL
- STDOUT
- STDERR*
- Which of the following commands will append its output to output.file?
- echo Testing > output.file
- echo Testing >> output.file*
- output.file < echo Testing
- echo Testing -> output.file
- 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*
- cat list.file | sort*
- cat list.file >> sort
- echo list.file > sort
- Which option of the head command will display only the first five lines of a file?
- -l 5
- No option needed; head displays only five lines by default.
- -n
- -n 5 *
- The grep command…
- …will display all the lines that begin with the specified Regular Expression.
- …is not case sensitive.
- …will display all the lines in a file containing the specified Regular Expression.*
- …will display the line numbers in a file that contain a specified Regular Expression.
- The grep command can be used with glob characters.True or False?
- True*
- False
- Which of the following commands will display only lines that begin with start?
- grep *start file.txt
- grep $start file.txt
- grep start file.txt
- grep ^start file.txt*
- Which of the following commands will display only lines that begin with test?
- grep ^test file.txt*
- grep $test* file.txt
- grep *test file.txt
- grep &test file.txt
- Which of the following commands will display lines that contain either start or end?
- egrep start end file.txt
- egrep ‘start|end’ file.txt*
- egrep start&end file.txt
- egrep (start|end) file.txt
- Which of the following commands can be used to scroll through a text file? (choose two)
- some
- less*
- cat
- more*
- The find command can search for files based on the size of the file.True or False?
- True*
- False
- Which of the following commands scans the file to determine file locations?
- search
- locate
- where
- find*
- Which option for the cut command is used to specify a delimiter?
- -f
- -d *
- =
- -D
- Which option for the cut command is used to specify the field?
- -D
- -f *
- -d
- #
- Which option for the wc command will print the number of lines in a file?
- -l *
- -w
- -C
- -L
- Which option for the wc command will print the total number of words in a file?
- -l
- -L
- -C
- -w *
- Which command can be used to print line numbers?
- num
- sort
- ln
- nl*
- The command echo “text” > file.txt will create file.txt if it does not already exist.True or False?
- True*
- False
- The command echo “text” > file.txt will not overwrite file.txt if it already exists.True or False?
- True
- False*
- The command echo “text” >> file.txt will not overwrite file.txt if it already exists.True or False?
- True*
- False
Download PDF File below:
[sociallocker id=”54558″]
[/sociallocker]
NDG Linux Essentials — CISCO Networking Academy — Questions and Answers
Chapter 01
CORRECT — See section 1.3.3
Source code refers to:
- Human readable version of computer software
CORRECT — See section 1.3.3
Open source means:
- You can view the software’s source code
- You can modify the software’s source code
CORRECT — See section 1.3.5
The Linux platform that runs on mobile phones is called:
- Android
CORRECT — See section 1.3.4
What does a distribution provide to add and remove software from the system?
- Package manager
CORRECT — See section 1.3.1
The bootloaders job is to:
- Load the kernel after the computer is powered on
CORRECT — See section 1.3.4
Ubuntu is derived from which distribution?
- Debian
WRONG — See section 1.3
Linux is not Unix because:
- There are too many distributions
CORRECT — See section 1.4.1
A maintenance cycle:
- Describes how long a version of software will be supported
CORRECT — See section 1.4.2
Microsoft Windows:
- Has powerful scripting capabilities
- Comes in desktop and server variants
- Has built in virtualization
WRONG — See section 1.4.5
Other commercial Unixes:
- Do not run the GNU tools
Chapter 02
CORRECT — See section 2.3.1
If you wanted to set up a blog,
which software would be most helpful?
- WordPress
CORRECT — See section 2.3.3
Which of the following are examples
of text editors?
- vim
- emacs
- pico
- nano
WRONG — See section 2.3.4
Which of the following are true
about compiled programming languages?
- Ruby is a compiled language
WRONG — See section 2.3.3
The Linux shell:
- Has a scripting language
- Is customizable
- Has a built in text editor
CORRECT — See section 2.3.2
Which application would you use to
edit and piece together sound files to make podcast?
- Audacity
CORRECT — See section 2.3.1
Which server software would you use
to create a company directory that you could search and authenticate against?
- OpenLDAP
CORRECT — See section 2.3.1
A Mail Transfer Agents primary
purpose is to:
- Deliver mail between servers
CORRECT — See section 2.4.1
The Free Software Foundation
believes that:
- Software should be free to share
- Software should be free to modify
WRONG — See section 2.4.3
What is the meaning of a public
domain license?
- The work was done by a government agency
WRONG — See section 2.4.1
Permissive free software licenses:
- Are not approved by the FSF
- Can allow software to be used inside closed source
software - Include the GPLv2 and BSD
Chapter 03
CORRECT — See section 3.3
Which of the following is true about
graphical mode?
- You access this mode by logging into a graphical
display - You have menus and tools to help you find what you are
looking for - After login, you are provided with a desktop
WRONG — See section 3.3
Which of the following is provided
by a graphical interface that isnt normally provided to a non graphical
interface?
- menus
- windows
- desktop
- shell
CORRECT — See section 3.3
A server is likely to be running in
graphical mode.
- False
CORRECT — See section 3.5
Virtualization means:
- A single host can be split up into multiple guests
CORRECT — See section 3.5
In virtualization, what are the host
and guest?
- The host is the machine that runs the virtual machines
- A guest is a virtual machine
CORRECT — See section 3.6
If you wanted to write a report that
was to be printed, you would probably use:
- LibreOffice
CORRECT — See section 3.7
If you want to store logins and
passwords for different websites in a secure manner, you could use:
- KeePassX
CORRECT — See section 3.7
You can configure your computer to
check for updates automatically.
- True
CORRECT — See section 3.7
Which of the following are
properties of a strong password?
- At least 10 characters long
- A mix of upper and lower case
- Includes symbols
CORRECT — See section 3.7
What can be done to prevent remote
people from running programs on your computer?
- Turn on a firewall
- use strong passwords on all user accounts
Chapter 04
CORRECT — See section 4.4
Select all the applications that
provide access to the Command Line Interface (CLI)?
- Terminal window
- Virtual Terminal
CORRECT — See section 4.11.1
A pair of double quotes ( » )
will prevent the shell from interpreting any metacharacter.
- False
CORRECT — See section 4.12.1
The semicolon «;» can be
used to separate multiple commands to be executed in order.
- True
CORRECT — See section 4.12.2
The double ampersand characters (
&& ) are used to separate commands to be executed conditionally, where
if the command to the left of the ampersands fails, then the command to the
right of the ampersands will be executed.
- False
CORRECT — See section 4.6
To be able to output messages to the
screen use the _______ command:
- echo
CORRECT — See section 4.5
To execute the same command as
previously executed five commands ago, you would type:
- !-5
CORRECT — See section 4.4.2
The shell program is what interprets
the commands you type into the terminal into instructions that the Linux
Operating System can execute.
- True
CORRECT — See section 4.4.4
Traditional UNIX command options
used a single dash, like -a; _______ command options use two dashes like —all.
- GNU
CORRECT — See section 4.4.4
The acronym GNU stands for:
- Gnu’s Not Unix
CORRECT — See section 4.11.3
What one character treats the
character that follows it as if it was surrounded by single quotes?
Chapter 05
WRONG — See section 5.5.1
What is the standard option to
provide a command line program to view its documentation?
CORRECT — See section 5.3.6
Commands typically executed by a
user are covered in what section of the manual?
- 1
CORRECT — See section 5.3.6
Section 5 of the manual pages
covers:
- File Formats
CORRECT — See section 5.3.2
In order to exit viewing a man page,
press:
- q
CORRECT — See section 5.3.2
Which option for the man
command should you use if you intend to send the output of the command to a
printer?
- -t
CORRECT — See section 5.3.2
What key should be used while
working in the man command if you want to go to the end of the document?
- G
CORRECT — See section 5.4.2
To get help while using the info
command press:
- h
CORRECT — See section 5.4.2
To exit the info command press:
- q
CORRECT — See section 5.4.2
To go to the end of an info page
press:
- END
CORRECT — See section 5.3.2
To move a page forward one at a time
while viewing a man page, press the following:
- Spacebar
Chapter 06
CORRECT — See section 6.3
The top-level directory on a Linux
system is represented as:
- /
CORRECT — See section 6.3.2
The tilde (~) is used to represent:
- A user’s home directory.
CORRECT — See section 6.3.2
Which of the following commands can
be used to access the home directory of the user «bob» while logged
in as root?
- cd /home/bob
- cd ~bob
WRONG — See section 6.3.5
The double dot (..) can be used to
represent the directory…
- …any directory below the current directory
CORRECT — See section 6.4
The ls command without options or
arguments…
- …lists the contents of the current directory.
CORRECT — See section 6.4.3
The first character in a long
listing (ls -l) indicates:
- If something is a file, directory, or symbolic link
CORRECT — See section 6.4.1
Which of the following commands will
prevent any aliased options to the ls command?
- ls
CORRECT — See section 6.5.2
Which option(s) can be used to
prevent cp from overwriting an existing file?
- -i
- -n
CORRECT — See section 6.7.1
Which of the following commands can
be used to rename a file?
- mv
CORRECT — See section 6.8
The touch command can be used to:
- create new files
- update the time stamp of existing files
Chapter 07
CORRECT — See section 7.3
You type gzip myfile.tar. What happens?
- myfile.tar is removed
- myfile.tar.gz holds a compressed version of myfile.tar
CORRECT — See section 7.4
Which flag would you pass to tar in
order to have it make a new archive?
- -c
CORRECT — See section 7.4
Which command will show whats inside
the compressed tarball with a name of foo.tar.gz?
- tar tzf foo.tar.gz
WRONG — See section 7.4
Given the command tar cvjf homedirs.tbz /home, which of the following are true?
- Files that are present in the archive might overwrite
files in /home - The /home directory will be restored with the contents
of homedirs.tbz
CORRECT — See section 7.5
Which of the following commands will
create a zipfile with the contents of your Documents directory?
- zip -r mydocs.zip Documents
CORRECT — See section 7.5
Given a file called documents.zip,
how can you see whats in it without extracting the files?
- unzip l documents.zip
CORRECT — See section 7.3
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
WRONG — See section 7.4
The three main modes of tar
are:
- Create
- Extract
CORRECT — See section 7.4
Which two commands do the same
thing?
- tar c foo | gzip > foo.tar.gz
- tar czf foo.tar.gz foo
CORRECT — See section 7.1
The _____ command is normally
executed daily to update the database of all files that are on the system.
- updatedb
Chapter 08
CORRECT — See section 8.4.3
Error messages generated by commands
are sent where by default?
- STDERR
CORRECT — See section 8.4.2
A successful command will print
output to STDOUT.
- True
CORRECT — See section 8.3
A pipe allows you to…
- …send the output of one command to another
CORRECT — See section 8.11
The grep command can be used with
glob characters.
- True
CORRECT — See section 8.5
The find command can search for files based
on the size of the file.
- True
WRONG — See section 8.5
Which of the following commands
scans the file to determine file locations?
- locate
CORRECT — See section 8.10
Which option for the cut
command is used to specify a delimiter?
- -d
CORRECT — See section 8.10
Which option for the cut
command is used to specify the field?
- -f
CORRECT — See section 8.9
Which option for the wc
command will print the number of lines in a file?
- -l
CORRECT — See section 8.4.4
The command echo «text» > file.txt will not overwrite file.txt if it already exists.
- False
Chapter 09
CORRECT — See section 9.3
A file begins with #!/bin/csh. This means:
- Running the script will invoke /bin/csh to interpret
the rest of the file
CORRECT — See section 9.4
Which are appropriate editors for
writing shell scripts?
- nano
- vi
WRONG — See section 9.4
Most of nanos commands take the form
of:
CORRECT — See section 9.5.2
What does this shell script do?
FOO=/tmp/foo
if
[ ! d $FOO ]; then
mkdir $FOO
fi
- Creates /tmp/foo if it does not exist
CORRECT — See section 9.5.1
Given the following part of a
script:
if
[ -f $1 ]; then
echo I am here
fi
What is the meaning of $1?
- It is the first argument passed to the script
CORRECT — See section 9.5.1
What information is held inside $?
?
- The previous commands exit code
CORRECT — See section 9.5.1
How would you finish your script
with an exit code of 42?
- exit 42
CORRECT — See section 9.5.2
The if command looks for what exit code to
consider a condition to be true?
- 0
WRONG — See section 9.5.2
Given the following script:
while
[ ! f /tmp/foo ]; do
echo n .
process_data > /tmp/foo
done
Which of the following are true?
- process_data will be called at most once
WRONG — See section 9.5.2
A conditional that lets you make
multiple comparisons with a pattern is called:
- if
Chapter 10
CORRECT — See section 10.3
Which of the following are valid CPU
types for Intel-based platforms?
- 32 bit
- 64 bit
CORRECT — See section 10.3
64 bit platforms can access more
memory than 32 bit platforms.
- True
WRONG — See section 10.3
Which of the following commands will
display CPU information?
- arch
- lspic
- cat /proc/cpuinfo
CORRECT — See section 10.3
A CPU flag…
- …defines the features that the CPU supports
CORRECT — See section 10.4
Which command displays information
from SMBIOS?
- dmidecode
CORRECT — See section 10.4.3
Which of the following are common
busing systems?
- USB
- PCI
CORRECT — See section 10.6
Which of the following are valid
partitioning types?
- MBR
- GPT
CORRECT — See section 10.6
The fdisk command is a tool used for working
with the MBR partitioned disks.
- True
WRONG — See section 10.6
Which of the following is the valid
device file name for the first IDE hard drive on the system?
- /dev/ide
CORRECT — See section 10.7
Which of the following are valid
video cable connector types?
- VGA
- DVI
Chapter 11
CORRECT — See section 11.3
One way to install new software on a
Linux system is to use a package management system.
- True
CORRECT — See section 11.10
When you execute the dmesg
command, the system displays messages that are generated by the kernel.
- True
CORRECT — See section 11.3.1
Which of the following are package
management commands for distributions with software distributed in files ending
in «.deb»?
- dpkg
- aptitude
- apt-get
WRONG — See section 11.3.2
Which of the following are package
management commands for distributions with software distributed in files ending
in «.rpm»?
- yum
WRONG — See section 11.4
The Linux kernel mounts the
following pseudo-filesystems to provide access to information about hardware
devices connected to the system:
- /info
- /proc
CORRECT — See section 11.4
The Process ID (PID) of the init
process is
- 1
WRONG — See section 11.8
The free command outputs statistics about:
- Disk usage
CORRECT — See section 11.9
What directory typically contains
log files?
- /var/log
CORRECT — See section 11.9
All log files contain only text
data.
- False
CORRECT — See section 11.4
Which file contains the information
passed to the kernel at boot time?
- /proc/cmdline
Chapter 12
WRONG — See section 12.3
Which of the following would be
considered a host?
- The computer’s hard drive
CORRECT — See section 12.3
A service is…
- …a feature provided by one computer to another
CORRECT — See section 12.5
A network packet contains …
- …the IP address of the destination machine
- …the IP address of the source machine
WRONG — See section 12.4
Which of the following protocols
defines how network communication functions?
- DHCP
CORRECT — See section 12.5
Which of the following are valid
IPv4 addresses?
- 192.105.10.10
- 10.33.55.77
CORRECT — See section 12.7.1
Which of the following commands will
display your machine’s IP address?
- ifconfig
WRONG — See section 12.7.2
Which of the following commands will
display the routing table?
- dig
- route
CORRECT — See section 12.7.4
What option to the netstat command has information shown as numbers rather than names?
- -n
CORRECT — See section 12.7.6
Which of the following commands will
allow you to log into the machine server1 with the account name nick?
- ssh nick@server1
CORRECT — See section 12.7.6.1
The RSA key fingerprint allows the
dig command to connect to remote systems.
- False
Chapter 13
WRONG — See section 13.3
Which files contain user account
information?
- /etc/shadow
- /etc/group
CORRECT — See section 13.3.4
Which command will display the UID,
GID and groups your current user belongs to?
- id
CORRECT — See section 13.8
Which command will display the users
that are currently logged in to the system?
- who
WRONG — See section 13.7.1
The sudo command allows regular users to…
WRONG — See section 13.6
Which of the following commands will
allow you to switch to the user «branch»?
- su branch
- sudo branch
CORRECT — See section 13.7.1
The visudo command uses which text editor by
default?
- vi
CORRECT — See section 13.4
A user can belong to…
- At least 16 groups
CORRECT — See section 13.7.1
Sudo privileges can be used to
specify which user can use the sudo command to execute commands as other users.
- True
CORRECT — See section 13.7.1
In distributions that do not allow
the root user to login directly or via the su command, the installation process
automatically configures one user account to be able to use the sudo
command to execute commands as if they were executed by the root user.
- True
CORRECT — See section 13.3.3
Which command can be used to view
the /etc/passwd file entries?
- getent
Chapter 14
CORRECT — See section 14.8.1
On a system that does not use UPG,
the useradd command will also create a user group. For example, user
«bob», group «bob».
- False
CORRECT — See section 14.12.1
The usermod command
can be used to do all of the following except…
- …change the user’s MAX and MIN password settings
CORRECT — See section 14.12.1
Which of the following commands will
add the group «extra» to the user bob’s secondary groups in addition
to bob’s current secondary groups?
- usermod -aG extra bob
CORRECT — See section 14.12.1
Which option for the usermod command can be used to specify a user’s group ID (either
primary or secondary)?
- -g
- -G
CORRECT — See section 14.13
The userdel command
will…
- delete the user account, but leave the user’s files by
default
CORRECT — See section 14.4
The groupmod command
can be used to change a group name.
- True
CORRECT — See section 14.4
The groupmod command
can be used to add users to a group
- False
CORRECT — See section 13.3.4
Which of the following commands can
be used to modify a group?
- groupmod
CORRECT — See section 14.12
Which command can be used to
determine a user’s most recent log in?
- last
CORRECT — See section 14.12.1
Which of the following commands, run
as root, will prevent the user «bob» from logging in?
- usermod -L bob
Chapter 15
CORRECT — See section 15.7.2
Only one set (user, group, other) of
permission can be changed at once using the symbolic method.
- False
CORRECT — See section 15.7.2
Which of the following are methods
for setting permissions using the chmod command?
- octal
- symbolic
WRONG — See section 15.7.2
The user «sysadmin» will
be able to change the permissions of the «file» because they own it.
—-r—r— 1
sysadmin group 38270
Sep 2 18:49 file
- False
CORRECT — See section 15.7.3
Octal notation uses the following
values for the permissions granted:
- r = 4, w = 2, x = 1
CORRECT — See section 15.7
Which of the following permissions
would allow all users to add, view, and delete files in a directory?
- 777
CORRECT — See section 15.7
A user cannot delete a file if they
do not own it.
- False
CORRECT — See section 15.7
The «execute» permission
on a file allows you to:
- Run the file as a script
WRONG — See section 15.6
The chmod command can be used on a file by:
- Only root
CORRECT — See section 15.9
The «execute» permission
is never set on files by default.
- True
CORRECT — See section 15.7
The user owner of a file will always
have the same or higher permissions as «other».
- False
Chapter 16
CORRECT — See section 16.9
The /tmp directory is a temporary
directory and will not exist on a system at all times.
- False
WRONG — See section 16.7
The «sticky bit»
permission…
- prevents others from overwriting files they don’t own
in common directories
CORRECT — See section 16.7
Which of the following commands will
set the «sticky bit» on /shared ?
- chmod 1777 /shared
CORRECT — See section 16.3
Which of the following commands will
set setuid for /usr/bin/program?
- chmod 4755 /usr/bin/program
WRONG — See section 16.4
The setgid permission…
- allows a command to be run as the group owner of the file.
WRONG — See section 16.5
Setting setgid on a directory…
- does nothing
CORRECT — See section 16.8.3
Deleting a source file will break an
associated hard link.
- False
CORRECT — See section 16.8.3
A source and a hard link must be
part of the same filesystem.
- True
CORRECT — See section 16.8.3
Deleting a source file will break an
associated symbolic link.
- True
CORRECT — See section 16.8.3
A source file and a symbolic link
must be part of the same file system.
- False
Final Comprehensive Exam
CORRECT — See section 1.3.1
One of the jobs of the kernel is to:
- Manage the systems resources
CORRECT — See section 1.3.3
Source code refers to:
- A human readable version of computer software
CORRECT — See section 5.5.1
What is the standard option to
provide a command line program to view its documentation?
- —help
CORRECT — See section 5.3.7
The command man -k
is the same as the command apropos.
- True
CORRECT — See section 5.3.6.3
The whatis command is the same as man -w.
- False
CORRECT — See section 6.4.2
Hidden files are files that begin
with what character?
- A period (.)
CORRECT — See section 6.4.2
What option for the ls
command will display all files, including hidden files?
- -a
CORRECT — See section 6.3
The top-level directory on a Linux
system is represented as:
- /
CORRECT — See section 6.3.5
Is the following path absolute or
relative?
/etc/ppp
- Absolute
CORRECT — See section 6.3.5
Is the following path absolute or
relative?
sysadmin/Documents
- Relative
CORRECT — See section 7.1
Compression on a file works by:
- Removing redundant information
CORRECT — See section 7.3
Lossy compression:
- Usually results better compression than lossless
- Is often used with images
- Sacrifices some quality
CORRECT — See section 7.3
You type gzip myfile.tar. What happens?
- myfile.tar is removed
- myfile.tar.gz holds a compressed version of myfile.tar
CORRECT — See section 8.4.2
A successful command will print
output to STDOUT.
- True
CORRECT — See section 8.4.5
Which of the following commands will
direct error messages to the file, error.log?
- ls /root 2> error.log
- ls /root &> error.log
CORRECT — See section 8.3
A pipe allows you to…
- …send the output of one command to another.
CORRECT — See section 8.4.5
Channel 2 is:
- STDERR
CORRECT — See section 9.3
The echo command:
- Is used to output text to the console
CORRECT — See section 9.3
A file begins with #!/bin/csh. This means:
- Running the script will invoke /bin/csh to interpret
the rest of the file
CORRECT — See section 9.4
Most of nanos commands take the form
of:
- Control and another character
CORRECT — See section 10.3
64 bit platforms can access more
memory than 32 bit platforms.
- True
CORRECT — See section 11.3
One way to install new software on a
Linux system is to use a package management system.
- True
CORRECT — See section 11.10
When you execute the dmesg
command, the system displays messages that are generated by the kernel.
- True
CORRECT — See section 11.3.1
Which of the following are package
management commands for distributions with software distributed in files ending
in .deb?
- dpkg
- aptitude
- apt-get
CORRECT — See section 12.3
Which of the following would be
considered a host?
- A printer attached to the network via an IP address
CORRECT — See section 12.3
A service is…
- …a feature provided by one computer to another.
CORRECT — See section 12.4
Only servers have hostnames.
- False
CORRECT — See section 13.3.2
Which user can view the /etc/shadow
file?
- The root user
CORRECT — See section 13.1
Each user belongs to at least one
group.
- True
CORRECT — See section 13.8
Which command will display the users
that are currently logged in to the system?
- who
CORRECT — See section 14.8.1
UIDs 1-500 are usually reserved for
what kind of users?
- System accounts, such as server processes
CORRECT — See section 14.13
If a user is deleted, the files and
directories that the user owned…
- …will show a UID as the owner, but not user name.
CORRECT — See section 14.8.1
Which of the following options for
the useradd command allows root to specify the UID to be associated
with the account?
- -u
CORRECT — See section 14.8.1
Which of the following options for
the useradd command allows root to specify supplementary groups the
user will be a member of?
- -G
CORRECT — See section 15.7.2
Which of the following commands set
«other» permissions on file to r-x?
- chmod o=rx file
CORRECT — See section 15.7.2
Which of the following are methods
for setting permissions using the chmod command?
- octal
- symbolic
CORRECT — See section 2.3.1
If you wanted to set up a blog,
which software would be most helpful?
- WordPress
CORRECT — See section 2.3.1
Which of the following pieces of
software deal with file sharing?
- Samba
- Netatalk
- NFS
CORRECT — See section 2.3.2
If you wanted to create and print an
invoice, which software could you use?
- LibreOffice
CORRECT — See section 3.3
Which of the following is true about
graphical mode?
- You access this mode by logging into a graphical
display - You have menus and tools to help you find what you are
looking for - After login, you are provided with a desktop
CORRECT — See section 3.3
A server is likely to be running in
graphical mode.
- False
CORRECT — See section 3.5
Which of the following are traits of
a multiuser operating system?
- Many users can log in simultaneously with a unique
account - Users can protect their information from other users
- Resources are shared between users
CORRECT — See section 4.4
Select all the applications that
provide access to the Command Line Interface (CLI)?
- Terminal window
- Virtual Terminal
WRONG — See section 4.8
Select the command that can report
the location of a command:
- where
CORRECT — See section 4.11.2
A pair of single quotes ( ‘ ) will
prevent the shell from interpreting any metacharacter.
- True
CORRECT — See section 16.9
The /tmp directory is a temporary
directory and will not exist on a system at all times.
- False
CORRECT — See section 16.9
The /var directory has files that
change over time.
- True
WRONG — See section 16.7
The «sticky bit»
permission…
CORRECT — See section 16.7
Which of the following commands will
set the «sticky bit» on /shared ?
- chmod 1777 /shared
CORRECT — See section 16.3
The «setuid» permission…
- …allows a command to be run as the file owner.
At the time of writing, the Apache HTTP server is
used by 30.8% of all web
servers in operation. If you’re responsible for managing any system that
utilizes Apache, then you will surely interact with its logging infrastructure
on a regular basis. This tutorial will introduce you to logging in Apache and
how it can help you diagnose, troubleshoot, and quickly resolve any problem you
may encounter on your server.
You will learn where logs are stored, how to access them, and how to customize
the log output and location to fit your needs. You will also learn how to
centralize Apache logs in a log management system for easier tracing, searching,
and filtering of logs across your entire stack.
🔭 Want to centralize and monitor your Apache logs?
Head over to Logtail and start ingesting your logs in 5 minutes.
Prerequisites
To follow through with this tutorial, you should set up a Linux server that
includes a non-root user with sudo
privileges. Additionally, you also need the
Apache HTTP server installed and enabled on the server, which can be done by
executing the relevant commands below.
On Debian-based distributions like Ubuntu:
sudo systemctl enable apache2
sudo systemctl start apache2
On RHEL, Fedora or CentOS:
sudo systemctl enable httpd
sudo systemctl start httpd
Please note that the rest of the commands, directory configurations, and
conventions used in this tutorial pertain to Debian-based distributions like
Ubuntu. Still, the concepts remain the same for other distributions.
Step 1 — Getting started with Apache logging
Apache logs are files that record everything the Apache web server is doing for
later analysis by the server administrator. The records of all Apache events are
placed in two different text files:
- Access Log: this file stores information about incoming requests. You’ll
find details about each request such as the requested resource, response
codes, time taken to generate the response, IP address of the client, and
more. - Error Log: this file contains diagnostic information about any errors were
encountered while processing requests.
Step 2 — Locating the Apache log files
The log files’ location depends on the operating system the Apache web server is
running. On Debian-based operating systems like Ubuntu, the access log file is
located in /var/log/apache2/access.log
. On CentOS, RHEL, or Fedora, the access
log file is stored in /var/log/httpd/access_log
.
A typical access log entry might look like this:
Output
::1 - - [13/Nov/2020:11:32:22 +0100] "GET / HTTP/1.1" 200 327 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
Similarly, the error log file is located in /var/log/apache2/error.log
on
Debian-based systems and /var/log/httpd/error_log
on CentOS, RHEL, or Fedora.
A typical error log entry might look like this:
Output
[Thu May 06 12:03:28.470305 2021] [php7:error] [pid 731] [client ::1:51092] script '/var/www/html/missing.php' not found or unable to stat
In the next section, we’ll discuss how to view these log files from the command
line.
Step 3 — Viewing Apache Log files
One of the most common ways to view an Apache log file is through the tail
command which prints the last 10 lines from a file. When the -f
option is
supplied, the command will watch the file and output its contents in real-time.
sudo tail -f /var/log/apache2/access.log
You should observe the following output on the screen:
Output
. . .
198.54.132.137 - - [04/Feb/2022:11:34:04 +0000] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:04 +0000] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:04 +0000] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:05 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:06 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:06 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:07 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:07 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
To view the entire contents of the file, you can use the cat
command or open
the file in a text editor like nano
or vim
:
cat /var/log/apache2/access.log
You may also want to filter the log entries in the log file by a specific term.
In such cases, you should use the grep
command. The first argument to grep
is the term you want to search for, while the second is the log file that will
be searched. In example below, we are filtering all the lines that contain the
word GET
:
sudo grep GET /var/log/apache2/access.log
This should present the following output:
Output
. . .
198.54.132.137 - - [04/Feb/2022:11:34:04 +0000] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:04 +0000] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:05 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:06 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:06 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:07 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
198.54.132.137 - - [04/Feb/2022:11:34:07 +0000] "GET / HTTP/1.1" 200 3476 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
Step 4 — Examining Apache access log formats
The access log records all requests that are processed by the server. You can
see what resources are being requested, the status of each request, and how long
it took to process their response. In this section, we’ll dive deeper into how
to customize the information that is displayed in this file.
Before you can derive value from reading a log file, you need to understand the
format that is being used for each of its entries. The CustomLog
directive is
what controls the location and format of the Apache access log file. This
directive can be placed in the server configuration file
(/etc/apache2/apache2.conf
) or in your virtual host entry. Note that defining
the same CustomLog
directive in both files may cause problems.
Let’s look at the common formats used in Apache access logs and what they mean.
Common Log Format
The Common Log Format
is the standardized access log format format used by many web servers because it
is easy to read and understand. It is defined in the /etc/apache2/apache2.conf
configuration file through the LogFormat
directive.
When you run the command below:
sudo grep common /etc/apache2/apache2.conf
You will observe the following output:
Output
LogFormat "%h %l %u %t "%r" %>s %O" common
The line above defines the nickname common
and associates it with a particular
log format string. A log entry produced by this format will look like this:
Output
127.0.0.1 alice Alice [06/May/2021:11:26:42 +0200] "GET / HTTP/1.1" 200 3477
Here’s an explanation of the information contained in the log message above:
%h
->127.0.0.1
: the hostname or IP address of the client that made the
request.%l
->alice
: remote log name (name used to log in a user). A placeholder
value (-
) will be used if it is not set.%u
->Alice
: remote username (username of logged-in user). A placeholder
value (-
) will be used if it is not set.%t
->[06/May/2021:11:26:42 +0200]
: the day and time of the request."%r"
->"GET / HTTP/1.1"
— the request method, route, and protocol.%>s
->200
— the response code.%O
->3477
— the size of the response in bytes.
Combined Log Format
The Combined Log Format
is very similar to the Common log format but contains few extra pieces of
information.
It’s also defined in the /etc/apache2/apache2.conf
configuration file:
sudo grep -w combined /etc/apache2/apache2.conf
You will observe the following output:
Output
LogFormat "%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combined
Notice that it is exactly the same as the Common Log Format, with the addition
of two extra fields. Entries produced in this format will look like this:
Output
127.0.0.1 alice Alice [06/May/2021:11:18:36 +0200] "GET / HTTP/1.1" 200 3477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
Here’s an explanation of the two additional fields that are not present in the
Common log format:
"%{Referer}i"
->"-"
: the URL of the referrer (if available, otherwise
-
is used)."%{User-Agent}i"
->
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
:
detailed information about the user agent of the client that made the request.
Step 5 — Creating a custom log format
You can define a custom log format in the /etc/apache2/apache2.conf
file by
using the LogFormat
directive followed by the actual format of the output and
a nickname that will be used as an identifier for the format. After defining the
custom format, you’ll pass its nickname to the CustomLog
directive and restart
the apache2
service.
In this example, we will create a log format named custom
that looks like
this:
Output
LogFormat "%t %H %m %U %q %I %>s %O %{ms}T" custom
Open your /etc/apache2/apache2.conf
file and place the line above below the
other LogFormat
lines. It will produce access log entries with the following
details:
%t
: date and time of the request.%H
: the request protocol.%m
: the request method.%U
: the URL path requested.%q
: query parameters (if any).%I
: total bytes received including the request headers.%>s
: final HTTP status code.%O
: number of bytes sent in the response.%{ms}T
: time taken to generate the response in milliseconds.
You can find all other formatting options and their description on
this page.
To enable the custom format for subsequent access log entries, you must change
the value of the CustomLog
directive in your virtual hosts file and restart
the apache2
service with Systemctl.
Open up the default virtual hosts file using the command below:
sudo nano /etc/apache2/sites-available/000-default.conf
Find the following line:
Output
CustomLog ${APACHE_LOG_DIR}/access.log combined
And change it to:
Output
CustomLog ${APACHE_LOG_DIR}/access.log combined
Save the file by pressing Ctrl-O
then Ctrl-X
, then restart the apache2
service using the command below:
sudo systemctl restart apache2
Afterward, make the following request to your server using curl
:
curl --head 'http://<your_server_ip>?name=john&age=30'
You should observe the following response:
Output
HTTP/1.1 200 OK
Date: Mon, 07 Feb 2022 14:21:45 GMT
Server: Apache/2.4.41 (Ubuntu)
Last-Modified: Mon, 07 Feb 2022 12:57:29 GMT
ETag: "2aa6-5d76d24a738bc"
Accept-Ranges: bytes
Content-Length: 10918
Vary: Accept-Encoding
Content-Type: text/html
Go ahead and view the last 10 messages in the access log file:
sudo tail /var/log/apache2/access.log
The log entry that describes the request will look like this:
Output
[07/Feb/2022:14:21:45 +0000] HTTP/1.1 HEAD /index.html ?name=john&age=30 96 200 255 0
It’s also possible to create multiple access log files by specifying the
CustomLog
directive more than once. In the example below, the first line logs
into a custom.log
file using the custom
log format, while the second uses
the common
format to write entries into access.log
. Similarly, the
combined.log
file contains messages formatted according to the combined
log
format.
Output
CustomLog ${APACHE_LOG_DIR}/custom.log custom
CustomLog ${APACHE_LOG_DIR}/access.log common
CustomLog ${APACHE_LOG_DIR}/combined.log combined
Step 6 — Formatting your logs as JSON
Although many log management systems support the default Apache logging formats,
it might be best to log in a structured format like JSON since that’s the go-to
format for structured logging in the industry and it is universally supported.
Here’s a conversion of our custom
log format into JSON:
Output
LogFormat "{ "timestamp":"%t", "protocol":"%H", "method":"%m", "request":"%U", "query":"%q", "request_size_in_bytes":"%I", "status_code":"%>s", "response_size_in_bytes":"%O", "time_taken_ms":"%{ms}T" }" json
This produces log entries with the following formatting:
Output
{
"timestamp": "[07/Feb/2022:15:09:02 +0000]",
"protocol": "HTTP/1.1",
"method": "HEAD",
"request": "/index.html",
"query": "?name=john&age=30",
"request_size_in_bytes": "96",
"status_code": "200",
"response_size_in_bytes": "255",
"time_taken_ms": "0"
}
Step 7 — Configuring Apache error logs
The server error log contains information about any errors that the web server
encountered while processing incoming requests as well as other diagnostic
information. You can choose where the error messages will be transported to
using the ErrorLog
directive in your virtual host configuration file. This
transport is usually a log file on the filesystem.
Here is an example from default virtual host configuration file
/etc/apache2/sites-available/000-default.conf
:
Output
ErrorLog ${APACHE_LOG_DIR}/error.log
On Debian-based distributions, the default error log is in the
/var/log/apache2/error.log
file, while in Fedora/CentOS/RHEL, it placed in the
/var/log/httpd/error_log
file. If the path argument to ErrorLog
is not
absolute, then it is assumed to be relative to the
ServerRoot.
A common practice is to monitor the error log continuously for any problems
during development or testing. This is easily achieved through the tail
command:
sudo tail -f /var/log/apache2/error.log
You will observe the following output:
Output
[Mon Feb 07 13:03:43.445444 2022] [core:notice] [pid 10469:tid 140561300880448] AH00094: Command line: '/usr/sbin/apache2'
[Mon Feb 07 13:07:31.528850 2022] [mpm_event:notice] [pid 10469:tid 140561300880448] AH00491: caught SIGTERM, shutting down
[Mon Feb 07 13:07:31.626878 2022] [mpm_event:notice] [pid 10864:tid 140224997284928] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Feb 07 13:07:31.626980 2022] [core:notice] [pid 10864:tid 140224997284928] AH00094: Command line: '/usr/sbin/apache2'
[Mon Feb 07 13:13:25.966501 2022] [mpm_event:notice] [pid 10864:tid 140224997284928] AH00491: caught SIGTERM, shutting down
[Mon Feb 07 13:13:26.049222 2022] [mpm_event:notice] [pid 11268:tid 139760377875520] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Feb 07 13:13:26.049318 2022] [core:notice] [pid 11268:tid 139760377875520] AH00094: Command line: '/usr/sbin/apache2'
[Mon Feb 07 15:08:50.856388 2022] [mpm_event:notice] [pid 11268:tid 139760377875520] AH00491: caught SIGTERM, shutting down
[Mon Feb 07 15:08:50.940561 2022] [mpm_event:notice] [pid 12096:tid 140473452194880] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Mon Feb 07 15:08:50.940669 2022] [core:notice] [pid 12096:tid 140473452194880] AH00094: Command line: '/usr/sbin/apache2'
Aside from logging directly to a file, you can also forward your logs to a
Syslog. You can do this by
specifying syslog
instead of a file path as the argument to ErrorLog
:
Step 8 — Customizing the error log format
Like the Apache access logs, the format of the error messages can be controlled
through the ErrorLogFormat
directive, which should be placed in the main
config file or virtual host entry. It looks like this:
Output
ErrorLogFormat "[%{u}t] [%l] [pid %P:tid %T] [client %a] %M"
The above configuration produces a log entry in the following format:
Output
[Mon Feb 07 15:52:57.234792 2022] [error] [pid 24372:tid 24507] [client 20.113.27.135:34579] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
Here’s an explanation of the formatting options used above:
%{u}t
: the current time, including microseconds. %l
: the log level of the
message. %P
: the process identifier. %T
: the thread identifier. %a
: the
client IP address. %M
: the actual log message.
Note that when the data for a formatting option is not available in a particular
event, it will be omitted from the log entirely as the Apache error log doesn’t
use placeholder values for missing parameters.
You can find a complete description of all the available error formatting
options in the
Apache docs.
Step 9 — Customizing the error log level
In the virtual host configuration file, you can also control the level of
messages that will be entered into the error log through the
LogLevel directive.
When you specify a particular value, messages from all other levels of higher
severity will be logged as well. For example, when LogLevel error
is
specified, messages with a severity of crit
, alert
, and emerg
will also be
logged.
These are the levels available in increasing order of severity:
trace1
—trace8
: trace messages (lowest severity).debug
: messages used for debugging.info
: informational messages.notice
: normal but significant conditions.warn
: warnings.error
: error conditions that doesn’t necessarily require immediate action.crit
: critical conditions that requires prompt action.alert
: errors that require immediate action.emerg
: system is unusable.
If the LogLevel
directive is not set, the server will set the log level to
warn
by default.
Step 10 — Centralizing your Apache logs
Storing your Apache logs on the filesystem may suffice for development
environments or single-server deployments, but when multiple servers are
involved, it may be more convenient to centralize all your logs in a single
location so that you can automatically parse, filter, and search log data from
all sources in real-time.
In this section, we’ll demonstrate how you can centralize your Apache logs in a
log management service through Vector,
a high-performance tool for building observability pipelines. The following
instructions assume that you’ve signed up for a free
Logtail account and retrieved your source
token.
Go ahead and follow the relevant
installation instructions for Vector
for your operating system. On Ubuntu, you may run the following commands to
install the Vector CLI:
curl -1sLf 'https://repositories.timber.io/public/vector/cfg/setup/bash.deb.sh' | sudo -E bash
After Vector is installed, confirm that it is up and running through
systemctl
:
You should observe that it is active and running:
Output
● vector.service - Vector
Loaded: loaded (/lib/systemd/system/vector.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-02-08 10:52:59 UTC; 48s ago
Docs: https://vector.dev
Process: 18586 ExecStartPre=/usr/bin/vector validate (code=exited, status=0/SUCCESS)
Main PID: 18599 (vector)
Tasks: 3 (limit: 2275)
Memory: 6.8M
CGroup: /system.slice/vector.service
└─18599 /usr/bin/vector
Otherwise, go ahead and start it with the command below.
sudo systemctl start vector
Afterwards, change into a root shell and append your Logtail vector
configuration for Apache into the /etc/vector/vector.toml
file using the
command below. Don’t forget to replace the <your_logtail_source_token>
placeholder below with your source token.
wget -O ->> /etc/vector/vector.toml
https://logtail.com/vector-toml/apache2/<your_logtail_source_token>
Then restart the vector
service:
sudo systemctl restart vector
You will observe that your Apache logs will start coming through in Logtail:
Conclusion
In this tutorial, you learned about the different types of logs that the Apache
web server stores, where you can find those logs, and how to view their
contents. We also discussed Apache access and error log formatting and how to
create your custom log formats, including a structured JSON format. Finally, we
considered how you can manage all your Apache logs in one place by using the
Vector CLI to stream each entry to a log management service.
Don’t forget to read the docs to
find out more about all the logging features that Apache has to offer. Thanks
for reading!
Centralize all your logs into one place.
Analyze, correlate and filter logs with SQL.
Create actionable
dashboards.
Share and comment with built-in collaboration.
Got an article suggestion?
Let us know
Next article
How to View and Configure NGINX Access & Error Logs
Learn how to view and configure nginx access and error logs
→
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.