Topic 1, Shells, Scripting and Data Management
What output will the following command sequence produce?
echo ‘1 2 3 4 5 6’ | while read a b c; do
echo result: $c $b $a;
done
- A . result: 3 4 5 6 2 1
- B . result: 1 2 3 4 5 6
- C . result: 6 5 4
- D . result: 6 5 4 3 2 1
- E . result: 3 2 1
E
Explanation:
The while loop reads a line from the standard input and splits it into words using the IFS variable, which by default contains spaces, tabs, and newlines. The read command assigns the first word to the variable a, the second word to the variable b, and the rest of the line to the variable c. Therefore, in this case, a=1, b=2, and c=3 4 5 6. The echo command prints the values of c, b, and a in reverse order, separated by spaces. The output is result: 3 2 1. The loop terminates after reading the first line, since there is no more input to read.
Reference: Bash while Loop | Linuxize, Bash Scripting – While Loop – GeeksforGeeks
When the command echo $ outputs 1, which of the following statements is true?
- A . It is the process ID of the echo command.
- B . It is the process ID of the current shell.
- C . It is the exit value of the command executed immediately before echo.
- D . It is the exit value of the echo command.
C
Explanation:
The $? variable in bash is a special parameter that holds the exit status of the last command executed in the current shell. The exit status is a numerical value that indicates whether the command was successful (zero) or failed (non-zero). The echo command simply prints its arguments to the standard output. Therefore, when the command echo $? outputs 1, it means that the previous command failed with an exit status of 1.
Reference: [LPI Linux Essentials – Topic 103: Command Line Basics]
[Bash Special Parameters]
[Exit status – Wikipedia]
Which command makes the shell variable named VARIABLE visible to subshells?
- A . export $VARIABLE
- B . export VARIABLE
- C . set $VARIABLE
- D . set VARIABLE
- E . env VARIABLE
B
Explanation:
The export command makes the shell variable named VARIABLE visible to subshells. This means that any child process that is spawned from the current shell will inherit the value of VARIABLE. The export command does not need a dollar sign ($) before the variable name, as that would expand the variable to its value. The set command only affects the current shell and does not export the variable to subshells. The env command can be used to run a command in a modified environment, but it does not export the variable to subshells either.
Reference: [LPI Linux Essentials – Topic 105: Shells, Scripting and Data Management]
[LPI Linux Administrator – Exam 102 Objectives – Topic 105: Shells and Shell Scripting]
What output will the command seq 10 produce?
- A . A continuous stream of numbers increasing in increments of 10 until stopped.
- B . The numbers 1 through 10 with one number per line.
- C . The numbers 0 through 9 with one number per line.
- D . The number 10 to standard output.
B
Explanation:
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.
Reference: 1: 10+ Seq Commands with Examples in Linux C LinuxWizardry 2: How to Use the seq Command on Linux – How-To Geek
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.)
Explanation:
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.
Reference: 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/
After issuing:
function myfunction { echo $1 $2 ; }
in Bash, which output does:
myfunction A B C
Produce?
- A . AB
- B . ABC
- C . AC
- D . BC
- E . CBA
A
Explanation:
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.
Reference: [LPI Linux Essentials – Topic 103: Command Line Basics]
[Bash Functions]
Which of the following commands puts the output of the command date into the shell variable mydate?
- A . mydate="$(date)"
- B . mydate="exec date"
- C . mydate="$((date))"
- D . mydate="date"
- E . mydate="${date}"
A
Explanation: ∗∗ ∗∗
(date)" Comprehensive Thecorrectwaytoputtheoutputofthecommanddateintotheshellvariablemy dateistousecommandsubstitutionwiththesyntax(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.
Reference: [LPI Linux Essentials – Topic 105: Shells, Scripting and Data Management]
[LPI Linux Administrator – Exam 102 Objectives – Topic 105: Shells and Shell Scripting]
Which of the following files, when existing, affect the behavior of the Bash shell? (Choose TWO correct answers.)
- A . ~/.bashconf
- B . ~/.bashrc
- C . ~/.bashdefaults
- D . ~/.bash_etc
- E . ~/.bash_profile
B, E
Explanation:
The Bash shell can be configured by various files that affect its behavior, such as setting environment variables, aliases, functions, options, and prompts. Some of these files are global, meaning they apply to all users of the system, and some are local, meaning they apply to individual users. The global files are usually located in the /etc directory, while the local files are usually located in the user’s home directory, which is denoted by the tilde (~) symbol1. The local files that affect the Bash shell are:
~/.bash_profile: This file is executed when a user logs in to the system. It is used to set up the user’s environment, such as the PATH, the default editor, the umask, and other variables. It can also run commands that are needed only once per login session, such as ssh-agent or fortune. This file can also source other files, such as ~/.bashrc, to inherit their settings12.
~/.bashrc: This file is executed when a user starts a new interactive shell, such as opening a terminal window or running a script with the shebang #!/bin/bash. It is used to set up the user’s shell preferences, such as aliases, functions, options, and prompts. It can also source other files, such as /etc/bashrc, to inherit their settings12.
~/.bash_logout: This file is executed when a user logs out of the system. It is used to perform any cleanup tasks, such as clearing the screen, deleting temporary files, or printing a farewell message1. The other files listed in the question are not valid Bash configuration files and do not affect the behavior of the shell. Therefore, the correct answer is
B. ~/.bashrc and
E. ~/.bash_profile.
Reference: 1: Bash Shell Configuration Files – Land of Linux 2: Bash Startup Files – GNU Project
What is the difference between the commands test -e path and test -f path?
- A . They are equivalent options with the same behaviour.
- B . The -f option tests for a regular file. The -e option tests for an empty file.
- C . Both options check the existence of the path. The -f option also confirms that it is a regular file.
- D . The -f option tests for a regular file. The -e option tests for an executable file.
C
Explanation:
The test command is used to perform checks and comparisons on files and values. The -e option tests if a given path exists, regardless of its type (file, directory, link, etc.). The -f option tests if a given path exists and is a regular file, not a directory or a special file. For example, if we have a directory named dir and a file named file, we can use the test command as follows:
test -e dir && echo “dir exists” dir exists test -f dir && echo “dir is a regular file” (no output) test -e file && echo “file exists” file exists test -f file && echo “file is a regular file” file is a regular file
Reference: https://www.howtoforge.com/linux-test-command/ https://www.computerhope.com/unix/bash/test.htm
How can the existing environment variable FOOBAR be suppressed for the execution of the script./myscript only?
- A . unset -v FOOBAR;./myscript
- B . set -a FOOBAR="";./myscript
- C . env -u FOOBAR./myscript
- D . env -i FOOBAR./myscript
C
Explanation:
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:
When the command echo $$ outputs 12942, what is the meaning of 12942?
- A . It is the process ID of the echo command.
- B . It is the process ID of the current shell.
- C . It is the process ID of the last command executed.
- D . It is the process ID of the last command which has been placed in the background.
B
Explanation:
In bash, the PID of a shell script’s subshell process is stored in a special variable called $$. This variable is read-only, and you cannot modify it in a shell script1. You can use echo $$ to get the PID of the current bash shell you are using2. Therefore, when the command echo $$ outputs 12942, it means that the PID of the current shell is 12942.
Reference: [LPI Linux Essentials – Topic 103: Command Line Basics]
[Bash Special Parameters]
How to get the process ID (PID) of a shell script
How to know the process id of current bash session?
What output will the following command produce?
seq 1 5 20
- A . 1
6
1
1
1
6 - B . 1
5
10
15 - C . 1
2
3
4 - D . 2
3
4
5 - E . 5
10
15
20
B
Explanation:
The seq command in Linux is used to generate a sequence of numbers from FIRST to LAST in steps of
INCREMENT1. The syntax for the seq command is:
seq [OPTION]… LAST or seq [OPTION]… FIRST LAST or seq [OPTION]… FIRST INCREMENT LAST
In this case, the command seq 1 5 20 has three arguments: FIRST = 1, INCREMENT = 5, and LAST = 20.
This means that the command will produce numbers from 1 to 20 in steps of 5. The output will be:
151015
The output will not include 20 because it is not a multiple of 5. The output will be printed on separate lines by default, unless a different separator is specified with the -s option2.
Reference: Seq Command in Linux [Explained With Examples]
seq Man Page – Linux – SS64.com – SS64 Command line reference
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?
- A . CASE
- B . FROM
- C . WHERE
- D . IF
C
Explanation:
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
Reference: 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]
Which of the following commands lists all defined variables and functions within Bash?
- A . env
- B . set
- C . env -a
- D . echo $ENV
B
Explanation:
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 .
Which of the following SQL queries counts the number of occurrences for each value of the field order_type in the table orders?
- A . SELECT order_type,COUNT(*) FROM orders WHERE order_type=order_type;
- B . SELECT order_type,COUNT(*) FROM orders GROUP BY order_type;
- C . COUNT(SELECT order_type FROM orders);
- D . SELECT COUNT(*) FROM orders ORDER BY order_type;
- E . SELECT AUTO_COUNT FROM orders COUNT order_type;
B
Explanation:
The correct SQL query to count the number of occurrences for each value of the field order_type in the table orders is:
SELECT order_type,COUNT(*) FROM orders GROUP BY order_type;
This query uses the SELECT statement to retrieve the values of the order_type field and
the COUNT(*) function to count the number of rows for each order_type. The GROUP BY clause groups the rows by the order_type field, so that the count is calculated for each distinct value of order_type. The result of this query is a table with two columns: order_type and count, where each row shows the number of orders for a specific order_type. The other options are incorrect for the following reasons:
A: This query uses a WHERE clause that is always true, since order_type=order_type for every row. Therefore, this query returns the same result as SELECT order_type,COUNT(*) FROM orders;, which is a table with one row that shows the total number of orders, regardless of the order_type.
C: This query is syntactically invalid, since the COUNT function cannot take a subquery as an argument. The correct way to use a subquery with COUNT is COUNT((SELECT order_type FROM orders));, which returns the total number of orders, regardless of the order_type.
D: This query uses the ORDER BY clause to sort the rows by the order_type field, but it does not group them by order_type. Therefore, this query returns the same result as SELECT COUNT(*) FROM orders;, which is a table with one row that shows the total number of orders, regardless of the order_type.
E: This query is syntactically invalid, since there is no such function as AUTO_COUNT in SQL, and
the COUNT function cannot take a field name as an argument. The correct way to use COUNT with a
field name is COUNT(order_type);, which returns the number of non-null values in the order_type
field.
Reference: [SQL COUNT Function]
[SQL GROUP BY Statement]
[SQL SELECT Statement]
What is the purpose of the file /etc/profile?
- A . It contains the welcome message that is displayed after login.
- B . It contains security profiles defining which users are allowed to log in.
- C . It contains environment variables that are set when a user logs in.
- D . It contains default application profiles for users that run an application for the first time.
C
Explanation:
The file /etc/profile is a configuration file that is read by the Bash shell when a user logs in. It contains commands and settings that apply to all users of the system, such as environment variables, PATH information, terminal settings, and security commands. Environment variables are variables that affect the behavior of programs and processes. For example, the PATH variable defines the directories where the shell looks for executable files, and the JAVA_HOME variable defines the location of the Java installation. The /etc/profile file can also source other files from the /etc/profile.d/ directory, which can contain additional scripts for setting environment variables or other system-wide settings. The /etc/profile file is not the only file that can set environment variables for a user. There are also user-specific files, such as ~/.profile, ~/.bash_profile, and ~/.bashrc, that are read by the shell after /etc/profile. These files can override or append to the settings in /etc/profile, or define new variables for the user. The order and precedence of these files depend on the type of shell (login or interactive) and the options used to start the shell. You can learn more about the difference between these files here1 and here2.
Reference: https://www.thegeekdiary.com/understanding-etc-profile-configuration-file-in-linux/
https://unix.stackexchange.com/questions/704610/what-does-the-etc-profile-do
What command displays all aliases defined in the current shell? (Specify the command without any path information)
Explanation:
The alias command is used to create, list, or remove aliases in the current shell. An alias is a short name that refers to another command, usually with some options or arguments. Aliases are useful for saving typing time, avoiding spelling errors, or customizing the behavior of commands. To list all the aliases defined in the current shell, we can use the alias command without any arguments. This will print the aliases in the format of alias name=’command’123. For example:
$ alias alias cp=‘cp -i’ alias l=‘ls -CF’ alias la=‘ls -A’ alias ll=‘ls -alF’ alias mv=‘mv -i’ alias rm=‘rm -i’ The output shows that some common commands, such as cp, mv, and rm, have aliases that add the – i option, which prompts the user before overwriting or deleting files. The l, la, and ll aliases are shortcuts for different variations of the ls command, which lists files and directories123.
Reference: 1: List All Available Commands and Aliases in Linux – Baeldung 2: get all aliases in linux
shell – Stack Overflow 3: How to list all aliases on Linux – Linux Tutorials – Learn Linux Configuration
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.)
- A . The user issuing the command must be in the group script.
- B . The script file must be found in the $PATH.
- C . The script file must have the executable permission bit set.
- D . The script must begin with a shebang-line (#!) that points to the correct interpreter.
- E . The file system on which the script resides must be mounted with the option scripts.
B, C, D
Explanation:
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.
Reference: [LPI Linux Essentials – Topic 105: Shells, Scripting and Data Management]
[LPI Linux Professional – Exam 102 Objectives – Topic 105: Shells and Shell Scripting]
Which of the following SQL statements will select the fields name and address from the contacts
table?
- A . SELECT (name, address) FROM contacts;
- B . SELECT (name address) FROM contacts;
- C . SELECT name, address FROM contacts;
- D . SELECT name address FROM contacts;
C
Explanation:
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.
Reference: https://www.sqltutorial.org/sql-select/
https://www.w3schools.com/mysql/mysql_select.asp
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/
Explanation:
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.
Reference: [Linux User Administration]
[Linux Directory Structure]
Which of the following configuration files should be modified to set default shell variables for all users?
- A . /etc/bashrc
- B . /etc/profile
- C . ~/.bash_profile
- D . /etc/.bashrc
B
Explanation:
The /etc/profile file is a configuration file that is read by the Bash shell when a user logs in. It contains commands and settings that apply to all users of the system, such as environment variables, PATH information, terminal settings, and security commands. Environment variables are variables that affect the behavior of programs and processes. For example, the PATH variable defines the directories where the shell looks for executable files, and the JAVA_HOME variable defines the location of the Java installation. The /etc/profile file can also source other files from the /etc/profile.d/ directory, which can contain additional scripts for setting environment variables or other system-wide settings. The /etc/profile file is the best option for setting default shell variables for all users, as it is executed before any user-specific files. The other options are not suitable for this purpose, because:
/etc/bashrc is a configuration file that is read by the Bash shell when it is started as an interactive non-login shell. It contains commands and settings that apply to all interactive shells of the system, such as aliases, functions, and prompt settings. It is not executed when the shell is started as a login shell, which is the case when a user logs in. Therefore, it is not a good place to set default shell variables for all users.
~/.bash_profile is a configuration file that is read by the Bash shell when it is started as a login shell for a specific user. It contains commands and settings that apply only to that user, such as environment variables, PATH information, and startup programs. It can also source other files, such as ~/.bashrc, which is read by the shell when it is started as an interactive non-login shell for that user. It is not a good place to set default shell variables for all users, as it only affects the user who owns the file.
/etc/.bashrc is not a valid configuration file for the Bash shell. The dot (.) at the beginning of the file name indicates that it is a hidden file, which means that it is not visible by default in the file system. The Bash shell does not look for this file when it is started, and it does not execute any commands or settings from it. Therefore, it is not a good place to set default shell variables for all users.
Reference: 1 2
Which of the following is the best way to list all defined shell variables?
- A . env
- B . set
- C . env -a
- D . echo $ENV
B
Explanation:
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 .
Reference: 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 command allows you to make a shell variable visible to subshells?
- A . export $VARIABLE
- B . export VARIABLE
- C . set $VARIABLE
- D . set VARIABLE
- E . env VARIABLE
B
Explanation:
The command that allows you to make a shell variable visible to subshells is export VARIABLE. This command turns the variable into a global or environment variable, which means it can be accessed by any child process or subshell that inherits the environment of the parent shell. The syntax of the export command does not require a dollar sign ($) before the variable name, unlike when referencing the value of the variable. The other commands are either invalid or do not affect the visibility of the variable to subshells. The set command can be used to assign values to variables, but it does not export them. The env command can be used to run a command in a modified
environment, but it does not change the environment of the current shell.
Reference: [LPI Linux Essentials – Topic 105: Shells, Scripting and Data Management]
[LPI Linux Professional – Exam 102 Objectives – Topic 105: Shells and Shell Scripting] What is a Subshell? – Linux Bash Shell Scripting Tutorial Wiki – nixCraft What is Subshell in Linux? [Explained]
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?
- A . LIMIT
- B . FROM
- C . WHERE
- D . IF
C
Explanation:
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;
Reference: 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
What benefit does an alias in bash provide?
- A . It provides faster lookups for commands in the system directory.
- B . It creates a local copy of a file from another directory.
- C . It hides what command you are running from others.
- D . It allows a string to be substituted for the first word of a simple command.
D
Explanation:
An alias in bash provides the benefit of allowing a string to be substituted for the first word of a simple command. This means that you can create a shortcut or alternative name for a command that is already installed on your system, and use the new name to run the command instead of the original name. For example, you can create an alias for the ls -la command, which lists all files and directories in the current directory with detailed information, by running the following command: alias ll=’ls -la’
After defining the alias, you can use the ll command to execute the ls -la command. The alias will be active for the duration of the current shell session, unless you make it persistent by adding it to your shell startup file (such as ~/.bashrc for the Bash shell). The other options are incorrect for the following reasons:
A: An alias does not provide faster lookups for commands in the system directory. The system directory is where the executable files for the commands are stored, and the shell uses the PATH variable to search for them. An alias does not affect the PATH variable or the system directory.
B: An alias does not create a local copy of a file from another directory. An alias is a way to rename a command, not a file. To create a local copy of a file, you can use the cp command.
C: An alias does not hide what command you are running from others. An alias is a way to simplify the use of a command, not to conceal it. Anyone can see what command an alias represents by using the type command or the alias command without any arguments.
Reference: LPI E – alias
What benefit does an alias in bash provide?
- A . It provides faster lookups for commands in the system directory.
- B . It creates a local copy of a file from another directory.
- C . It hides what command you are running from others.
- D . It allows a string to be substituted for the first word of a simple command.
D
Explanation:
An alias in bash provides the benefit of allowing a string to be substituted for the first word of a simple command. This means that you can create a shortcut or alternative name for a command that is already installed on your system, and use the new name to run the command instead of the original name. For example, you can create an alias for the ls -la command, which lists all files and directories in the current directory with detailed information, by running the following command: alias ll=’ls -la’
After defining the alias, you can use the ll command to execute the ls -la command. The alias will be active for the duration of the current shell session, unless you make it persistent by adding it to your shell startup file (such as ~/.bashrc for the Bash shell). The other options are incorrect for the following reasons:
A: An alias does not provide faster lookups for commands in the system directory. The system directory is where the executable files for the commands are stored, and the shell uses the PATH variable to search for them. An alias does not affect the PATH variable or the system directory.
B: An alias does not create a local copy of a file from another directory. An alias is a way to rename a command, not a file. To create a local copy of a file, you can use the cp command.
C: An alias does not hide what command you are running from others. An alias is a way to simplify the use of a command, not to conceal it. Anyone can see what command an alias represents by using the type command or the alias command without any arguments.
Reference: LPI E – alias
You are looking into a new script you received from your senior administrator. In the very first line you notice a #! followed by a file path. This indicates that:
- A . The file at that location was used to make the script.
- B . This script provides identical functionality as the file at that location.
- C . This script will self-extract into a file at that location.
- D . The program at that location will be used to process the script.
D
Explanation:
The #! followed by a file path is called a shebang or a hashbang. It is a special notation that tells the operating system which interpreter to use to execute the script. For example, if the first line of a script is #!/bin/bash, it means that the script will be run by the Bash shell, which is located at /bin/bash. Similarly, if the first line of a script is #!/usr/bin/python3, it means that the script will be run by the Python 3 interpreter, which is located at /usr/bin/python3. The shebang must be the very first line of the script, and it must start with #! without any spaces. The file path after the #! must be an absolute path, not a relative path or a symbolic link. The shebang allows the script to be executed as a standalone program, without specifying the interpreter explicitly. For example, if a script named hello.sh has a shebang of #!/bin/bash, and it has the executable permission, it can be run as
./hello.sh instead of bash hello.sh. The shebang also allows the script to be associated with a specific interpreter, regardless of the default interpreter of the system or the user. For example, if a script named hello.py has a shebang of #!/usr/bin/python3, it will always be run by Python 3, even if the system or the user has Python 2 as the default Python interpreter. The shebang is not a comment, although it looks like one. It is a special instruction that is only recognized by the operating system when the script is executed. It is ignored by the interpreter when the script is read. Therefore, the shebang does not indicate that the file at that location was used to make the script, or that the script provides identical functionality as the file at that location, or that the script will self-extract into a file at that location. The correct answer is that the program at that location will be used to process the script. You can learn more about the shebang here1 and here2.
Reference: 1 2
What keyword is missing from this code sample of a shell script?
____ i in *.txt; do
echo $i
done
- A . for
- B . loop
- C . until
- D . while
B
Explanation:
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 .
Reference: 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
What word is missing from the following SQL statement?
__________ count(*) from tablename;
(Please specify the missing word using lower-case letters only.)
Explanation:
The missing word is select, which is the keyword used to query data from a table in SQL. The select statement has the following syntax:
select column_list from table_name where condition;
The column_list can be one or more columns separated by commas, or an asterisk () to indicate all columns. The table_name is the name of the table that contains the dat
a. The where clause is optional and specifies a condition to filter the rows. The count() function is an aggregate function that returns the number of rows in the table or in a group. Therefore, the complete statement is:
select count(*) from tablename;
This statement will return the number of rows in the table named tablename.
Reference: SQL COUNT() Function – W3Schools, SQL COUNT: The Ultimate Guide To SQL COUNT Function – SQL Tutorial, The SQL Count Function Explained With 7 Examples.
Topic 2, User Interfaces and Desktops
Which file used by XDM specifies the default wallpaper?
- A . /etc/X11/xdm/Xsetup
- B . /etc/X11/xdm.conf
- C . /etc/X11/xdm/Defaults
- D . /etc/X11/defaults.conf
A
Explanation:
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.
Reference: XDM – ArchWiki
Configuring XDM – Linux Documentation Project
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.)
xwininfo
Explanation:
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.
Reference: https://bing.com/search?q=command+to+investigate+properties+of+a+windo
w+in+X
https://www.exam-answer.com/linux-foundation-certified-system-administrator-lfcs-simulation-
investigate-window-properties
The X11 configuration file xorg.conf is grouped into sections.
How is the content of the section SectionName associated with that section?
- A . It is placed in curly brackets as in Section SectionName { … }.
- B . It is placed between a line containing Section "SectionName" and a line containing EndSection.
- C . It is placed between the tags <Section name="SectionName"> and </Section>
- D . It is placed after the row [SectionName].
- E . It is placed after an initial unindented Section "SectionName" and must be indented by exactly one tab character.
B
Explanation:
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.
Reference: xorg.conf – X Window System
Editing basics for the xorg.conf file – Linux.com
The X11 configuration file xorg.conf is grouped into sections.
How is the content of the section SectionName associated with that section?
- A . It is placed in curly brackets as in Section SectionName { … }.
- B . It is placed between a line containing Section "SectionName" and a line containing EndSection.
- C . It is placed between the tags <Section name="SectionName"> and </Section>
- D . It is placed after the row [SectionName].
- E . It is placed after an initial unindented Section "SectionName" and must be indented by exactly one tab character.
B
Explanation:
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.
Reference: xorg.conf – X Window System
Editing basics for the xorg.conf file – Linux.com
What is the purpose of a screen reader?
- A . It reads text displayed on the screen to blind or visually impaired people.
- B . It reads the parameters of the attached monitors and creates an appropriate X11 configuration.
- C . It displays lines and markers to help people use speed reading techniques.
- D . It manages and displays files that contain e-books.
A
Explanation:
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.
Reference: Screen reader – Wikipedia
Orca Screen Reader – GNOME
Accessibility in Linux is good (but could be much better)
How is a display manager started?
- A . It is started by a user using the command startx.
- B . It is started like any other system service by the init system.
- C . It is started by inetd when a remote hosts connects to the X11 port.
- D . It is started automatically when a X11 user logs in to the system console.
B
Explanation:
A display manager is a program that provides a graphical login screen for users to access a graphical desktop environment. A display manager is usually started by the init system, which is the first process that runs when the system boots up. The init system is responsible for starting and stopping various system services, including the display manager. The init system can be configured to start a specific display manager by setting the default runlevel or target, or by editing the /etc/X11/default-display-manager file123.
The other options are not correct because:
What is the default name of the configuration file for the Xorg X11 server? (Specify the file name only without any path.)
Explanation:
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.
Reference: Xorg – ArchWiki
xorg.conf – Wikipedia
How to Configure X11 in Linux: 10 Steps (with Pictures) – wikiHow
Which of the following commands shows the current color depth of the X Server?
- A . xcd
- B . xcdepth
- C . xwininfo
- D . xcolordepth
- E . cat /etc/X11
C
Explanation:
The command that can be used to show the current color depth of the X Server 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. The depth value indicates the number of bits per pixel used to represent the colors of
the window. 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. The other options are incorrect because they are either invalid commands or do not show the color depth of the X Server:
xcd is not a valid command in Linux. It may be confused with cd, which is used to change the current working directory.
xcdepth is not a valid command in Linux. It may be confused with xrandr, which is used to change the screen resolution and orientation.
xcolordepth is not a valid command in Linux. It may be confused with xcalib, which is used to load, alter, and query the color profile of the X display.
cat /etc/X11 is not a command, but a directory. cat is used to concatenate files and print them to the standard output. /etc/X11 is a directory that contains configuration files for the X Window System. However, these files do not necessarily show the current color depth of the X Server, as it may be overridden by other settings or options.
Reference: https://bing.com/search?q=command+to+show+color+depth+of+X+Server
https://x.org/releases/X11R7.5/doc/man/man5/xorg.conf.5.html
For accessibility assistance, which of the following programs is an on-screen keyboard?
- A . xkb
- B . atkb
- C . GOK
- D . xOSK
C
Explanation:
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:
What is the name of the simple graphical login manager that comes with a vanilla X11 installation? (Specify ONLY the command without any path or parameters.)
Explanation:
The name of the simple graphical login manager that comes with a vanilla X11 installation is xdm.
XDM is the traditional graphical login manager for the X Window System, independent of any
window manager or environment the user might choose. When it is run at system startup, it displays
a graphical login prompt rather than the text-based login prompt at the console1. XDM is part of the
xorg-x11-apps package, which provides the basic applications for the X Window System2. XDM is also
one of the topics covered by the LPI Linux Professional – Exam 102 Objectives – Topic 111: Graphical
Desktops3.
Reference: xorg-x11-apps – Linux Man Pages (1) – SysTutorials
LPI Linux Professional – Exam 102 Objectives – Topic 111: Graphical Desktops GitHub – iwamatsu/slim: SLiM (Simple Login Manager) is a graphical login manager for X11 slim-fork download | SourceForge.net
Using the XDM Graphical Login Manager | FreeBSD 6 Unleashed – Flylib Xorg – ArchWiki
How to remotely log in with full graphical desktop over X11 – Unix & Linux Stack Exchange
Which of the following are tasks handled by a display manager like XDM or KDM? (Choose TWO correct answers.)
- A . Start and prepare the desktop environment for the user.
- B . Configure additional devices like new monitors or projectors when they are attached.
- C . Handle the login of a user.
- D . Lock the screen when the user was inactive for a configurable amount of time.
- E . Create an X11 configuration file for the current graphic devices and monitors.
A, C
Explanation:
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. Reference https://www.baeldung.com/linux/display-managers-explained https://quizlet.com/185979426/lx0-104-flash-cards/
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?
- A . xcd
- B . xcdepth
- C . xwininfo
- D . xcolordepth
- E . cat /etc/X11
C
Explanation:
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”.
Reference: xwininfo(1) – Linux man page
xdpyinfo(1) – Linux man page
[LPI Linux Certification/Configure the X Window System, Xorg and …]
Your senior administrator asked you to change the default background of his machine, which uses XDM.
Which file would you edit to achieve this?
- A . /etc/X11/xdm/Xsetup
- B . /etc/X11/xdm.conf
- C . /etc/X11/xdm/Defaults
- D . /etc/X11/defaults.conf
A
Explanation:
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.
Reference: XDM – ArchWiki
Customizing the XDM Login Screen | Linux Journal
What is the purpose of the Sticky Keys feature in X?
- A . To assist users who have difficulty holding down multiple keys at once
- B . To prevent repeated input of a single character if the key is held down
- C . To ignore brief keystrokes according to a specified time limit
- D . To repeat the input of a single character
A
Explanation:
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.
Reference: https://www.howtogeek.com/739764/how-to-turn-off-sticky-keys-on-windows-10/ https://geekflare.com/using-sticky-keys-in-windows/
Why is the xhost program considered dangerous to use?
- A . It makes it difficult to uniquely identify a computer on the network.
- B . It allows easy access to your X server by other users.
- C . It logs sensitive information to syslog.
- D . It makes your computer share network resources without any authentication.
- E . It is a graphical DNS tool with known exploits.
B
Explanation:
The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server1. In the case of hosts, this provides a rudimentary form of privacy control and security. It is only sufficient for a workstation (single user) environment, although it does limit the worst abuses1. However, if xhost is used to grant access to everyone, even if they aren’t on the list (i.e., access control is turned off), then any user on the network can connect to your X server and monitor your keystrokes, capture your screen, or run malicious programs2. This is why xhost is considered dangerous to use and should be avoided in favor of more secure methods, such as xauth or ssh23.
Reference: xhost linux command man page – commandlinux.com Linux Xhost Command Help and Examples – Computer Hope xhost(1) ― Arch manual pages
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.
xwininfo
Explanation:
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.
Reference: xwininfo(1) ― Arch manual pages
[command line –
On a system running the KDE Display Manager, when is the /etc/kde4/kdm/Xreset script automatically executed?
- A . When KDM starts
- B . When a user’s X session exits
- C . When KDM crashes
- D . When X is restarted
- E . When X crashes
B
Explanation:
The /etc/kde4/kdm/Xreset script is a script that runs as root after a user’s X session exits. It can be used to perform some cleanup tasks or other actions that need to be done when the user logs out of the graphical environment. For example, it can reassign the ownership of the console to root, or shut down the system if desired. The /etc/kde4/kdm/Xreset script is part of the KDE Display Manager (kdm), which is a graphical login manager for X. KDM can be configured to run this script by setting the Reset key in the [X-*-Core] section of the /etc/kde4/kdm/kdmrc configuration file.
Reference: kdm.options – configuration options for X display manager
kdm(1) ― kdm ― Debian jessie ― Debian Manpages debian – How to get system to shutdown when Xorg is quit? – Unix …
Which of the following lines is an example of a correct setting for the DISPLAY environment variable?
- A . hostname:displayname
- B . hostname:displaynumber
- C . hostname/displayname
- D . hostname/displaynumber
- E . hostname
B
Explanation:
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.
Reference: X11 – DISPLAY (environment variable) – Datacadamia
x11 – How can I specify a display? – Stack Overflow
What is the $DISPLAY environment variable? – Ask Ubuntu
Which of the following steps prevents a user from obtaining an interactive login session?
- A . Run the command chsh -s /bin/false with the user name.
- B . Set the UID for the user to 0.
- C . Remove the user from the group staff.
- D . Add the user to /etc/noaccess.
- E . Create a .nologin file in the user’s home directory.
A
Explanation:
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.
Reference: 1234
Which file specifies the user accounts that can NOT submit jobs via at or batch? (Provide the full path and filename)
Explanation:
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.
Reference: 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
Which character in the password field of /etc/passwd is used to indicate that the encrypted password is stored in /etc/shadow?
- A . *
- B . –
- C . s
- D . x
D
Explanation:
The password field of /etc/passwd is used to store the user’s encrypted password or a special character that indicates how the password is stored. In older Linux systems, the user’s encrypted password was stored in the /etc/passwd file. On most modern systems, this field is set to x, and the user password is stored in the /etc/shadow file12. The /etc/shadow file is more secure than the /etc/passwd file because it is readable only by the root user and not by regular users1. The other options are not valid characters for the password field of /etc/passwd.
Reference: Understanding the /etc/passwd File | Linuxize
Understanding the /etc/passwd File – GeeksforGeeks
The system’s timezone may be set by linking /etc/localtime to an appropriate file in which directory? (Provide the full path to the directory, without any country information)
Explanation:
The /usr/share/zoneinfo directory contains the binary time zone files that are used by the system to determine the local time for any region. The files are organized in subdirectories by continent, country, or ocean. Some files represent the standard time zones, while others may have historical or political variations. To set the system’s timezone, one can create a symbolic link from /etc/localtime to the appropriate file in the /usr/share/zoneinfo directory. For example, to set the timezone to America/New_York, one can use the command sudo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime. Alternatively, one can use the timedatectl command to set the timezone without creating the link manually.
Reference: How to Set or Change the Time Zone in Linux | Linuxize
4 Ways to Change the Timezone in Linux – wikiHow
Which of the following fields are available in both the global /etc/crontab file as well as in user-specific crontab files? (Select TWO correct answers)
- A . Year
- B . Minute
- C . Username
- D . Command
B, D
Explanation:
The crontab file format consists of six fields: minute, hour, day of month, month, day of week, and command. The user-specific crontab files have the same format as the global /etc/crontab file, except that they do not have the username field. The username field is only present in the system-wide crontab files and specifies which user will run the cron job. The year field is not a valid crontab field and is not supported by cron.
Reference: Scheduling Cron Jobs with Crontab | Linuxize
Crontab Explained in Linux [With Examples]
Which command can be used to delete a group from a Linux system?
- A . groupdel
- B . groupmod
- C . groups
- D . groupedit
A
Explanation:
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.
Reference: 1234
What is the purpose of the iconv command?
- A . It converts bitmap images from one format to another such as PNG to JPEG.
- B . It verifies that the root directory tree complies to all conventions from the Filesystem Hierarchy Standard (FHS).
- C . It displays additional meta information from icon files ending in .ico.
- D . It changes the mode of an inode in the ext4 file system.
- E . It converts files from one character encoding to another.
E
Explanation:
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.
Reference: 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
In case neither cron.allow nor cron.deny exist in /etc/, which of the following is true?
- A . Without additional configuration, no users may have user specific crontabs.
- B . Without additional configuration, all users may have user specific crontabs.
- C . The cron daemon will refuse to start and report missing files in the system’s logfile.
- D . When a user creates a user specific crontab the system administrator must approve it explicitly.
B
Explanation:
The /etc/cron.allow and /etc/cron.deny files are used to control access to the crontab command and cron jobs for individual users. If neither of these files exists, then depending on site-dependent configuration parameters, only the superuser (root user) will be allowed to use this command, or all users will be able to use this command1. The default behavior of most Linux distributions is to allow all users to use the crontab command and have user specific crontabs if neither /etc/cron.allow nor /etc/cron.deny exists23. Therefore, option B is the correct answer. The other options are not true because:
Option A is false because it contradicts the default behavior of most Linux distributions. Option C is false because the cron daemon will not refuse to start or report missing files in the system’s logfile if neither /etc/cron.allow nor /etc/cron.deny exists. The cron daemon will start normally and use the default configuration parameters1.
Option D is false because the system administrator does not need to approve user specific crontabs explicitly. The user can create, edit, display, or remove their own crontab files without any intervention from the system administrator1.
Reference: How cron.allow and cron.deny can be used to limit access to crontab for a particular user | The Geek Search
crontab(1) ― cron ― Debian bullseye ― Debian Manpages
Controlling Access to crontab (System Administration Guide: Basic Administration) – Oracle /etc/cron.allow – Linux Bash Shell Scripting Tutorial Wiki – nixCraft
Which of the following commands can remove a user from a group?
- A . grouprm
- B . groupmod
- C . passwd
- D . usergroups
- E . usermod
E
Explanation:
The usermod command is a utility for modifying user accounts. One of its options is -G, which allows specifying a list of supplementary groups that the user is a member of. If the user is currently a member of a group that is not listed, the user will be removed from that group. For example, to remove the user alice from the group sales, one can use the command sudo usermod -G admin alice,
assuming that alice is only a member of admin and sales groups. Alternatively, one can use the gpasswd command with the –delete option to remove a user from a specific group without affecting other groups. For example, to remove the user alice from the group sales, one can use the command sudo gpasswd –delete alice sales. The other commands in the options are not used for removing a user from a group. The grouprm command does not exist. The groupmod command is used for modifying group attributes, not membership. The passwd command is used for changing user passwords, not groups. The usergroups command is used for displaying the groups that a user belongs to, not modifying them.
Reference: usermod(8) – Linux man page
gpasswd(1) – Linux man page
How to Remove User From Group in Linux [Quick Tip]
Where are user specific crontabs stored?
- A . In the database file /etc/crontab.db which is shared by all users.
- B . As individual per-user files within /var/spool/cron.
- C . As individual per-user files in /etc/cron.user.d.
- D . In the .crontab file in the user’s home directory.
- E . In the file /var/cron/user-crontab which is shared by all users.
B
Explanation:
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.
Reference: Where is the user crontab stored?
crontab running as a specific user
Location of the crontab file
Where is the User Crontab Stored?
Which file contains the date of the last change of a user’s password?
- A . /etc/gshadow
- B . /etc/passwd
- C . /etc/pwdlog
- D . /etc/shadow
- E . /var/log/shadow
D
Explanation:
The /etc/shadow file contains the encrypted passwords and other information for each user account on a Linux system. The third field in each line of this file is the date of the last password change, expressed as the number of days since Jan 1, 1970. This information is used by the system to determine when a user must change their password, based on the password aging policy. The /etc/shadow file can be viewed and modified by the root user or by using the chage command123. The other files listed in the options do not store the date of the last password change. The /etc/gshadow file contains the encrypted passwords for group accounts4. The /etc/passwd file contains the basic information for each user account, such as the user name, user ID, group ID, home directory, login shell, etc., but not the password5. The /etc/pwdlog file does not exist by default on most Linux systems, and it is not related to the password change date. The /var/log/shadow file also does not exist by default on most Linux systems, and it is not related to the password change
date.
Reference:
https://www.redhat.com/sysadmin/password-changes-chage-command
https://www.golinuxcloud.com/check-last-password-change-expiration-linux/
Which environment variable should be set in order to change the time zone for the commands run from within the environment variable’s scope? (Specify the variable name only.)
Explanation:
The TZ environment variable is used to change the time zone for the commands run from within the environment variable’s scope. It specifies the name of a time zone as defined in the /usr/share/zoneinfo directory or a custom time zone in the POSIX format12. The TZ variable can be set either globally in a shell profile file or locally in a shell session. For example, to set the time zone to America/New_York for the current shell session, one can use the following command: export TZ=America/New_York
To verify the change, one can use the date command to display the current date and time according to the TZ variable. The TZ variable can also be used to run a single command with a different time zone without affecting the system’s time zone. For example, to run the date command with the Asia/Tokyo time zone, one can use the following syntax: TZ=Asia/Tokyo date
The TZ variable is useful for testing how applications behave in different time zones or for displaying the time in different locations34.
Reference: How to Set or Change the Time Zone in Linux | Linuxize
Linux / UNIX: TZ Environment Variable – nixCraft
Get Current System Time Zone in Linux | Baeldung on Linux
Setting the TZ Environment Variable on Linux | InterSystems Developer
Each entry in a crontab must end with what character?
- A . Tab
- B . Space
- C . Backslash
- D . Newline
D
Explanation:
Each entry in a crontab file consists of six fields, specifying in the following order: minute, hour, day, month, weekday, and command1. Any of these fields can be set to an asterisk (*), which stands for “first through last.” So, for example, to run a job every hour, put * in the hour field1. Each entry in a crontab file must end with a newline character (n), which indicates the end of a line2. A newline character is created by pressing the Enter key on the keyboard. The other options are not valid characters for ending a crontab entry. A tab or a space is used to separate each field, and a backslash is used to escape special characters or continue a long command to the next line2.
Reference: How to Use the Cron Job Format to Schedule Task in Linux Syntax of crontab File Entries – Oracle.
To prevent a specific user from scheduling tasks with at, what should the administrator do?
- A . Add the specific user to /etc/at.allow file.
- B . Add the specific user to [deny] section in the /etc/atd.conf file.
- C . Add the specific user to /etc/at.deny file.
- D . Add the specific user to nojobs group.
- E . Run the following: atd –deny [user].
C
Explanation:
The /etc/at.deny file is a file that contains a list of users who are not allowed to use the at command to schedule jobs. If the file exists, any user who is not in the /etc/at.allow file and is in the /etc/at.deny file will be denied access to the at command. To prevent a specific user from scheduling tasks with at, the administrator can simply add the user’s name to the /etc/at.deny file. For example, to prevent the user bob from using the at command, the administrator can use the following command:
echo “bob” | sudo tee -a /etc/at.deny
The other options are not correct. The /etc/at.allow file is a file that contains a list of users who are allowed to use the at command. Adding a user to this file will not prevent them from scheduling tasks with at. The /etc/atd.conf file is a configuration file for the at daemon, which does not have a [deny] section. Adding a user to this file will not affect their access to the at command. The nojobs group is not a predefined group in Linux, and adding a user to this group will not prevent them from scheduling tasks with at. The atd command does not have a –deny option, and running this command will not prevent a user from scheduling tasks with at.
Reference: at Command in Linux with Examples – GeeksforGeeks
How to Use the Linux at Command {9 Examples} – phoenixNAP at(1) – Linux man page
Which of the following crontab entries will execute myscript at 30 minutes past every hour on Sundays?
- A . 0 * * * 30 myscript
- B . 30 * * * 6 myscript
- C . 30 0 * * 0 myscript
- D . 30 0-23 * * 0 myscript
- E . 0 0-23 * * 30 myscript
D
Explanation:
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
Which of the following files assigns a user to its primary group?
- A . /etc/pgroup
- B . /etc/shadow
- C . /etc/group
- D . /etc/passwd
- E . /etc/gshadow
D
Explanation:
The /etc/passwd file assigns a user to its primary group by specifying the group ID (GID) of the primary group in the fourth field of each line. The /etc/passwd file contains the basic information for each user account on a Linux system, such as the user name, user ID (UID), group ID (GID), home directory, login shell, etc. The format of each line is: username:password:UID:GID:comment:home:shell
For example, the following line assigns the user bob to the primary group bob, which has the GID of
1001:
bob:x:1001:1001::/home/bob:/bin/sh
The /etc/passwd file can be viewed and modified by the root user or by using the useradd, usermod, or userdel commands123. The other files listed in the options do not assign a user to its primary group. The /etc/pgroup file does not exist by default on most Linux systems, and it is not related to the primary group. The /etc/shadow file contains the encrypted passwords and other information for each user account, but not the primary group4. The /etc/group file contains the information for each group on the system, such as the group name, group password, group ID, and group members, but not the primary group of each user5. The /etc/gshadow file contains the encrypted passwords for group accounts.
Reference: 12345
Which of the following commands should be added to /etc/bash_profile in order to change the language of messages for an internationalized program to Portuguese (pt)?
- A . export LANGUAGE="pt"
- B . export MESSAGE="pt"
- C . export UI_MESSAGES="pt"
- D . export LC_MESSAGES="pt"
- E . export ALL_MESSAGES="pt"
D
Explanation:
The LC_MESSAGES environment variable specifies the language to use in diagnostic messages for an internationalized program. It can be set to any value supported by the installation, such as pt for Portuguese, en for English, fr for French, etc. The LC_MESSAGES variable can be set either globally in a shell profile file, such as /etc/bash_profile, or locally in a shell session.
For example, to set the language of messages to Portuguese for the current shell session, one can use the following command:
export LC_MESSAGES=pt
To verify the change, one can run an internationalized program, such as man, and see the output in Portuguese. The LC_MESSAGES variable can also be used to run a single command with a different language without affecting the system’s language. For example, to run the man command with the Spanish language, one can use the following syntax: LC_MESSAGES=es man
The LC_MESSAGES variable is useful for testing how programs behave in different languages or for displaying messages in different languages1234.
Reference: Locale Environment Variables in Linux | Baeldung on Linux Linux / UNIX: TZ Environment Variable – nixCraft Changing your locale on Linux and UNIX systems – IBM Selecting message language in gcc and g++ – Stack Overflow
In which file, if present, must all users be listed that are allowed to use the cron scheduling system? (Specify the full name of the file, including path.)
Explanation:
The /etc/cron.allow file is a file that contains a list of users who are allowed to use the cron scheduling system. The cron scheduling system is a way of running commands or scripts at specified times or intervals. Users can create their own cron jobs by using the crontab command, which edits a file called crontab that stores the user’s scheduled tasks. However, not all users may have access to the crontab command or the cron system. The access is controlled by two files: /etc/cron.allow and /etc/cron.deny. If the /etc/cron.allow file exists, then only the users listed in this file can use the crontab command and the cron system. The file should have one user name per line. If the /etc/cron.allow file does not exist, then the /etc/cron.deny file is checked. If this file exists, then the users listed in this file are denied access to the crontab command and the cron system. If neither file exists, then the access depends on the configuration of the cron daemon, which is the program that runs the cron jobs. By default, only the root user can use the cron system if no files exist. The root user can always use the cron system regardless of the existence or content of these files. To create or edit the /etc/cron.allow file, the root user needs to use a text editor such as vi, nano, or emacs. For example, to allow the users alice and bob to use the cron system, the root user can use the following command:
sudo vi /etc/cron.allow
And then add the following lines to the file:
alice bob
And then save and exit the file.
Reference: How cron.allow and cron.deny can be used to limit access to crontab for … /etc/cron.allow – Linux Bash Shell Scripting Tutorial Wiki Linux / UNIX Restrict at / cron Usage To Authorized Users
Which commands can be used to change a user’s account aging information? (Choose THREE correct answers.)
- A . usermod
- B . passwd
- C . chattr
- D . chage
- E . chsh
A, B, D
Explanation:
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.
Reference: 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
Which command is used to add an empty group to the system? (Specify ONLY the command without any path or parameters.)
/usr/sbin/groupadd
Explanation:
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.
Reference: Linux Groups – javatpoint groupadd(8) – Linux manual page
How to Add and Delete User Groups on Linux
What is NOT contained in the locale setting of the operating system?
- A . currency symbol
- B . language
- C . timezone
- D . thousands separator
C
Explanation:
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.
Reference: 12
What is true about the file /etc/localtime?
- A . It is a plain text file containing a string such as Europe/Berlin
- B . It is created and maintained by the NTP service based on the location of the system’s IP address.
- C . It is a symlink to /sys/device/clock/ltime and always contains the current local time.
- D . After changing this file, newtzconfig has to be run to make the changes effective.
- E . It is either a symlink to or a copy of a timezone information file such as /usr/share/zoneinfo/Europe/Berlin.
E
Explanation:
The /etc/localtime file is used to configure the system-wide timezone of the local system that is used by applications for presentation to the user. It should be either a symlink to or a copy of a timezone information file that contains the binary data for the configured timezone. The timezone information files are located under /usr/share/zoneinfo/ and are named after the geographic regions and cities, such as Europe/Berlin or Etc/UTC. The timezone identifier is extracted from the symlink target name of /etc/localtime, so it is recommended to use a symlink rather than a copy. The timezone can be changed by using the timedatectl command or by creating a new symlink to the desired timezone file123.
Reference: How to Set or Change the Time Zone in Linux | Linuxize
localtime(5) – Linux manual page – man7.org
localtime(5) ― Arch manual pages
What is true regarding the command userdel –force –remove bob? (Choose TWO correct answers.)
- A . The user bob is removed from the system’s user database.
- B . The user bob’s home directory is removed.
- C . The locate database is updated to drop files owned by bob.
- D . All files owned by bob are remove from all mounted filesystems.
- E . In case bob was the last member of a group, that group is deleted.
A, B
Explanation:
The command userdel –force –remove bob is used to delete the user account named bob and all its associated files. The –force option forces the removal of the user account, even if the user is still logged in. The –remove option forces userdel to remove the user’s home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user12. Therefore, options A and B are true regarding this command. The other options are not true because:
Option C is false because the locate database is not updated by the userdel command. The locate database is updated by the updatedb command, which is usually run by cron as a scheduled job3. Option D is false because the userdel command does not remove all files owned by bob from all mounted filesystems. The userdel command only removes the user’s home directory and mail spool, and it does not search for and delete the user files located in other file systems. You have to search for and delete the files manually1.
Option E is false because the userdel command does not delete the group with the same name as the user, unless the USERGROUPS_ENAB parameter is set to yes in the /etc/login.defs file and the group has no other members14.
Reference: How to Delete/Remove Users in Linux (userdel Command) | Linuxize
userdel(8) ― Linux manual page
updatedb(8) ― Linux manual page
Understanding the /etc/login.defs File | Linuxize
Which of the following fields can be found in the /etc/group file? (Choose THREE correct answers.)
- A . The list of users that belong to the group.
- B . The home directory of the group.
- C . The name of the group.
- D . The description of the group.
- E . The password of the group.
A, C, E
Explanation:
The /etc/group file is a text file that defines the groups and their members on the system.
Each line in the file represents a single group, with the following format:
group_name:password:GID:user_list
The fields are:
group_name: the name of the group
password: the (encrypted) group password, or empty for no password
GID: the numerical group ID
user_list: a comma-separated list of users who belong to the group
Therefore, the fields that can be found in the /etc/group file are the name of the group, the password of the group, and the list of users that belong to the group. The home directory and the description of the group are not part of the /etc/group file format.
Reference: group(5) – Linux manual page
/etc/group file format | Linux#
On a system using shadowed passwords, the most correct permissions for /etc/passwd are ___ and the most correct permissions for /etc/shadow are _________.
- A . -rw-r—–, -r——–
- B . -rw-r–r–, -r–r–r–
- C . -rw-r–r–, -r——–
- D . -rw-r–rw-, -r—–r–
- E . -rw——-, -r——–
C
Explanation:
The /etc/passwd file stores local accounts of the system. It is a readable text file and uses colons (:) to separate the fields. This file helps with converting user IDs to names (and back). It is fine that all users can read this file, but they should not be able to change fields. Therefore, the most correct permissions for /etc/passwd are -rw-rCrC, which means that only the owner (root) can write to the file, and everyone can read it. The /etc/shadow file contains information about the system’s users’ passwords. It is owned by user root and group shadow, and has 640 permissions. The password is stored as a long string of characters, which is a combination of the hashing algorithm, optional salt applied, and the hashed password itself. Other users are not allowed to read the file directly, to prevent them from gathering hashed passwords of others. Therefore, the most correct permissions for /etc/shadow are -r——–, which means that only the owner (root) can read the file, and no one else can read or write to it.
Reference:
A French user has installed the French language pack, but currencies are still being displayed with a leading ‘$’ sign in his spreadsheets.
What must be done to fix this?
- A . Alter the locale.
- B . Set the timezone correctly.
- C . Edit /etc/currency.
- D . Reinstall the French language pack.
A
Explanation:
The locale is a set of environmental variables that defines the language, country, and character encoding settings for the applications and shell session on a Linux system. The locale affects things
such as the time/date format, the first day of the week, numbers, currency and many other values formatted in accordance with the language or region/country you set on a Linux system1. The currency sign (¤) is a character used to denote an unspecified currency2. To display the correct currency symbol for a specific region, the locale must be set accordingly. For example, to display the euro symbol () for France, the locale can be set to fr_FR.UTF-81. Setting the timezone correctly, editing /etc/currency, or reinstalling the French language pack will not affect the currency symbol displayed in the spreadsheets.
Reference: 1: How to Change or Set System Locales in Linux – Tecmint 2: decimal.ToString (“C”) produces ¤ currency symbol on Linux – Stack Overflow
Which of the following can the chage command NOT change?
- A . The number of days since January 1, 1970 after which the user’s account will no longer be accessible.
- B . The number of days since January 1, 1970 after which the password can change.
- C . The number of days since January 1, 1970 since the password was last changed.
- D . The maximum number of days during which a password is valid.
- E . The number of days of inactivity after a password has expired before the account is locked.
E
Explanation:
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.
Reference: chage command in Linux with examples – GeeksforGeeks
10 chage command examples in Linux [Cheat Sheet] – GoLinuxCloud How to Use the Chage Command in Linux C TecAdmin
How to Manage User Password Expiration and Aging in Linux – Tecmint
What command will display the group names and GIDs to which a user belongs? (Provide only the command name with or without path information)
Explanation:
The id command will display the user ID (uid), the primary group ID (gid), and the supplementary groups (groups) of a user. The output will show the names and the numerical IDs of the groups.
For example:
id linuxize
The command will show the user ID (uid), the user’s primary group (gid), and the user’s secondary groups (groups)
uid=1001(linuxize) gid=1001(linuxize) groups=1001(linuxize),27(sudo) To print only the names instead of the numbers use the -n option. id -nG linuxize
The command will show only the names of the groups
linuxize sudo
The id command is part of the GNU coreutils package and is available on all Linux systems. The full path of the command is /usr/bin/id.
Reference: id(1) – Linux manual page
How to List Groups in Linux | Linuxize
Of the ways listed, which is the best method to temporarily suspend a user’s ability to interactively login?
- A . Use passwd -d username to give the user an empty password.
- B . Use chage to expire the user account.
- C . Change the user’s password.
- D . Add the command exit to the user’s .login file.
B
Explanation:
The chage command can be used to change the expiration date of a user account. By setting the
expiration date to a past date, the user account will be disabled and the user will not be able to login
interactively. This is a temporary method, as the expiration date can be changed back to a future
date or removed to re-enable the user account. The other options are either permanent, insecure, or
ineffective. Option A is insecure, as it allows anyone to login as the user without a password. Option
C is permanent, as it changes the user’s password without saving the original one. Option D is
ineffective, as it only affects the user’s .login file, which is used by the csh and tcsh shells, and not by
other shells such as bash or zsh. Therefore, option B is the best method to temporarily suspend a
user’s ability to interactively login.
Reference:
https://linuxconfig.org/disabling-user-logins-to-linux-system
https://askubuntu.com/questions/282806/how-to-enable-or-disable-a-user
What is the conventional purpose of Linux UIDs that are lower than 100?
- A . They are reserved for super user accounts.
- B . They are reserved for the system admin accounts.
- C . They are reserved for system accounts.
- D . They are unused, aside from 0, because they are targets of exploits.
- E . They are used to match with GIDs in grouping users.
C
Explanation:
Linux UIDs (user identifiers) are numbers that are used to identify users and groups on a Linux system. Each user and group has a unique UID and GID (group identifier) respectively. The UID 0 is always reserved for the root or superuser account, which has full privileges to access and modify the system. The UIDs lower than 100 (or 1000 on some modern systems) are typically reserved for system accounts, which are used by various services and daemons that run on the system. These accounts are not meant for human users, but for specific purposes such as managing files, processes, network, security, etc. For example, some common system accounts are bin, daemon, mail, sshd, etc. The UIDs higher than 100 (or 1000) are usually allocated for regular user accounts, which have limited privileges and can be created and deleted by the system administrator. The system accounts are defined in the /etc/passwd file, which contains the username, UID, GID, home directory, shell, and other information for each account12345.
Reference: 1: Linux User Management – Tecmint 2: What are the well-known UIDs? – Stack Overflow 3: user ID less than 1000 on CentOS 7 – Unix & Linux Stack Exchange 4: Recommended GID for users group in Linux (100 or 1000)? – Unix & Linux Stack Exchange 5: What is the conventional purpose of Linux UIDs that are lower than 100? – VCE Guide
How is the file format of /etc/crontab different from a normal crontab file? (Select TWO correct answers)
- A . The /etc/crontab file can specify a year field.
- B . A normal crontab file must be installed with the crontab command.
- C . A normal crontab file allows for environment variable substitution.
- D . The /etc/crontab file has a user field for commands.
B, D
Explanation:
The /etc/crontab file is the system-wide crontab file that can be edited only by root. It has a different format from the normal crontab files that can be edited by individual users using the crontab command.
The differences are:
The /etc/crontab file can specify a year field as the sixth field in a cron entry. This allows for
scheduling jobs that run only in specific years. The normal crontab files do not have a year field and assume the current year for all entries.
The /etc/crontab file has a user field as the seventh field in a cron entry. This allows for running commands as different users from the crontab owner (root). The normal crontab files do not have a user field and run commands as the crontab owner.
The /etc/crontab file does not need to be installed with the crontab command. It is read by the cron daemon automatically. The normal crontab files need to be installed with the crontab command to be recognized by the cron daemon.
The /etc/crontab file and the normal crontab files both allow for environment variable substitution. However, the /etc/crontab file sets some default environment variables such as SHELL, PATH, MAILTO, and HOME, which can be overridden by entries in the file. The normal crontab files inherit the environment variables from the cron daemon, which are usually minimal.
Reference: crontab(5) – Linux manual page
Linux Crontab Format
How to schedule a task using Linux crontab (/etc/crontab) file /etc/crontab – Linux Bash Shell Scripting Tutorial Wiki
What is the main difference between the batch and at commands?
- A . The batch command will run multiple times.The at command will only run once.
- B . The batch command will run when system load is low. The at command runs at a specific time.
- C . The at command reads commands from standard input. The batch command requires a command line argument.
- D . The at command e-mails results to the user. The batch command logs results to syslog.
B
Explanation:
The batch command is similar to the at command, except that it executes commands when the system load levels permit; in other words, when the load average drops below 1.5, or the value specified in the invocation of atd1. The at command allows us to schedule jobs using any of two commands: at and batch. While at runs commands at our specified time, batch runs commands when our system’s load average is below 0.82. Both commands read commands from standard input or a specified file, and both commands send the output of the commands to the user by mail1. Therefore, the main difference between them is the time of execution: at runs at a fixed time,
while batch runs when the system is idle.
Reference: 1: Linux At, Batch, Atq, Atrm Command Help and Examples – Computer Hope 2: The “at” Command in Linux | Baeldung on Linux
The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m.:
- A . * 3,4,5 1 * * chklog
- B . 3 3,4,5 1 * * chklog
- C . 3 15,16,17 * * * chklog
- D . 0 15,16,17 1 * * chklog
- E . * 15,16,17 1 * * chklog
C
Explanation:
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:
Fill in Blanks
The ________ command is used to add a group to the system.
/usr/sbin/groupadd
Explanation:
The groupadd command creates a new group using the options specified on the command line and the default values from the /etc/login.defs file. It adds an entry for the new group to the /etc/group and /etc/gshadow files. Only the root user or a user with sudo privileges can create new groups using this command. The general syntax for the groupadd command is as follows: groupadd [OPTIONS] GROUPNAME
Some of the common options for the groupadd command are:
-g, –gid GID: Specify the numeric group ID for the new group. If not given, the system will assign the next available GID from the range of group IDs specified in the login.defs file.
-r, –system: Create a system group with a GID chosen from the range of system group IDs specified in the login.defs file. System groups are usually used for some special system operation purposes, like creating backups or doing system maintenance.
-f, –force: Suppress the error message if the group already exists and exit successfully. This option is useful for scripts that need to ensure the existence of a group.
-K, –key KEY=VALUE: Override the default values from the /etc/login.defs file. The valid keys are GROUP_MIN_ID, GROUP_MAX_ID, SYS_GROUP_MIN_ID, SYS_GROUP_MAX_ID, and GID_INCREMENT.
Reference:
https://www.makeuseof.com/linux-file-ownership-groups-guide/
https://linuxize.com/post/how-to-create-groups-in-linux/ https://linuxhandbook.com/groupadd-command/
Which command will set the local machine’s timezone to UTC?
- A . cat UTC > /etc/timezone
- B . ln -s /usr/share/zoneinfo/UTC /etc/localtime
- C . date –timezone=UTC
- D . mv /usr/timezone/UTC /etc
B
Explanation:
The command ln -s /usr/share/zoneinfo/UTC /etc/localtime will create a symbolic link from the file /etc/localtime to the file /usr/share/zoneinfo/UTC, which contains the binary time zone data for the UTC timezone. This will set the system’s timezone to UTC, which is the Coordinated Universal Time, the primary time standard by which the world regulates clocks and time1.
The /etc/localtime file is used by various system programs and libraries to determine the local time according to the configured timezone2. The /usr/share/zoneinfo directory contains the time zone information files for different regions and cities around the world3. The other commands are either invalid or will not change the system’s timezone permanently. The command cat UTC > /etc/timezone will overwrite the /etc/timezone file with the string “UTC”, which is not a valid timezone identifier. The /etc/timezone file is a plain text file that contains the name of the timezone, such as “America/New_York” or "Europe/Paris"4. The command date –timezone=UTC will display the current date and time in UTC, but will not change the system’s timezone setting. The command mv /usr/timezone/UTC /etc will move the file /usr/timezone/UTC to the /etc directory, but this file does not exist by default and has no effect on the system’s timezone configuration.
Reference: 1: Coordinated Universal Time – Wikipedia 2: localtime(5) – Linux manual page 3: tz database – Wikipedia 4: How to Change or Set System Locales in Linux – Tecmint : date(1) – Linux manual page : How do I change my timezone to UTC/GMT? – Ask Ubuntu
Which command should be added to /etc/bash_profile to change the language of messages from an internationalised program to Portuguese (pt)? (Select TWO correct answers)
- A . export LANGUAGE="pt"
- B . export MESSAGE="pt"
- C . export LANG="pt"
- D . export LC_MESSAGES="pt"
- E . export ALL_MESSAGES="pt"
C, D
Explanation:
The commands that should be added to /etc/bash_profile to change the language of messages from an internationalised program to Portuguese (pt) are: export LANG=“pt”
export LC_MESSAGES=“pt”
The LANG and LC_MESSAGES environment variables are used to control the language of messages
from an internationalised program. The LANG variable sets the default locale for all categories, such
as collation, currency, date and time formats, etc. The LC_MESSAGES variable sets the locale for the
language of messages, overriding the LANG variable for this category. Therefore, to change the
language of messages to Portuguese, both variables should be set to “pt” in /etc/bash_profile, which
is a script that is executed when a user logs in. This will affect the current user and any subsequent
login sessions.
Reference: Locale Environment Variables in Linux C Baeldung on Linux Environment Variables – The Open Group
[LPI Linux Essentials – 1.4 Localization and Internationalization]
A user was not given permission to use the CRON scheduling system.
What file needs to be modified to provide that access? (Please specify the full path to the file)
Explanation:
The /etc/cron.d/cron.allow file is a text file that contains the names of the users who are allowed to use the crontab command to create and manage their own cron jobs12. If this file exists, only the users listed in it can use the crontab command, and all other users are denied access12. If this file does not exist, the /etc/cron.d/cron.deny file is checked to see which users are not allowed to use the crontab command12. If neither file exists, only the root user can use the crontab command12. To modify the /etc/cron.d/cron.allow file, the root user can use any text editor to add or remove the names of the users who will be allowed to use the crontab command1234. For example, to allow the user frank to use the crontab command, the root user can append the name frank to
the /etc/cron.d/cron.allow file1234. The root user must always be included in this file, otherwise the superuser access to the crontab command will be denied4.
Reference: 1: Linux At, Batch, Atq, Atrm Command Help and Examples – Computer Hope 2: 107.2
Lesson 1 – Linux Professional Institute Certification Programs 3: /etc/cron.allow – Linux Bash Shell Scripting Tutorial Wiki – nixCraft 4: Controlling Access to crontab (System Administration Guide … – Oracle
Which commands can you use to change a user’s account aging information? (Choose THREE correct answers.)
- A . usermod
- B . passwd
- C . chattr
- D . chage
- E . chsh
A, B, D
Explanation:
The commands that can be used to change a user’s account aging information are: usermod: this command can modify various user account properties, including the password expiration date, the account expiration date, the minimum and maximum password age, the password warning period, and the password inactivity period. To use this command, you need to specify the option and the value for the property you want to change, followed by the username. For example, to set the password expiration date for the user test to February 11, 2022, you can run: usermod -e 2022-02-11 test
To view the current account aging information for a user, you can use the -l option with the usermod command. For example, to view the information for the user test, you can run:
usermod -l test
passwd: this command can change the password of a user account, as well as some password aging options. To use this command, you need to specify the username and the option for the property you want to change. For example, to change the password of the user test, you can run: passwd test
To set the maximum password age for the user test to 90 days, you can run:
passwd -x 90 test
To view the current password aging information for a user, you can use the -S option with the passwd command. For example, to view the information for the user test, you can run: passwd -S test
chage: this command can change the user password expiry and aging information, such as the password expiration date, the account expiration date, the minimum and maximum password age, the password warning period, and the password inactivity period. To use this command, you need to specify the option and the value for the property you want to change, followed by the username. For example, to set the account expiration date for the user test to February 11, 2022, you can run: chage -E 2022-02-11 test
To view the current account aging information for a user, you can use the -l option with the chage command. For example, to view the information for the user test, you can run: chage -l test
The other options are incorrect because:
chattr: this command can change the file attributes on a Linux file system, such as making a file immutable, append-only, or undeletable. It has nothing to do with user account aging information. chsh: this command can change the login shell of a user account, such as bash, zsh, or ksh. It has nothing to do with user account aging information.
Reference: How to Manage User Password Expiration and Aging in Linux – Tecmint Use the Chage Command in Linux
How to set user password expirations on Linux | Enable Sysadmin
How to change password and account expiry options on Linux using chage – Linux Tutorials – Learn Linux Configuration 3 ways to change user password expiration date in Linux – howtouselinux
Why is /etc/shadow not world readable if the passwords are stored in an encrypted fashion?
- A . The encrypted passwords are still subject to brute force attacks.
- B . This is just for historical reasons.
- C . There is other information in the file that needs to be kept secret.
- D . The passwords can be decrypted by anyone with root access.
A
Explanation:
The /etc/shadow file is not world readable because the encrypted passwords stored in it are still vulnerable to offline brute force attacks. A brute force attack is a method of trying every possible password until finding the correct one. With modern hardware and software, millions of passwords can be tried per second. If the /etc/shadow file was world readable, anyone who logged in to the system, even as a guest, could copy the file and attempt to crack the passwords without leaving any trace. By making the file readable only by the root user, the system prevents unauthorized access to the password hashes and reduces the risk of password compromise. The other options are incorrect because they do not explain the reason for the file permissions. Option B is false, as the /etc/shadow file was created to address the security issues of the /etc/passwd file, which used to store the passwords in a world readable file. Option C is partially true, as the /etc/shadow file does contain other information related to password expiration and account locking, but this is not the main reason for making the file not world readable. Option D is irrelevant, as the passwords cannot be decrypted by anyone, even with root access, as the encryption is one-way and irreversible.
Reference:
https://www.computernetworkingnotes.com/linux-tutorials/etc-shadow-file-in-linux-explained-with-examples.html
https://kerneltalks.com/user-management/understanding-etc-shadow-file/
Of the ways listed, which is the best way to temporarily suspend a single user’s ability to interactively login?
- A . Add the user name to /etc/nologin.
- B . Change the user’s password.
- C . Change the user name in /etc/passwd.
- D . Use change to expire the user account.
- E . Place the command logout in the user’s profile.
D
Explanation:
The best way to temporarily suspend a single user’s ability to interactively login is to use the chage command to expire the user account. The chage command can modify the expiration date of a user account, which is stored in the /etc/shadow file. By setting the expiration date to a past date, the user account will be locked and the user will not be able to login. This method is temporary because the expiration date can be changed again to a future date or removed to unlock the user account. For example, to expire the user account linuxconfig, we can use the following command: # chage -E 0 linuxconfig
This will set the expiration date to January 1, 1970, which is the epoch date.
To check the expiration date of a user account, we can use the -l option:
To remove the expiration date of a user account, we can use the -E option with an empty argument:
# chage -E "" linuxconfig
The other options are either invalid or not recommended. Adding the user name to /etc/nologin will not work, because /etc/nologin is a file that contains a message to be displayed to users who try to login when the system is down for maintenance. Changing the user’s password is not a good idea, because it will affect the user’s authentication and may cause security issues. Changing the user name in /etc/passwd will also affect the user’s authentication and may cause inconsistencies with other files and services. Placing the command logout in the user’s profile will not prevent the user from logging in, but only log them out immediately after login, which is not very elegant or secure.
Reference: 1: How to disable user login with Linux nologin – LinuxConfig.org 2: Disable a user’s login without disabling the account – Unix & Linux Stack Exchange 3: How to Block or Disable Normal User Logins in Linux? – GeeksforGeeks 4: How to Disable User Logins on Linux | Baeldung on Linux 5: How to Disable a User in Linux – Linux Nightly 6: How to deactivate or disable a user account in Ubuntu 20.04 LTS – Vitux 7: chage(1) – Linux manual page
Which TWO statements about crontab are true?
- A . Every user may have their own crontab.
- B . Changing a crontab requires a reload/restart of the cron daemon.
- C . The cron daemon reloads crontab files automatically when necessary.
- D . hourly is the same as "0 * * * *".
- E . A cron daemon must run for each existing crontab.
AC
Explanation:
Which crontab entry could be used to set the system time at regular intervals?
- A . 1 0 * * * date $d $t $24
- B . 1 0 * * * ntpdate ntp1.digex.net
- C . 1 0 * * * date ntp1.digex.net
- D . 1 0 * * * runcron date ntp1.digex.net
- E . 1 0 * * * settime $d $t $24
B
Explanation:
The crontab entry that could be used to set the system time at regular intervals is the one that uses the ntpdate command to synchronize the system clock with a Network Time Protocol (NTP) server. The ntpdate command takes one or more NTP server names or IP addresses as arguments and adjusts the system clock accordingly12. The crontab entry B specifies that the ntpdate command should be executed at the first minute of the zeroth hour (i.e., 00:01) of every day of every month of every weekday, using the NTP server ntp1.digex.net34. This will ensure that the system time is updated daily with a reliable source.
The other crontab entries are either invalid or ineffective for setting the system time at regular intervals. The date command can be used to display or set the system date and time, but it requires a specific format for the argument, not an NTP server name5. The runcron and settime commands are not standard Linux commands and their functionality is unknown. The $d, $t, and $24 variables are also undefined and meaningless in this context.
Reference: 1: Linux At, Batch, Atq, Atrm Command Help and Examples – Computer Hope 2: How to set a cron job to run at a exact time? – Stack Overflow 3: 107.2 Lesson 1 – Linux Professional Institute Certification Programs 4: How to setup a crontab to execute at specific time – Stack Overflow 5: Writing a specific format of time in a text file every minute using … – Ask Ubuntu
Which of the following commands can be used to convert text files in one character encoding to another character encoding?
- A . cat
- B . convert
- C . dd
- D . iconv
- E . utf2utf
D
Explanation:
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.
Reference: 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
Topic 4, Essential System Services
Which option in the /etc/ntp.conf file specifies an external NTP source to be queried for time information? (Specify ONLY the option without any values or parameters.)
Explanation:
The server option is used to configure a persistent association with a remote server or peer. It takes an argument that is either a host name or a numeric IP address of the NTP server. The ntpd daemon will periodically send NTP packets to the specified server and adjust the local clock according to the received responses. Multiple server options can be used to specify more than one NTP source. For example, the following lines in the /etc/ntp.conf file configure four external NTP sources: server 0.asia.pool.ntp.org
server 0.oceania.pool.ntp.org
server 0.europe.pool.ntp.org
server 0.north-america.pool.ntp.org
Reference:
https://docs.ntpsec.org/latest/ntp_conf.html
https://vceguide.com/which-option-in-the-etc-ntp-conf-file-specifies-an-external-ntp-source-to-be-queried-for-time-information-2/
https://vceguide.com/which-option-in-the-etcntp-conf-file-specifies-an-external-ntp-source-to-be-queried-for-time-information/
After configuring printing on a Linux server, the administrator sends a test file to one of the printers and it fails to print.
What command can be used to display the status of the printer’s queue? (Specify ONLY the command without any path or parameters.)
/usr/bin/lpq, lpstat,
/usr/bin/lpstat
Explanation:
The command lpq can be used to display the status of the printer’s queue on a Linux server. The lpq command is part of the cups-bsd package, which provides the Berkeley commands for CUPS (Common UNIX Printing System), the standard printing system for Linux. The lpq command shows the status of a specified printer or the default printer if none is specified. It also lists the jobs that are queued for printing, along with their job IDs, owners, sizes, and names12. For example, to display the status of the printer lp1, we can use the following command: $ lpq -P lp1
lp1 is ready
The output shows that the printer lp1 is ready, and that there are two jobs in the queue, one of which is active and the other is waiting. The output also shows the owners, job IDs, file names, and sizes of the jobs. To display the status of all printers, we can use the -a option: $ lpq -a
The output shows that there are two printers, lp1 and lp2, and that lp2 has no entries in the queue.
To display more information about the jobs, such as the priority, submission time, and status, we can use the -l option:
$ lpq -l -P lp1
lp1 is ready
priority 50 Apr 27 10:05 waiting for lp1
The output shows that the jobs have the same priority, and that the first job is processing while the second job is waiting. The lpq command can be useful for troubleshooting printing problems, such as checking if the printer is ready, if there are any stuck or failed jobs, or if there are any conflicts or delays in the queue34.
Reference: 1: lpq(1) – Linux manual page 2: How to Use the lp Command in Linux to Print Files From Terminal – Make Tech Easier 3: Linux sysadmin printing reference guide – PenguinTutor 4: How to manage print jobs on Linux – Network World