What output will the command seq 10 produce?
A continuous stream of numbers increasing in increments of 10 until stopped.
The numbers 1 through 10 with one number per line.
The numbers 0 through 9 with one number per line.
The number 10 to standard output.
The seq command in Linux is used to print a sequence of numbers, which can be piped to other commands or used in for loops and bash scripts1. The command can generate a list of integers or real numbers, with options to control the start, end, and increment of the sequence. The general syntax of the command is seq [options] specification1.
If you launch seq with a single number as a command-line parameter, it counts from one to that number. It then prints the numbers in the terminal window, one number per line2. For example, seq 10 will produce the following output:
1
2
3
4
5
6
7
8
9
10
Therefore, the correct answer is B. The numbers 1 through 10 with one number per line.
References: 1: 10+ Seq Commands with Examples in Linux – LinuxWizardry 2: How to Use the seq Command on Linux - How-To Geek
How can the existing environment variable FOOBAR be suppressed for the execution of the script./myscript only?
unset -v FOOBAR;./myscript
set -a FOOBAR="";./myscript
env -u FOOBAR./myscript
env -i FOOBAR./myscript
The env command can be used to run a utility or command in a custom environment without having to modify the currently existing environment1. The -u or --unset option can be used to remove a variable from the environment12. Therefore, the command env -u FOOBAR./myscript will run the script./myscript in an environment where the variable FOOBAR is suppressed. The other options are incorrect for the following reasons:
A. unset -v FOOBAR;./myscript: This will unset the variable FOOBAR in the current shell, not just for the script execution. The semicolon (;) separates two commands, so the script will run in the same environment as the unset command.
B. set -a FOOBAR=“”;./myscript: This will set the variable FOOBAR to an empty string, not suppress it. The -a option means that the variable will be exported to the environment of subsequent commands, so the script will still see the variable FOOBAR, but with no value.
D. env -i FOOBAR./myscript: This will run the script in an empty environment, not just suppress the variable FOOBAR. The -i or --ignore-environment option means that no environment variables will be passed to the command12. References: env command in Linux with Examples - GeeksforGeeks, env - Wikipedia.
Which of the following is the best way to list all defined shell variables?
env
set
env -a
echo $ENV
The set command is used to display or modify the shell variables and functions in the current shell. When used without any arguments, it prints the names and values of all shell variables, including environment variables and user-defined variables, in alphabetical order. The output also includes the shell options and the positional parameters. The set command can be used in any POSIX-compliant shell, such as bash, zsh, ksh, etc123.
The other options are not correct because:
env is used to print or modify the environment variables, not the shell variables. It does not show the user-defined variables or the shell options. It can also be used to run a command in a modified environment45.
env -a is an invalid option for the env command. The -a option is not supported by the env command in any standard or common implementation45.
echo $ENV is used to print the value of the environment variable ENV, not the list of all shell variables. The ENV variable is usually set to the name of a file that contains commands or aliases to be executed by the shell. It is mainly used by the ksh and some versions of bash .
References: 1: How can I list all shell variables? - Unix & Linux Stack Exchange 2: 2.1 Command Line Basics - Linux Professional Institute Certification … 3: set - The Open Group Base Specifications Issue 7, 2018 edition 4: How to set and list environment variables on Linux 5: env - The Open Group Base Specifications Issue 7, 2018 edition : What is the difference between .bash_profile and .bashrc? - Unix & Linux Stack Exchange : ENV - The Open Group Base Specifications Issue 7, 2018 edition
Which of the following words is used to restrict the records that are returned from a SELECT query based on a supplied criteria for the values in the records?
LIMIT
FROM
WHERE
IF
The correct keyword for restricting the records that are returned from a SELECT query based on a supplied criteria for the values in the records is WHERE. The WHERE clause is used to filter records based on one or more conditions. The syntax of the WHERE clause is:
SELECT column1, column2, … FROM table_name WHERE condition;
The condition can be a logical expression that evaluates to true, false, or unknown. The condition can also use comparison operators, logical operators, and wildcards to specify the criteria. For example, the following query selects all the records from the employees table where the salary is greater than 50000:
SELECT * FROM employees WHERE salary > 50000;
The other options are incorrect because they have different purposes in SQL:
LIMIT is used to specify the maximum number of records to return from a query. For example, the following query returns only the first 10 records from the employees table:
SELECT * FROM employees LIMIT 10;
FROM is used to specify the table or tables from which to retrieve data. For example, the following query selects all the columns from the employees table:
SELECT * FROM employees;
IF is used to execute a block of code conditionally. For example, the following query updates the salary of an employee based on their performance:
UPDATE employees SET salary = IF(performance = ‘excellent’, salary * 1.1, salary) WHERE employee_id = 123; References:
https://bing.com/search?q=SQL+statements+restrict+records+based+on+criteria
https://stackoverflow.com/questions/11611931/sql-query-to-select-records-based-on-criteria
Which of the following are requirements in order to run a shell script like a regular command from anywhere in the filesystem? (Choose THREE correct answers.)
The user issuing the command must be in the group script.
The script file must be found in the $PATH.
The script file must have the executable permission bit set.
The script must begin with a shebang-line (#!) that points to the correct interpreter.
The file system on which the script resides must be mounted with the option scripts.
In order to run a shell script like a regular command from anywhere in the filesystem, the following requirements must be met:
The script file must be found in the $PATH. The $PATH is a variable that contains a list of directories where the shell looks for executable files when a command is issued. If the script file is not in one of these directories, the shell will not be able to find it unless the full path is specified.
The script file must have the executable permission bit set. This is a file attribute that determines whether the file can be executed by the user, the group, or others. The executable permission bit can be set using the chmod command, for example: chmod +x script.sh.
The script must begin with a shebang-line (#!) that points to the correct interpreter. This is a special line at the beginning of the script that tells the shell which program to use to run the script, such as #!/bin/bash for bash scripts, or #!/usr/bin/perl for perl scripts. The shebang-line must match the exact path of the interpreter, otherwise the script will not run.
The other options are not requirements for running a shell script like a regular command. There is no such group as script, and the file system mount option scripts does not exist. References:
[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management]
[LPI Linux Professional - Exam 102 Objectives - Topic 105: Shells and Shell Scripting]
Which directory in /etc is used to keep a sample copy of files and directories for when a new user has a home directory created? (Please provide the full path)
/etc/skel, /etc/skel/
The /etc/skel directory is used to keep a sample copy of files and directories for when a new user has a home directory created. The /etc/skel directory contains files and directories that are automatically copied over to a new user’s home directory when such user is created by the useradd or adduser command. The /etc/skel directory allows the system administrator to create a standard environment for all new users on the system. For example, the /etc/skel directory may contain a default .bashrc file that sets some aliases and environment variables for the new user, or a default .profile file that executes some commands at login. The /etc/skel directory may also contain subdirectories such as .ssh or .config that store configuration files for various applications or services. The name /etc/skel comes from the word “skeleton”, as it provides a basic structure for the new user’s home directory. References:
[Linux User Administration]
[Linux Directory Structure]
Which of the following commands puts the output of the command date into the shell variable mydate?
mydate="$(date)"
mydate="exec date"
mydate="$((date))"
mydate="date"
mydate="${date}"
(date)"∗∗ComprehensiveExplanation:∗∗Thecorrectwaytoputtheoutputofthecommanddateintotheshellvariablemydateistousecommandsubstitutionwiththesyntax(command). This will execute the command in a subshell and replace the expression with its standard output. The double quotes around the expression will prevent word splitting and globbing of the output. The other options are incorrect because they will either assign a literal string to the variable, use an invalid syntax, or try to execute the command as an arithmetic expression. References:
[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management]
[LPI Linux Administrator - Exam 102 Objectives - Topic 105: Shells and Shell Scripting]
After issuing:
function myfunction { echo $1 $2 ; }
in Bash, which output does:
myfunction A B C
Produce?
A B
A B C
A C
B C
C B A
In Bash, a function is a block of code that can be invoked by its name. A function can take arguments, which are passed to the function as positional parameters. The $1 variable refers to the first argument, $2 to the second argument, and so on. The function can access the number of arguments passed to it by using the $# variable. In this case, the function myfunction simply echoes the first and second arguments to the standard output. Therefore, when the command myfunction A B C is executed, the output is A B, since the third argument C is ignored by the function. References:
[LPI Linux Essentials - Topic 103: Command Line Basics]
[Bash Functions]
Which of the following SQL statements will select the fields name and address from the contacts table?
SELECT (name, address) FROM contacts;
SELECT (name address) FROM contacts;
SELECT name, address FROM contacts;
SELECT name address FROM contacts;
The correct syntax for selecting specific columns from a table in SQL is to use the SELECT keyword followed by a comma-separated list of column names and then the FROM keyword followed by the table name. Therefore, the only option that follows this syntax is C. SELECT name, address FROM contacts; The other options are incorrect because they either use parentheses around the column names, which are not needed, or they omit the comma between the column names, which causes a syntax error. References: https://www.sqltutorial.org/sql-select/
https://www.w3schools.com/mysql/mysql_select.asp
Which of the following commands lists all defined variables and functions within Bash?
env
set
env -a
echo $ENV
The set command lists all defined variables and functions within Bash, including local, environment, and shell variables, as well as aliases and functions. The output of set can be very long, so it is often piped to less, grep, or other commands for filtering or paging. The set command can also be used to set or unset shell options and positional parameters. The -o posix option to set limits the output to only variables, as defined by the POSIX standard123.
The env command lists only the environment variables, which are a subset of the shell variables that are passed to child processes. The env command can also be used to run a command in a modified environment, or to print or set environment variables. The -a option to env is not valid in most implementations45.
The echo command prints a line of text to the standard output. The $ENV variable is not a predefined variable in Bash, but it can be set by the user or by other programs. If it is not set, echo $ENV will print a blank line1 . References:
Which of the following words is used to restrict the records that are returned from a SELECT SQL query based on a supplied criteria for the values in the records?
CASE
FROM
WHERE
IF
The SQL WHERE clause is used to restrict the records that are returned from a SELECT SQL query based on a supplied criteria for the values in the records12. The WHERE clause follows the SELECT and FROM clauses and contains one or more conditions that must be true for a record to be included in the result set. The general syntax of the WHERE clause is:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
The condition can be a comparison, a logical operation, a pattern matching, a subquery, or a combination of these using various operators12. For example, the following query selects all the records from the customers table where the country is ‘USA’:
SELECT * FROM customers
WHERE country = 'USA';
The other words listed in the question are not used to filter records based on values. They have different meanings and purposes in SQL:
CASE: This is a conditional expression that returns a value based on a set of conditions3. It can be used in SELECT, UPDATE, DELETE, or WHERE statements. For example, the following query uses a CASE expression to assign a rating to each customer based on their credit limit:
SELECT customer_name, credit_limit, CASE WHEN credit_limit > 10000 THEN ‘High’ WHEN credit_limit > 5000 THEN ‘Medium’ ELSE ‘Low’ END AS rating FROM customers;
FROM: This is a clause that specifies the table (s) or view (s) from which the data is retrieved. It follows the SELECT clause and precedes the WHERE clause. For example, the following query selects the customer name and order date from the customers and orders tables:
SELECT customer_name, order_date FROM customers JOIN orders ON customers.customer_id = orders.customer_id;
IF: This is a control flow statement that executes a block of code based on a condition. It can be used in stored procedures, functions, triggers, or batch files. For example, the following code snippet uses an IF statement to check if a variable is positive or negative:
DECLARE @num INT; SET @num = -10; IF @num > 0 BEGIN PRINT ‘Positive’; END ELSE BEGIN PRINT ‘Negative’; END
References: 1: SQL WHERE Clause - W3Schools 2: How to Write a WHERE Clause in SQL | LearnSQL.com 3: [SQL CASE Statement - W3Schools] : [SQL FROM Clause - W3Schools] : [SQL IF…ELSE Statement - W3Schools]
By default, the contents of which directory will be copied to a new user's home directory when the account is created by passing the -m option to the useradd command? (Specify the full path to the directory.)
/etc/skel
The /etc/skel directory contains files and directories that are used as a template for creating a new user’s home directory. The useradd command uses the -m (or --create-home) option to create the user home directory as /home/username and copy the files from /etc/skel to it. The files in /etc/skel are typically initialization files such as .bashrc, .profile, and .bash_logout that set the user’s environment variables, aliases, and other preferences. The system administrator can customize the /etc/skel directory to provide a consistent and convenient initial setup for new users. References:
https://www.howtouselinux.com/post/create-new-user-with-home-directory-in-linux
https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/
Which of the following can the chage command NOT change?
The number of days since January 1, 1970 after which the user's account will no longer be accessible.
The number of days since January 1, 1970 after which the password can change.
The number of days since January 1, 1970 since the password was last changed.
The maximum number of days during which a password is valid.
The number of days of inactivity after a password has expired before the account is locked.
The chage command can change the following parameters related to user password expiry and aging:
The last password change date (-d or --lastday option)
The password expiry date (-E or --expiredate option)
The minimum number of days between password changes (-m or --mindays option)
The maximum number of days during which a password is valid (-M or --maxdays option)
The number of days of warning before password expires (-W or --warndays option)
The chage command cannot change the number of days of inactivity after a password has expired before the account is locked. This parameter is controlled by the -I or --inactive option of the usermod command, which modifies the user account information. The chage command only displays the current value of this parameter, but does not allow changing it. References:
chage command in Linux with examples - GeeksforGeeks
10 chage command examples in Linux [Cheat Sheet] - GoLinuxCloud
How to Use the Chage Command in Linux – TecAdmin
How to Manage User Password Expiration and Aging in Linux - Tecmint
Which file specifies the user accounts that can NOT submit jobs via at or batch? (Provide the full path and filename)
/etc/at.deny
The /etc/at.deny file specifies the user accounts that can NOT submit jobs via at or batch. The format of the file is a list of usernames, one on each line. Whitespace is not permitted. The superuser may always use at. If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at. If /etc/at.allow does not exist, /etc/at.deny is checked12. The at and batch commands use the files /usr/lib/cron/at.allow and /usr/lib/cron/at.deny to restrict usage on some systems3. References:
at.allow(5) - Linux man page
at.deny(5) [linux man page] - The UNIX and Linux Forums
The at.allow and at.deny files - IBM
What is NOT contained in the locale setting of the operating system?
currency symbol
language
timezone
thousands separator
The locale setting of the operating system is a set of environmental variables that defines the language, country, and character encoding settings (or any other special variant preferences) for the applications and shell session on a Linux system12. The locale setting usually consists of at least a language code and a country/region code, such as en_US for English (United States) or fr_FR for French (France). The locale setting also affects things such as the currency symbol, the thousands separator, the decimal point, the date and time format, the collation order, the paper size, the telephone number format, and many other values formatted in accordance with the language or region/country12. However, the timezone is not contained in the locale setting of the operating system. The timezone is a separate setting that determines the local time of the system based on the offset from the Coordinated Universal Time (UTC) and the daylight saving time (DST) rules. The timezone can be different from the country/region code in the locale setting, for example, a user can have a locale setting of en_US but a timezone of Asia/Kolkata. The timezone can be viewed and modified by using the date, timedatectl, or tzselect commands . References: 12
What is the purpose of the iconv command?
It converts bitmap images from one format to another such as PNG to JPEG.
It verifies that the root directory tree complies to all conventions from the Filesystem Hierarchy Standard (FHS).
It displays additional meta information from icon files ending in .ico.
It changes the mode of an inode in the ext4 file system.
It converts files from one character encoding to another.
The iconv command is used to convert the encoding of a file from one character set to another. A character set is a collection of characters that are assigned numerical values called code points. Different character sets may use different numbers of bytes to represent each character, and may have different mappings of code points to characters. For example, ASCII is a single-byte character set that encodes 128 characters, while UTF-8 is a variable-length character set that can encode over a million characters. The iconv command can convert between many different character sets, such as ASCII, UTF-8, ISO-8859-1, etc. The basic syntax for using the command is as follows:
iconv [options] -f from-encoding -t to-encoding input-file > output-file
The -f option specifies the encoding of the input file, and the -t option specifies the encoding of the output file. The input file is read from standard input, and the output file is written to standard output, unless specified otherwise. The iconv command can also list all the supported character sets with the -l option1234. References:
How To Use the iconv Command on Linux - How-To Geek
iconv command in Linux with Examples - GeeksforGeeks
iconv - convert file encoding from one character set to another | Linux …
Using iconv to change character encodings - FileFormat.Info
Which of the following commands can be used to convert text files in one character encoding to another character encoding?
cat
convert
dd
iconv
utf2utf
The command that can be used to convert text files in one character encoding to another character encoding is:
iconv: this command can convert text files from one form of encoding to another, such as UTF-8, ISO-8859-1, ASCII, etc. To use this command, you need to specify the input encoding, the output encoding, and the file name. For example, to convert a file named input.txt from ISO-8859-1 to UTF-8, you can run:
iconv -f ISO-8859-1 -t UTF-8 input.txt
The output will be printed to the standard output, which can be redirected to another file or piped to another command. You can also use the -o option to specify the output file name. For example, to convert the same file and save the output to output.txt, you can run:
iconv -f ISO-8859-1 -t UTF-8 -o output.txt input.txt
To list all the supported encodings, you can use the -l option. For example, to see all the encodings that start with UTF, you can run:
iconv -l | grep UTF
The iconv command is part of the GNU libc package and is available on most Linux systems. The full path of the command is /usr/bin/iconv.
The other options are incorrect because:
cat: this command can concatenate and print files to the standard output, but it does not perform any encoding conversion. It can be used to display the contents of a text file, but it will not change the encoding of the file.
convert: this command can convert image files from one format to another, such as PNG, JPEG, GIF, etc. It is part of the ImageMagick suite of tools and is not related to text encoding conversion.
dd: this command can copy and convert data from one source to another, such as files, devices, or pipes. It can perform some conversions, such as changing the case of letters, swapping bytes, or converting between ASCII and EBCDIC, but it does not support common text encodings such as UTF-8 or ISO-8859-1.
utf2utf: this is not a valid command on Linux. There is no such tool that can convert between different UTF encodings.
References:
How to Convert Files to UTF-8 Encoding in Linux - Tecmint
Best way to convert text files between character sets? - Stack Overflow
how to change encoding of a text file without openning the file in shell program - Stack Overflow
HowTo: Check and Change File Encoding In Linux - ShellHacks
How to change character encoding of a text file on Linux - Xmodulo
The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m.:
* 3,4,5 1 * * chklog
3 3,4,5 1 * * chklog
3 15,16,17 * * * chklog
0 15,16,17 1 * * chklog
* 15,16,17 1 * * chklog
The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m. is:
3 15,16,17 * * * chklog
The crontab entry has five fields that specify the time and frequency of the job, followed by the command or script to be executed. The fields are:
Minute: the minute of the hour when the job should run, from 0 to 59
Hour: the hour of the day when the job should run, from 0 to 23 (in 24-hour format)
Day of month: the day of the month when the job should run, from 1 to 31
Month: the month of the year when the job should run, from 1 to 12
Day of week: the day of the week when the job should run, from 0 to 6 (where 0 and 7 are Sunday)
The asterisk (*) means any value, and the comma (,) means a list of values. Therefore, the crontab entry above means:
Run the job at the 3rd minute of the hour
Run the job at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.)
Run the job on any day of the month
Run the job on any month of the year
Run the job on any day of the week
This will execute the script chklog three times per day, every day of the month, and every month of the year, which is equivalent to three times per month.
The other options are incorrect because:
A. This will run the job at any minute of the hour, but only at the 3rd, 4th, and 5th hour of the day (which are 3 a.m., 4 a.m., and 5 a.m.), and only on the 1st day of the month.
B. This will run the job at the 3rd minute of the hour, but only at the 3rd, 4th, and 5th hour of the day (which are 3 a.m., 4 a.m., and 5 a.m.), and only on the 1st day of the month.
D. This will run the job at the 0th minute of the hour (which is the top of the hour), but only at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.), and only on the 1st day of the month.
E. This will run the job at any minute of the hour, but only at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.), and only on the 1st day of the month.
References:
Crontab Explained in Linux [With Examples]
‘crontab’ in Linux with Examples - GeeksforGeeks
Linux Crontab Command Help and Examples - Computer Hope
Crontab in Linux with 20 Useful Examples to Schedule Jobs - TecAdmin
Linux crontab tutorial with Examples - Linux Tutorials - Learn Linux …
Which command can be used to delete a group from a Linux system?
groupdel
groupmod
groups
groupedit
The groupdel command is used to delete a group from a Linux system. It removes the group name from the /etc/group and /etc/gshadow files, but not the group’s configuration files, entries, or account files. The groupdel command requires root or sudo privileges and does not accept any options except for one for chroot. The groupdel command does not print any output on success, but it will display an error message if the group does not exist or if it is the primary group of an existing user. The groupdel command is part of the shadow-utils package, which provides tools for managing user and group accounts. The groupdel command is also compatible with the Linux Standard Base (LSB) specification, which defines a common set of commands and utilities for Linux distributions. References: 1234
Which command is used to add an empty group to the system? (Specify ONLY the command without any path or parameters.)
groupadd, /usr/sbin/groupadd
The groupadd command is used to add an empty group to the system. It takes the name of the group as an argument and creates an entry for it in the /etc/group file. The groupadd command also assigns a unique group ID (GID) to the new group. The groupadd command can take various options to specify the GID, the password, and other attributes of the new group. For example, groupadd -g 1000 mygroup will create a new group named mygroup with a GID of 1000. References:
Linux Groups - javatpoint
groupadd(8) - Linux manual page
How to Add and Delete User Groups on Linux
Which of the following steps prevents a user from obtaining an interactive login session?
Run the command chsh -s /bin/false with the user name.
Set the UID for the user to 0.
Remove the user from the group staff.
Add the user to /etc/noaccess.
Create a .nologin file in the user's home directory.
Running the command chsh -s /bin/false with the user name will change the user’s login shell to /bin/false, which is a program that does nothing and returns a non-zero exit code. This means that the user will not be able to execute any commands or start an interactive shell session. This is a common way to disable a user’s login without disabling the account completely, which can be useful for users who only need to access the system via scp, sftp, or other non-interactive services. However, this method does not prevent the user from authenticating with the system, and it may not work with some services that do not rely on the login shell, such as ssh with a forced command. Therefore, it is not a foolproof way to secure the system from unauthorized access. References: 1234
Which of the following crontab entries will execute myscript at 30 minutes past every hour on Sundays?
0 * * * 30 myscript
30 * * * 6 myscript
30 0 * * 0 myscript
30 0-23 * * 0 myscript
0 0-23 * * 30 myscript
The correct crontab entry for executing myscript at 30 minutes past every hour on Sundays is D. 30 0-23 * * 0 myscript. This is because the crontab format consists of six fields: minute, hour, day of month, month, day of week, and command. The values for each field can be:
A single number, such as 5 or 10.
A range of numbers, such as 1-5 or 10-15.
A list of numbers separated by commas, such as 1,3,5 or 10,12,14.
An asterisk (*), which means all possible values for that field.
A step value, which means every nth value for that field, such as */5 or 10-20/2.
The day of week field can be either a number from 0 to 6, where 0 and 7 are Sunday, or a three-letter abbreviation, such as SUN or MON. The month field can be either a number from 1 to 12, or a three-letter abbreviation, such as JAN or FEB.
In this case, the crontab entry D. 30 0-23 * * 0 myscript means:
30: Execute the command at the 30th minute of every hour.
0-23: Execute the command for every hour from 0 (midnight) to 23 (11 PM).
*: Execute the command for every day of the month, regardless of the month.
*: Execute the command for every month, regardless of the year.
0: Execute the command only on Sundays.
The other options are either incorrect or do not match the requirement. For example, option A. 0 * * * 30 myscript means:
0: Execute the command at the 0th minute of every hour.
*: Execute the command for every hour of the day.
*: Execute the command for every day of the month, regardless of the month.
*: Execute the command for every month, regardless of the year.
30: Execute the command only on the 30th day of the week, which is invalid.
References:
Crontab Explained in Linux [With Examples]
‘crontab’ in Linux with Examples - GeeksforGeeks
Crontab Syntax on Linux + Useful Examples - Hostinger
Where are user specific crontabs stored?
In the database file /etc/crontab.db which is shared by all users.
As individual per-user files within /var/spool/cron.
As individual per-user files in /etc/cron.user.d.
In the .crontab file in the user's home directory.
In the file /var/cron/user-crontab which is shared by all users.
The user-specific crontab files are stored in the /var/spool/cron/crontabs directory, where each file is named after the username of the owner. These files are not meant to be edited directly, but rather through the crontab command. The other options are either incorrect or non-existent locations for user crontab files. References:
Where is the user crontab stored?
crontab running as a specific user
Location of the crontab file
Where is the User Crontab Stored?
Which commands can be used to change a user's account aging information? (Choose THREE correct answers.)
usermod
passwd
chattr
chage
chsh
The usermod, passwd, and chage commands can be used to change a user’s account aging information. These commands can modify the password expiry date, the last password change date, the minimum and maximum number of days between password changes, the number of days of warning before password expiration, and the number of days of inactivity after password expiration. The usermod command is mainly used for modifying a user account, but it also has options for changing the password expiry and aging information, such as -e, -f, -p, and -L1. The passwd command is mainly used for changing the user password, but it also has options for changing the password expiry and aging information, such as -e, -i, -n, -w, and -x2. The chage command is specifically used for changing the user password expiry and aging information, and it has options such as -d, -E, -I, -m, -M, and -W3.
The other options, chattr and chsh, are not related to changing the user’s account aging information. The chattr command is used to change the file attributes on a Linux file system4. The chsh command is used to change the user’s login shell5.
References:
usermod(8) — Linux manual page
passwd(1) — Linux manual page
chage(1) — Linux manual page
chattr(1) — Linux manual page
chsh(1) — Linux manual page
Please specify the top directory containing the configuration files for the CUPS printing system. (Specify the full path to the directory.)
/etc/cups, /etc/cups/
The top directory containing the configuration files for the CUPS printing system is /etc/cups. This directory stores various files that control the behavior and functionality of the CUPS scheduler, cupsd (8), such as cups-files.conf (5), cupsd.conf (5), mime.convs (5), mime.types (5), printers.conf (5), and subscriptions.conf (5). The /etc/cups directory also contains subdirectories for classes, interfaces, ppd, and ssl, which store information about printer classes, device interfaces, printer drivers, and encryption certificates, respectively12. The /etc/cups directory is part of the LPI’s multi-level Linux professional certification program, and it is covered in the topic 105.5 Print service of the exam 102 objectives3. References: 1: cups-files (5) - Linux Manuals 2: cupsd.conf - server configuration file for cups 3: Exam 102 Objectives
Which of the following tasks can be accomplished using the command date? (Choose TWO correct answers.)
Synchronize the hardware and system clocks.
Output date and time in different formats.
Set the system clock.
Set the hardware clock.
Update the time via NTP.
The date command is used to display and set the system date and time. It can also be used to print the time in different formats and calculate future and past dates. The date command has the following syntax:
date [option]... [+format]
The format controls begin with the % symbol and are substituted by their current values. For example, to display the current year, month, and day, we can use the following command:
date +"Year: %Y, Month: %m, Day: %d"
To set the system clock manually, we can use the --set or -s option followed by the date and time string. For example, to set the date and time to 5:30 PM, May 13, 2010, we can use the following command:
date --set="20100513 05:30"
The other tasks are not possible with the date command because:
Synchronize the hardware and system clocks: The date command cannot synchronize the hardware and system clocks. To do this, we need to use the hwclock command, which can read or set the hardware clock, and also synchronize it with the system clock.
Set the hardware clock: The date command cannot set the hardware clock. To do this, we need to use the hwclock command with the --systohc or -w option, which will copy the system time to the hardware clock.
Update the time via NTP: The date command cannot update the time via NTP (Network Time Protocol). To do this, we need to use the ntpdate command, which will query an NTP server and set the system clock accordingly.
References:
Date Command in Linux: How to Set, Change, Format and Display Date
date command in Linux with examples - GeeksforGeeks
Date Command in Linux | Linuxize
Which of the following are syslog facilities? (Choose TWO correct answers.)
local5
advanced
postmaster
remote
The syslog facilities are predefined categories of messages that can be used to classify the source and type of the log events12. The syslog facilities are defined by the syslog protocol and are standardized across different implementations of syslog12. The syslog facilities are:
auth: Security and authorization messages, such as login failures or sudo usage12.
authpriv: Same as auth, but used for private security messages that should not be available to all users12.
cron: Messages from the cron daemon, such as scheduled jobs or errors12.
daemon: Messages from system daemons, such as sshd or ntpd12.
kern: Messages from the kernel, such as boot messages or hardware errors12.
lpr: Messages from the line printer subsystem, such as print jobs or errors12.
mail: Messages from the mail subsystem, such as sendmail or postfix12.
news: Messages from the network news subsystem, such as news servers or clients12.
syslog: Messages generated internally by the syslog daemon, such as configuration errors or restarts12.
user: Messages from user-level processes, such as applications or scripts12.
uucp: Messages from the Unix-to-Unix copy subsystem, such as file transfers or errors12.
local0 to local7: Custom facilities that are not used by any system processes and can be assigned to user applications or scripts123.
Therefore, the correct answers are A. local7 and B. mail, as they are both valid syslog facilities. The other options are not syslog facilities and are either made up (C. advanced and E. remote) or refer to a specific process rather than a category of messages (D. postmaster).
References: 1: Prepare for LPIC-1 exam 2 - topic 108.2: System logging - IBM Developer Tutorial 2: 108.2 System logging - Linux Professional Institute Certification Programs 3: What is the local6 (and all other local#) facilities in syslog?
Which of the following are commonly used Mail Transfer Agent (MTA) applications? (Choose THREE correct answers.)
Postfix
Procmail
Sendmail
Exim
SMTPd
Postfix, Sendmail, and Exim are three of the most commonly used Mail Transfer Agent (MTA) applications on Linux systems. An MTA is a software that transfers and routes electronic mail messages from one computer to another using the Simple Mail Transfer Protocol (SMTP). An MTA receives messages from another MTA or from a Mail User Agent (MUA), which is a computer application that end users use to access or send emails. An MTA can also query the MX records of the recipient’s domain to find the destination mail server and forward the message accordingly. An MTA can also perform other functions such as filtering, encryption, authentication, and bounce handling.
Postfix is a cross-platform, popular MTA that was designed and developed by Wietse Zweitze Venema for his mail server while working at the IBM research department. It was primarily developed as an alternative to well-known and popular Sendmail MTA. Postfix runs on Linux, Mac OSX, Solaris, and several other Unix-like operating systems. It borrows a lot of Sendmail properties on the outside, but it has a totally and comprehensively distinct internal operation. Additionally, it bids to be fast in performance with easy configurations and secure operation mechanism1.
Sendmail, now known as Proofpoint (after Proofpoint, Inc acquired Sendmail, Inc), is by far the most popular and one of the oldest MTA on the Linux server platform. Sendmail has a lot of limitations though, in comparison to modern MTAs. Because of its complicated configuration steps and demands, and weak security mechanisms, many new MTAs have come up as alternatives to Sendmail, but importantly, it offers everything to do with mail on a network1.
Exim is a free MTA developed for Unix-like operating systems such as Linux, Mac OSX, Solaris, and many more. Exim offers a great level of flexibility in routing mail on a network, with outstanding mechanisms and facilities for incoming mail monitoring. Its notable features include among others: no support for POP and IMAP protocols, supports protocols such as RFC 2821 SMTP and RFC 2033 LMTP email message transport, configurations include access control lists, content scanning, encryption, routing controls among others1.
Procmail is not an MTA, but a mail processing utility that can be used to filter, sort, and deliver incoming mail. It can be invoked by an MTA or run as a standalone program. Procmail can process mail based on various criteria such as sender, subject, header, body, size, date, and more. It can also execute external programs, forward mail to another address, or write mail to a file.
SMTPd is not an MTA, but a generic name for a daemon (a background process) that implements the SMTP protocol. A daemon is a program that runs continuously and performs certain tasks at predefined times or in response to certain events. An SMTP daemon listens for incoming SMTP connections from other MTAs or MUAs and handles the mail transfer accordingly. SMTPd can also refer to a specific SMTP daemon that is part of the OpenSMTPD project, which is a free implementation of the SMTP protocol for Unix systems. References:
7 Best Mail Transfer Agents (MTA’s) for Linux
Mail Transfer Agent (MTA) Explained | Mailtrap Blog
What is a Message Transfer Agent (MTA)? - Definition from Techopedia
Mail Transfer Agent (MTA) – Glossary of Email Terms | Mailgun
[Procmail - Wikipedia]
[SMTP daemon - Wikipedia]
What is pool.ntp.org?
A deprecated feature for maintaining system time in the Linux kernel
A website which provides binary and source packages for the OpenNTPD project
A virtual cluster of various timeservers
A community website used to discuss the localization of Linux
C. pool.ntp.org is indeed a virtual cluster of various timeservers. It provides a reliable and easy-to-use NTP (Network Time Protocol) service for millions of clients worldwide. The pool.ntp.org project allows systems to synchronize their clocks with internet time servers, which are part of a large virtual cluster1.
References:
pool.ntp.org: the internet cluster of ntp servers, which explains the purpose and functioning of the pool.ntp.org project.
How do I setup NTP to use the pool?, which provides instructions on how to use pool.ntp.org for time synchronization.
NTP pool - Wikipedia, which offers additional information about the NTP pool and its role in time synchronization across the internet.
What is the purpose of the command mailq?
It fetches new emails from a remote server using POP3 or IMAP.
It is a multi-user mailing list manager.
It is a proprietary tool contained only in the qmail MTA.
It queries the mail queue of the local MTA.
It is a command-line based tool for reading and writing emails.
The mailq command is a widely used tool for checking the email queue in Linux. It provides a summary of all the messages in the queue, including information such as message IDs, sender addresses, recipient addresses, and delivery status1. The mail queue is a collection of messages that are waiting to be delivered by the local Mail Transfer Agent (MTA), such as sendmail, postfix, or exim1. The mailq command is the same as the sendmail -bp command that also prints the mail queue2. The mailq command can also accept various options to filter or modify the output, such as -v for verbose mode, -Ac for mail submission queue, or -q for processing the queue3. The mailq command is part of the LPI’s multi-level Linux professional certification program, and it is covered in the topic 108.3 Mail Transfer Agent (MTA) basics of the exam 102 objectives4. References: 4: https://www.lpi.org/our-certifications/exam-102-objectives/ 3: https://www.thegeekdiary.com/mailq-command-examples-in-linux/ 2: https://sites.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/cmds/aixcmds3/mailq.htm 1: https://www.emaillistvalidation.com/blog/check-email-queue-in-linux-a-comprehensive-guide-to-managing-message-queues/
Which file, when using Sendmail or a similar MTA system, will allow a user to redirect all their mail to another address and is configurable by the user themselves?
/etc/alias
~/.alias
/etc/mail/forwarders
~/.forward
~/.vacation
The ~/.forward file is a file that users can create in their home directories to redirect mail or send mail using sendmail or a similar MTA system. The file contains a list of recipient addresses, which can be email addresses, file names, program names, or :include: files. The file must be owned by the user and have the read permission bit set for the owner. The file cannot be a symbolic link or have more than one hard link. The file is processed by sendmail when a recipient address selects a delivery agent with the F=w flag set. If the file contains a backslash, further processing is disabled and the message is delivered to the user’s mail-spooling directory. If the file does not exist or cannot be read, it is silently ignored. The ~/.forward file is different from the /etc/aliases file, which is a system-wide file that maps aliases to one or more recipient addresses. The /etc/aliases file is maintained by the system administrator and requires running the newaliases command after any changes. The ~/.alias file is not a valid file for sendmail or similar MTA systems. The /etc/mail/forwarders file is not a standard file for sendmail or similar MTA systems. The ~/.vacation file is a file that contains a vacation message that is sent to the sender when the user is away. The ~/.vacation file is used in conjunction with the vacation program, which can be invoked from the ~/.forward file. References:
You need to pause the CUPS printer HPLaserjet4, and you want to cancel all print jobs with a message, "hello". Which command will do this?
cupsreject -c -r hello HPLaserjet4
cupsreject -p -m hello HPLaserjet4
cupsdisable -c -r hello HPLaserjet4
cupsdisable -p -m hello HPLaserjet4
The command cupsdisable -c -r hello HPLaserjet4 will pause the CUPS printer HPLaserjet4 and cancel all print jobs with a message, “hello”. The cupsdisable command is used to stop printers and classes, while the cupsenable command is used to start them. The -c option cancels all jobs on the named destination, and the -r option sets the message associated with the stopped state. The message will be displayed to the users who try to print to the paused printer. For example, the output of lpstat -p HPLaserjet4 after running the command will show:
printer HPLaserjet4 disabled since Wed 23 Jun 2023 11:54:03 AM UTC -
hello
The other options are not correct. The cupsreject command is used to reject or accept jobs for a printer or class, not to pause or resume them. The -p and -m options are not valid for either cupsdisable or cupsreject. The correct syntax for cupsreject is:
cupsreject [ -E ] [ -U username ] [ -h server [:port] ] [ -r reason ] destination (s)
The -E option forces encryption of the connection to the server, the -U option uses the specified username when connecting to the server, the -h option uses the specified server and port, and the -r option sets the message associated with the rejecting state123. References: 1: cupsdisable(8) - Linux manual page 2: cupsreject(8) - Linux manual page 3: CUPS Administration - Page: 1.4 - Seite 3 » Raspberry Pi Geek
Which of the following is observed and corrected by a NTP client?
The skew in time between the system clock and the hardware clock.
The skew in time between the system clock and the reference clock.
Changes in the time zone of the current computer's location.
Adjustments needed to support Daylight Saving Time.
The Network Time Protocol (NTP) is a protocol that enables the accurate synchronization of time and date information across networked computer systems. NTP uses a hierarchical system of time servers, where each server has a stratum level that indicates its distance from the primary reference source. The primary reference source is usually an atomic clock or a GPS receiver, which provides the Coordinated Universal Time (UTC). The NTP clients are the computer systems that want to synchronize their system clocks with the UTC. The system clock is a software clock that runs in the kernel and keeps track of the current time and date. The system clock can be influenced by various factors, such as the hardware clock, the CPU frequency, the temperature, the load, and the network latency. These factors can cause the system clock to drift or skew from the UTC, resulting in inaccurate timekeeping. A NTP client observes and corrects the skew in time between the system clock and the reference clock, which is the clock of the NTP server that the client is connected to. The NTP client periodically sends requests to the NTP server and receives the server’s time stamps. The NTP client then calculates the offset and the round-trip delay between its system clock and the reference clock, and adjusts its system clock accordingly. The NTP client can also use multiple NTP servers and apply algorithms to select the best one and filter out outliers. The NTP client can also discipline the system clock by using a feedback loop that controls the clock frequency and reduces the clock drift. By using NTP, the system clock can achieve a high accuracy and precision, usually within a few milliseconds or microseconds of the UTC123.
The other options are not correct. The skew in time between the system clock and the hardware clock is not observed and corrected by a NTP client, but by a separate utility called hwclock, which can read and set the hardware clock. The hardware clock is a battery-powered device that keeps time even when the system is powered off. The hardware clock is usually less accurate than the system clock, and can be synchronized with the system clock at boot or shutdown time. The changes in the time zone of the current computer’s location are not observed and corrected by a NTP client, but by a configuration tool called timedatectl, which can set the system time zone and other parameters. The time zone is a geographical region that has a uniform standard time and date. The time zone does not affect the system clock, which always keeps the UTC, but only the display of the local time and date for the user. The adjustments needed to support Daylight Saving Time (DST) are not observed and corrected by a NTP client, but by the system’s time zone database, which contains the rules and transitions for DST. DST is a practice of advancing the clocks by one hour during summer months to make better use of daylight. DST is not observed in all regions and countries, and can vary in start and end dates. The system’s time zone database is updated regularly to reflect the changes in DST rules, and can be applied to the system clock to calculate the correct local time and date. References: 1: Network Time Protocol - Wikipedia 2: How NTP Works - NTP Pool Project 3: How To Set Up Time Synchronization on Ubuntu 20.042 : hwclock(8) - Linux manual page : timedatectl(1) - Linux manual page : Daylight saving time - Wikipedia
To exclude all log messages of a given logging facility, you should use a logging priority of _____ .
none
To exclude all log messages of a given logging facility, you should use a logging priority of none. This means that no messages from that facility will be logged, regardless of their severity level. For example, if you want to exclude all messages from the local0 facility, you can use local0.none in your syslog configuration file. This will prevent any messages from local0 from being written to any log file or destination that matches that selector12. The logging priority of none is part of the LPI’s multi-level Linux professional certification program, and it is covered in the topic 106.1 System logging of the exam 102 objectives3. References: 1: logging - exclude syslog facility from all others - Server Fault 2: rsyslog.conf(5) - Linux manual page - man7.org 3: Exam 102 Objectives
Which of the following is a legacy program provided by CUPS for sending files to the printer queues on the command line?
lpd
lpp
lpq
lpr
The lpr command is a legacy program provided by CUPS for sending files to the printer queues on the command line. It is one of the Berkeley (lpr) printing commands that CUPS supports for compatibility with other Unix-like systems. The lpr command accepts one or more filenames as arguments and sends them to the default or specified printer. It also supports several options to control the printing process, such as the number of copies, the page size, the orientation, and the priority. The lpr command is equivalent to the lp command, which is one of the System V (lp) printing commands that CUPS also supports. However, the lp command has more options and features than the lpr command, and is recommended for use with CUPS. References:
Command-Line Printing and Options - CUPS
Command-Line Printer Administration - CUPS
Linux cups tutorial for beginners - Linux Tutorials - Learn Linux …
CUPS Command-Line Utilities - Configuring and Managing … - Oracle
What command can be used to generate syslog entries of any facility and priority? (supply just the command name without a path)
logger
The logger command can be used to generate syslog entries of any facility and priority. It is a shell command interface to the syslog system log module. It allows users to write messages to the system log from the command line or from a script. The logger command supports several options to specify the facility, priority, tag, message, and other attributes of the log entry. For example, the following command generates a log entry with the facility user and the priority info:
logger -p user.info “This is a test message”
The facility and priority can be any of the values defined in the syslog protocol, such as kern, mail, auth, local0, etc. for the facility, and emerg, alert, crit, err, warn, notice, info, debug, etc. for the priority. The default facility is user and the default priority is notice. The logger command can also read messages from standard input or from a file. For more information, see the logger man page or the logger - Linux man page online. References:
Syslogs in Linux: Understanding Facilities and Levels
What are Syslog Facilities and Levels? - Trend Micro
syslog-ng Open Source Edition 3.30 - Administration Guide
Syslog Logging Guide: Advanced Concepts - CrowdStrike
What is the purpose of the nsswitch.conf file?
It is used to configure where the C library looks for system information such as host names and user passwords.
It is used to configure network protocol port numbers such as for HTTP or SMTP.
It is used to configure LDAP authentication services for the local system.
It is used to configure which network services will be turned on during the next system boot.
The nsswitch.conf file is a configuration file that determines the sources and the order of the sources that are queried for various system databases, such as user information, group information, host names, network services, and more. The C library uses this file to look up various system information when a program or a command requests it. For example, when a user logs in, the C library will use the nsswitch.conf file to determine where to find the user’s password, whether it is in the local /etc/passwd file, or in a remote LDAP server, or both. The nsswitch.conf file allows the system administrator to configure the system databases in a flexible and modular way. References:
[LPI Linux Essentials - Topic 106: The Linux Operating System]
[LPI Linux Administrator - Exam 102 Objectives - Topic 110: Security]
[Linux man page for nsswitch.conf]
Which of the following tools used for DNS debugging, reports not only the response from the name server but also details about the query?
dnsq
dig
hostname
dnslookup
zoneinfo
The tool that reports not only the response from the name server but also details about the query is dig. Dig stands for domain information groper and it is a command-line tool that can query DNS servers for various types of records. Dig can also provide additional information such as the query time, the server address, the query options, and the response code. Dig is a powerful and flexible tool that can be used for DNS troubleshooting and testing123 References:
1: How to use the dig command - Linux.com
2: dig(1) - Linux manual page - man7.org
3: Top 6 Tools for DNS Troubleshooting | Total Uptime®
How many IP-addresses can be used for unique hosts inside the IPv4 subnet 192.168.2.128/28? (Specify the number only without any additional information.)
14
To find the number of IP-addresses that can be used for unique hosts inside an IPv4 subnet, we need to calculate the number of bits that are used for the host part of the IP address. The host part is the part that is not used for the network prefix, which is indicated by the slash notation (/) followed by a number. The number after the slash represents the number of bits that are used for the network prefix, out of the total 32 bits of an IPv4 address. The remaining bits are used for the host part. For example, in the subnet 192.168.2.128/28, the number 28 means that the first 28 bits are used for the network prefix, and the last 4 bits are used for the host part.
The number of IP-addresses that can be used for unique hosts is equal to 2^n - 2, where n is the number of bits in the host part. The -2 is because the first and the last IP addresses in a subnet are reserved for the network address and the broadcast address, respectively, and cannot be assigned to hosts. Therefore, in the subnet 192.168.2.128/28, the number of IP-addresses that can be used for unique hosts is 2^4 - 2, which is 14.
References:
IPv4 - Subnetting - Online Tutorials Library
IP Subnet Calculator
Which of the following keywords can be used in the file /etc/resolv.conf? (Choose TWO correct answers.)
substitute
nameserver
search
lookup
method
The file /etc/resolv.conf is the configuration file for the DNS resolver, which translates domain names to IP addresses by querying the DNS servers. The file supports several keywords that provide various types of resolver information. Two of the keywords that can be used in /etc/resolv.conf are:
nameserver: This keyword specifies the IP address of the DNS server that the resolver can query against. Up to three nameservers can be configured, and the resolver will try them in order until one responds or all fail.
search: This keyword specifies a list of search domains that the resolver will append to the domain name when performing a query. For example, if the search list is example.com example.net, and the resolver queries for host, it will try host.example.com and host.example.net in order. The search list can have up to six domains, with a maximum of 256 characters in total.
The other keywords in the question are not valid for /etc/resolv.conf. The file does not support any keywords for substitution, lookup, or method. However, there are other keywords that can be used, such as:
domain: This keyword specifies the local domain name of the system. It is mutually exclusive with the search keyword, and only one instance of either can be used.
options: This keyword specifies various options that modify the behavior of the resolver. For example, the option rotate can be used to rotate the nameservers in a round-robin fashion, instead of trying them in order. Multiple options can be specified, separated by spaces.
References:
3: The /etc/resolv.conf File | Baeldung on Linux
1: /etc/resolv.conf - QNX
4: Chapter 33. Manually configuring the /etc/resolv.conf file
Which keyword must be listed in the hosts option of the Name Service Switch configuration file in order to make host lookups consult the /etc/hosts file?
files
The keyword files must be listed in the hosts option of the Name Service Switch configuration file in order to make host lookups consult the /etc/hosts file. The files service specifies that the local files, such as /etc/hosts, should be used as a source of information. The order of the services on the line determines the order in which those services will be queried, in turn, until a result is found. For example, if the hosts option is set to:
hosts: files dns
then the /etc/hosts file will be searched first, and if no match is found, the DNS server will be queried next. If the hosts option is set to:
hosts: dns files
then the DNS server will be queried first, and if no match is found, the /etc/hosts file will be searched next. References:
LPI 102-500 Exam Objectives, Topic 110: Network Fundamentals, Weight: 4, 110.3 Basic network troubleshooting
LPI 102-500 Study Guide, Chapter 10: Network Fundamentals, Section 10.3: Basic Network Troubleshooting, Page 125-126
nsswitch.conf: Name Service Switch configuration file
Which of the following is a valid IPv6 address?
2001:db8:3241::1
2001::db8:4581::1
2001:db8:0g41::1
2001%db8%9990%%1
2001.db8.819f..1
A valid IPv6 address is represented as a set of 16-bit hexadecimals separated by colons. The address is divided into eight groups, and each 16-bit group is represented by four hexadecimal numbers. A valid IPv6 address is in the form “x1:x2:x3:x4:x5:x6:x7:x8” where each xi is a hexadecimal string which may contain digits, lower-case English letter (‘a’ to ‘f’) and upper-case English letters (‘A’ to ‘F’). Leading zeros are allowed in xi. The longest sequence of consecutive all-zero fields is replaced with two colons (::).1
Option A is the only one that follows these rules. Option B has two consecutive colons twice, which is not allowed. Option C has an invalid hexadecimal character ‘g’. Option D uses percentage signs instead of colons, which is not a valid separator. Option E uses dots instead of colons, and has two consecutive dots, which are both invalid.
References: 1: IPv4 and IPv6 address formats - IBM
Which of the following details is NOT provided in any output from the netstat utility?
broadcast services
interface statistics
masquerading connections
network connections
routing tables
The netstat utility is a command-line tool that displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It can be used with various options to filter and customize the output. However, it does not provide any information about broadcast services, which are a type of network communication that sends data to all devices on a network segment. Broadcast services are usually handled by other tools, such as ping, traceroute, or arp.
References:
netstat | Microsoft Learn
28 Netstat Commands {A Comprehensive List With Examples} - phoenixNAP
What is the command to delete the default gateway from the system IP routing table? (Choose TWO correct answers.)
route del default
ifconfig unset default
netstat -r default
ip route del default
sysctl ipv4.default_gw=0
The command to delete the default gateway from the system IP routing table is either route del default or ip route del default. Both commands will remove the default route that matches the specified parameters. The route command is the older and more widely supported tool, while the ip command is the newer and more powerful tool that can manipulate various aspects of the network configuration. The other options are either invalid or do not affect the default gateway. References:
1: How to Remove Default Gateways via ip | Baeldung on Linux
2: How to remove all default gateways - Unix & Linux Stack Exchange
4: How to Add or Change the Default Gateway in Linux: 9 Steps - wikiHow
Given the following routing table:
How would an outgoing packet to the destination 192.168.2.150 be handled?
It would be passed to the default router 192.168.178.1 on wlan0.
It would be directly transmitted on the device eth0.
It would be passed to the default router 255.255.255.0 on eth0.
It would be directly transmitted on the device wlan0.
It would be passed to the router 192.168.1.1 on eth0.
The routing table shows how the kernel will route packets to different destinations based on the destination IP address, the gateway, the netmask, the flags, the metric, and the interface. The kernel will try to find the most specific route that matches the destination IP address, which means the route with the longest netmask. If there are multiple routes with the same netmask, the kernel will use the route with the lowest metric. If there is no matching route, the kernel will use the default route, which is the route with the destination 0.0.0.0.
In this case, the destination IP address is 192.168.2.150, which belongs to the network 192.168.2.0/24. The routing table has a specific route for this network, which is the second entry. The gateway for this route is 0.0.0.0, which means that the packet will be directly transmitted on the interface eth0, without passing through any router. The netmask for this route is 255.255.255.0, which means that the network has 256 possible hosts. The flags for this route are U, which means that the route is up, and G, which means that the route is to a gateway. The metric for this route is 0, which means that it has the highest priority. Therefore, the kernel will use this route to handle the outgoing packet to the destination 192.168.2.150.
References:
How To Display Routing Table In Linux - RootUsers
route command in Linux with Examples - GeeksforGeeks
Understand the basics of Linux routing | TechRepublic
With IPv6, how many bits have been used for the interface identifier of an unicast address? (Specify the number using digits only.)
64
With IPv6, the interface identifier of an unicast address is typically a 64-bit value that is used to identify a host’s network interface. The interface identifier can be derived from the MAC address of the network card, or it can be randomly generated or manually configured. The interface identifier is the rightmost 64 bits of the most commonly encountered address types, such as global unicast (2000::/3) and link-local (fe80::/10). The interface identifier is different from the network prefix, which is the leftmost bits of the address that indicate the network or subnet to which the host belongs. The network prefix can vary in length, depending on the address type and the subnetting scheme. The network prefix and the interface identifier are separated by a double colon (::) in the IPv6 address notation. For example, in the address 2001:db8:1234:5678:abcd:ef12:3456:7890, the network prefix is 2001:db8:1234:5678 and the interface identifier is abcd:ef12:3456:7890. References: https://study-ccna.com/ipv6-interface-identifier/
https://networklessons.com/ipv6/ipv6-eui-64-explained
What is the lowest numbered unprivileged TCP port? (Specify the number in digits only.)
1024
The lowest numbered unprivileged TCP port is 1024. A port number is a 16-bit unsigned integer, thus ranging from 0 to 65535. The port numbers in the range from 0 to 1023 are the well-known ports or system ports. They are used by system processes that provide widely used types of network services. On Unix-like operating systems, a process must execute with superuser privileges to be able to bind a network socket to an IP address using one of the well-known ports. Therefore, the lowest numbered port that can be used by a normal user without root access is 1024, which is the first unprivileged port123 References:
1: How to bind to port number less than 1024 with non root access?
2: lowest numbered unprivileged TCP port - Bing
3: List of TCP and UDP port numbers - Wikipedia
4: Privileged Ports - World Wide Web Consortium (W3C)
5: What is the lowest TCP port number? – TeachersCollegesj
Which of the following commands will help identify a broken router between the local and the remote machine?
ps
netstat
nslookup
ifconfig
traceroute
The traceroute command will help identify a broken router between the local and the remote machine. The traceroute command sends a series of packets with increasing time-to-live (TTL) values to a destination and displays the routers that the packets pass through along the way. If a router is broken or unreachable, the traceroute command will show a * symbol or a timeout message. The traceroute command is part of the topic 109.1: Fundamentals of internet protocols, which is one of the objectives of the LPI Linux Administrator - 102 exam12. References: 1: https://learning.lpi.org/en/learning-materials/102-500/ 2: https://www.lpi.org/our-certifications/exam-102-objectives/
What is the default name of the configuration file for the Xorg X11 server? (Specify the file name only without any path.)
xorg.conf
The default name of the configuration file for the Xorg X11 server is xorg.conf. This file is used to store initial setup for X, such as settings for video cards, monitors, input devices, and other options. The Xorg X11 server is a display server that uses a configuration file called xorg.conf and files ending in the suffix .conf for its initial setup1. The xorg.conf file is typically located in /etc/X11/xorg.conf, but its location may vary across operating system distributions2. The xorg.conf file is not mandatory, as the Xorg X11 server can automatically configure most hardware and settings. However, it can be created and edited manually if needed3. References:
Xorg - ArchWiki
xorg.conf - Wikipedia
How to Configure X11 in Linux: 10 Steps (with Pictures) - wikiHow
X is running okay but you're concerned that you may not have the right color depth set. What single command will show you the running color depth while in X?
xcd
xcdepth
xwininfo
xcolordepth
cat /etc/X11
The xwininfo command is a utility for displaying information about windows on an X server. One of the information it displays is the depth of the window, which is the number of bits per pixel used to represent the color of the window. The depth of the root window, which is the background window of the X server, is the same as the color depth of the X server. To display the depth of the root window, one can use the command xwininfo -root and look for the line that says “depth of root window”. Alternatively, one can use the command xdpyinfo, which displays information about the X server, and look for the line that says “depths of root window”. References:
xwininfo(1) - Linux man page
xdpyinfo(1) - Linux man page
[LPI Linux Certification/Configure the X Window System, Xorg and …]
Which of the following are tasks handled by a display manager like XDM or KDM? (Choose TWO correct answers.)
Start and prepare the desktop environment for the user.
Configure additional devices like new monitors or projectors when they are attached.
Handle the login of a user.
Lock the screen when the user was inactive for a configurable amount of time.
Create an X11 configuration file for the current graphic devices and monitors.
The tasks that are handled by a display manager like XDM or KDM are to start and prepare the desktop environment for the user and to handle the login of a user. A display manager is a software component that manages the graphical user interface of an operating system. It provides a login screen where the user can enter their credentials and choose their preferred desktop environment or window manager. After the user is authenticated, the display manager launches the selected desktop environment or window manager and sets up the graphical session. The display manager also handles the logout, shutdown, and reboot of the system.
The other options are incorrect because they are not tasks handled by a display manager:
B. Configure additional devices like new monitors or projectors when they are attached. This task is handled by the X server, which is the core component of the X Window System. The X server is responsible for communicating with the hardware devices, such as the keyboard, mouse, monitor, and graphics card. The X server can detect and configure new devices dynamically using tools like xrandr or xorg.conf.
D. Lock the screen when the user was inactive for a configurable amount of time. This task is handled by the screensaver program, which is a utility that runs in the background and activates when the user is idle for a certain period of time. The screensaver can display various animations or images on the screen, or it can blank the screen entirely. The screensaver can also lock the screen and require the user to enter their password to resume the session. The screensaver can be configured by the user using tools like xscreensaver or gnome-screensaver.
E. Create an X11 configuration file for the current graphic devices and monitors. This task is handled by the X server, which is the core component of the X Window System. The X server can create an X11 configuration file, which is a text file that contains the settings for the X server and the devices it communicates with. The X11 configuration file is usually located at /etc/X11/xorg.conf or /etc/X11/xorg.conf.d/. The X server can generate a default configuration file using the command Xorg -configure, or it can be edited manually by the user or the system administrator. References https://www.baeldung.com/linux/display-managers-explained
https://quizlet.com/185979426/lx0-104-flash-cards/
Which of the following lines is an example of a correct setting for the DISPLAY environment variable?
hostname:displayname
hostname:displaynumber
hostname/displayname
hostname/displaynumber
hostname
The correct format for the DISPLAY environment variable is hostname:displaynumber.screennumber, where hostname is the name of the computer where the X server runs, displaynumber is a sequence number (usually 0) that identifies a display, and screennumber is the number of the screen within that display (usually 0). The screennumber can be omitted if it is 0. For example, localhost:0 or myhost:1.0 are valid values for the DISPLAY variable. The other options are either missing the colon, using the wrong separator, or not specifying the display number. References:
X11 - DISPLAY (environment variable) - Datacadamia
x11 - How can I specify a display? - Stack Overflow
What is the $DISPLAY environment variable? - Ask Ubuntu
An administrator wants to determine the geometry of a particular window in X, so she issues the __________ -metric command and then clicks on the window.
/usr/bin/xwininfo, xwininfo
The xwininfo command is a utility for displaying information about windows in X. It can show various attributes of a window, such as its location, size, depth, border width, visual class, colormap, map state, and event masks. The -metric option specifies that all dimensions should be displayed in metric units (millimeters) rather than pixels. By issuing the xwininfo -metric command and then clicking on a window, the administrator can determine the geometry of that window, including the decorations, in millimeters. References:
xwininfo(1) — Arch manual pages
[command line -
What is the purpose of the Sticky Keys feature in X?
To assist users who have difficulty holding down multiple keys at once
To prevent repeated input of a single character if the key is held down
To ignore brief keystrokes according to a specified time limit
To repeat the input of a single character
The Sticky Keys feature in X is an accessibility option that allows users to press modifier keys (such as Ctrl, Alt, Shift, or the Windows key) one at a time, instead of holding them down simultaneously, to perform keyboard shortcuts. For example, to copy something, a user can press Ctrl, release it, and then press C, instead of pressing Ctrl+C together. This can be helpful for users who have difficulty pressing multiple keys at once, or who prefer not to do so. References: https://www.howtogeek.com/739764/how-to-turn-off-sticky-keys-on-windows-10/
https://geekflare.com/using-sticky-keys-in-windows/
Your senior administrator asked you to change the default background of his machine, which uses XDM. Which file would you edit to achieve this?
/etc/X11/xdm/Xsetup
/etc/X11/xdm.conf
/etc/X11/xdm/Defaults
/etc/X11/defaults.conf
The file /etc/X11/xdm/Xsetup contains commands that are executed by XDM before displaying the login screen. This file can be used to set the background image, color, or run other programs on the X display. The other files are either not related to XDM or do not exist by default. References:
XDM - ArchWiki
Customizing the XDM Login Screen | Linux Journal
For accessibility assistance, which of the following programs is an on-screen keyboard?
xkb
atkb
GOK
xOSK
GOK stands for GNOME On-screen Keyboard, and it is a program that provides a virtual keyboard for users who have difficulty using a physical keyboard. GOK is designed to be accessible and customizable, and it supports different keyboard layouts, input methods, and modes. GOK can also generate mouse and gesture events, and it can be controlled by various input devices, such as switches, joysticks, or head trackers. GOK is part of the GNOME desktop environment, and it can be enabled from the Universal Access settings panel123.
The other options are not correct because:
A. xkb is not a program, but a component of the X Window System that handles keyboard configuration and mapping. XKB stands for X Keyboard Extension, and it allows users to define the behavior and appearance of their keyboards, such as the layout, the modifiers, the symbols, and the actions. XKB does not provide an on-screen keyboard, but it can be used by other programs that do45.
B. atkb is not a valid name for any known program or component related to on-screen keyboards. There is no such program or component in the LPI Linux certification program or in the common Linux distributions. The closest match is ATK, which stands for Accessibility Toolkit, and it is a library that provides a set of interfaces for accessibility support in GNOME applications. ATK does not provide an on-screen keyboard, but it can be used by GOK and other programs that do6 .
D. xOSK is a program that provides an on-screen keyboard, but it is not the one that is mentioned in the LPI Linux certification program or in the common Linux distributions. xOSK stands for X On-Screen Keyboard, and it is a simple and lightweight virtual keyboard that can be used with any X11 application. xOSK is not part of any desktop environment, and it has to be installed and launched manually. xOSK is not as accessible and customizable as GOK, and it does not support different input methods or modes .
References: 1: GOK - GNOME Wiki! 2: How to Set Up a Virtual On-Screen Keyboard in Linux 3: Working With On-Screen Keyboards - Oracle Help Center 4: X keyboard extension - Wikipedia 5: XKB Configuration Guide 6: Accessibility Toolkit - GNOME Developer : Accessibility - ArchWiki : xosk - X On-Screen Keyboard : How to use on-screen virtual keyboard on Linux - Xmodulo
What is the purpose of a screen reader?
It reads text displayed on the screen to blind or visually impaired people.
It reads the parameters of the attached monitors and creates an appropriate X11 configuration.
It displays lines and markers to help people use speed reading techniques.
It manages and displays files that contain e-books.
A screen reader is a form of assistive technology that renders text and image content as speech or braille output. Screen readers are essential to people who are blind, and are useful to people who are visually impaired, illiterate, or have a learning disability. Linux has several screen readers available, such as Orca, Speakup, and Emacspeak. These screen readers can help users interact with the graphical or console interface, read documents and web pages, and perform various tasks on the system. References:
Screen reader - Wikipedia
Orca Screen Reader - GNOME
Accessibility in Linux is good (but could be much better)
The X11 configuration file xorg.conf is grouped into sections. How is the content of the section SectionName associated with that section?
It is placed in curly brackets as in Section SectionName { ... }.
It is placed between a line containing Section "SectionName" and a line containing EndSection.
It is placed between the tags
It is placed after the row [SectionName].
It is placed after an initial unindented Section "SectionName" and must be indented by exactly one tab character.
The X11 configuration file xorg.conf is grouped into sections, and the content of the section SectionName is associated with that section by placing it between a line containing Section “SectionName” and a line containing EndSection. For example, the following is a section named ServerLayout that defines the layout of the X server:
Section “ServerLayout” Identifier “X.org Configured” Screen 0 “Screen0” 0 0 InputDevice “Mouse0” “CorePointer” InputDevice “Keyboard0” “CoreKeyboard” EndSection
The other options are incorrect for the following reasons:
A: Curly brackets are not used to delimit sections in xorg.conf. They are used to enclose values that are lists, such as Option “XkbLayout” “{us,fr}”.
C: Tags are not used to delimit sections in xorg.conf. They are used in XML files, which have a different syntax and structure than xorg.conf.
D: Rows are not used to delimit sections in xorg.conf. They are used to define key-value pairs within a section, such as Identifier “Screen0”.
E: Indentation is not required to delimit sections in xorg.conf. It is used to improve readability and clarity, but it does not affect the functionality of the file.
References:
xorg.conf - X Window System
Editing basics for the xorg.conf file - Linux.com
106.1 Lesson 1 - Linux Professional Institute Certification Programs
Which command can be used to investigate the properties for a particular window in X by clicking that window? (Specify ONLY the command without any path or parameters.)
/usr/bin/xwininfo, xwininfo
The command that can be used to investigate the properties for a particular window in X by clicking that window is xwininfo. xwininfo is a command-line tool that provides information about X windows. When executed, it opens a small window and waits for the user to select a window by clicking on it. Then, it displays various characteristics about the window in question, such as its geometry, position, size, depth, class, name, id, and more. xwininfo is part of the X Window System, which is a graphical user interface system for Unix-like operating systems. xwininfo can be useful for debugging, testing, or scripting purposes. References: https://bing.com/search?q=command+to+investigate+properties+of+a+window+in+X
https://www.exam-answer.com/linux-foundation-certified-system-administrator-lfcs-simulation-investigate-window-properties
Which file used by XDM specifies the default wallpaper?
/etc/X11/xdm/Xsetup
/etc/X11/xdm.conf
/etc/X11/xdm/Defaults
/etc/X11/defaults.conf
The file that specifies the default wallpaper for XDM is /etc/X11/xdm/Xsetup. XDM is a display manager for the X Window System that provides a graphical login screen and manages user sessions. The /etc/X11/xdm/Xsetup file is executed when XDM starts the X server and before any user login or session starts. This file can be used to configure the X server, set X resources, and perform any other system-wide setup tasks, such as setting the wallpaper. To set the wallpaper, one can use a command like qiv -z /usr/local/share/backgrounds/wallpaper.jpg in the /etc/X11/xdm/Xsetup file, where qiv is an image viewer and /usr/local/share/backgrounds/wallpaper.jpg is the path to the desired wallpaper image1.
The other options are not correct/etc/X11/xdm.conf is the configuration file for XDM, which specifies how XDM should behave, such as the access control, the login window, and the session types2/etc/X11/xdm/Defaults is the directory where the default XDM configuration files are stored, such as Xresources, Xsession, and Xwilling2. /etc/X11/defaults.conf is not a valid file or directory related to XDM or X Window System. References:
XDM - ArchWiki
Configuring XDM - Linux Documentation Project
Which of the following commands displays all environment and shell variables?
getargs
lsenv
ls
env
lsshell
The command that displays all environment and shell variables is env. The env command prints a list of the current environment variables, which are variables that are defined for the current shell and are inherited by any child shells or processes. The env command can also be used to run another program in a custom environment without modifying the current one1. The env command is part of the GNU coreutils package and is available on most Linux systems2.
The other commands are not valid or do not display all environment and shell variables. The getargs command does not exist in Linux. The lsenv command is a utility to list information about IBM Power Systems firmware, not environment variables. The ls command lists the files and directories in the current working directory, not environment variables. The lsshell command is a utility to list the available shells on a system, not environment variables.
References:
LPI Linux Essentials: 1.4. Using sudo
LPI Linux Administrator: 102.5. Use Debian package management
LPI Linux Engineer: 201.1. Measure and Troubleshoot Resource Usage
LPI Linux Professional Certification Program
https://linuxconfig.org/how-to-set-and-list-environment-variables-on-linux
https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-linux
https://unix.stackexchange.com/questions/176001/how-can-i-list-all-shell-variables
Which of the following features are provided by SPICE? (Choose two.)
Connecting local USB devices to remote applications.
Accessing graphical applications on a remote host.
Replacing Xorg as local X11 server.
Downloading and locally installing applications from a remote machine.
Uploading and running a binary program on a remote machine.
SPICE is a protocol that allows users to access graphical applications on a remote host, such as a virtual machine or a server, using a client program. SPICE also supports connecting local USB devices to remote applications, such as printers, scanners, or flash drives, using a feature called USB redirection. SPICE does not replace Xorg as the local X11 server, nor does it allow downloading and locally installing applications or uploading and running binary programs from a remote machine. These are features that are provided by other tools, such as SSH, SCP, or RDP. References:
Features - spice-space.org
SPICE - Wikipedia
SPICE Model <What is SPICE?> | Electronics Basics | ROHM
Which parameter of the ssh command specifies the location of the private key used for login attempts? (Specify ONLY the option name without any values or parameters.)
ssh-keygen
Where is the system journal stored?
/var/ jlog/ and /var/jlogd/
/proc/log and /proc/klog
/run/Iog/journal/or/var/log/journal/
/var/log/syslog.bin or /var/log/syslog-jrn
/etc/system/journal / or /usr/1ib/sysLend/journal/
Which of the following programs uses the hosts.allow file to perform its main task of checking for access control restrictions to system services?
tcpd
inetd
fingerd
mountd
xinetd
The tcpd program is a wrapper for network services that use the TCP protocol. It intercepts incoming connection requests and checks them against the rules specified in the /etc/hosts.allow and /etc/hosts.deny files. If the connection is allowed, tcpd executes the actual service program and passes the connection to it. If the connection is denied, tcpd logs the attempt and sends an error message to the client. The tcpd program can be used to enhance the security and control of network access to various services, such as SSH, FTP, Telnet, etc.
The other programs listed are not directly related to the hosts.allow file, although they may be affected by it if they are wrapped by tcpd. The inetd and xinetd programs are super-servers that listen for incoming connections and launch the appropriate service program. The fingerd program is a service that provides information about users on a remote system. The mountd program is a service that handles NFS mount requests from clients. References:
tcpd(8) - Linux man page
Control server access using hosts.allow and hosts.deny files
hosts.allow format and example on Linux
Which of the following find commands will print out a list of files owned by root and with the SUID bit set in /usr?
find /usr -uid 0 -perm +4000
find -user root +mode +s /usr
find -type suid -username root -d /usr
find /usr -ls \*s\* -u root
find /usr -suid -perm +4000
This command will find all the files in the /usr directory that have the user ID (UID) of 0, which is the root user, and have the permission of 4000, which is the SUID bit. The SUID bit allows the file to be executed with the privileges of the file owner, regardless of who runs it. The -uid option tests for a specific UID, and the -perm option tests for a specific permission. The + sign before the permission means that at least those bits are set; the - sign means that exactly those bits are set. The other options are either invalid or do not match the criteria. References:
LPIC-1 Exam 102 Objectives, Topic 104: Devices, Linux Filesystems, Filesystem Hierarchy Standard, 104.4 Find system files and place files in the correct location, Key Knowledge Areas: Search for files by type, size, or time
find manual page, -uid and -perm options description
Find Command in Linux with Practical Examples, Example 8: Find Files with SUID and SGID Permissions
Which of Ihe following commands sets the system's time zone to the Canadian Eastern Time?
A)
B)
C)
D)
E)
Option A
Option B
Option C
Option D
Option E
What is Irue regarding public and private SSH keys? (Choose TWO correct answers.)
For each user account, there is exactly one key pair that can be used to log into that account.
The private key must never be revealed to anyone.
Several different public keys may be generated (or the same private key.
To maintain the private key's confidentiality, the SSH key pair must be created by its owner.
To allow remote logins, the user's private key must be copied to the remote server.
Which of the following commands preloads and manages keys that are used for automatic authentication while logging in to other machines using SSH?
sshd
ssh-agent
ssh-keygen
ssh-add
The ssh-agent command is a program that runs in the background and acts as a key manager for SSH. It can store multiple private keys in memory and provide them to SSH clients when needed. This way, the user does not have to enter the passphrase for each key every time they log in to another machine using SSH. The ssh-agent can also forward the authentication request to another agent running on the original machine, allowing the user to hop between different machines without re-entering the passphrase1.
To use ssh-agent, the user needs to start it and add the private keys to it using the ssh-add command. The ssh-add command can also list, delete, and lock the keys stored in the agent. The user can then use the SSH_AUTH_SOCK environment variable to connect to the agent and use the keys for authentication2.
The other commands are not related to the ssh-agent. The sshd command is the SSH server daemon that listens for incoming connections and handles the authentication and encryption. The ssh-keygen command is a tool for generating, managing, and converting SSH keys. The ssh command is the SSH client that initiates the connection to the remote machine3. References: 1: SSH Essentials: Working with SSH Servers, Clients, and Keys. 2: [ssh-agent(1) - Linux manual page]. 3: SSH command usage, options, and configuration in Linux/Unix.
What does the term Braille Display refer to?
A standardized high contract graphical theme for desktop applications
A Linux desktop environment similar to KDE and GNOME.
A legacy display technology superseded by LCD.
A physical representation of characters using small dots.
A standard file format for data exchange, similar to XML
Copyright © 2014-2024 Certensure. All Rights Reserved