What command can be used to generate syslog entries of any facility and priority? (supply just the command name without a path)
Answer : A
The logger command can be used to generate syslog entries of any facility and priority. It is a shell command interface to the syslog system log module. It allows users to write messages to the system log from the command line or from a script. The logger command supports several options to specify the facility, priority, tag, message, and other attributes of the log entry. For example, the following command generates a log entry with the facility user and the priority info:
logger -p user.info ''This is a test message''
The facility and priority can be any of the values defined in the syslog protocol, such as kern, mail, auth, local0, etc. for the facility, and emerg, alert, crit, err, warn, notice, info, debug, etc. for the priority. The default facility is user and the default priority is notice. The logger command can also read messages from standard input or from a file. For more information, see the logger man page or thelogger - Linux man pageonline.Reference:
Syslogs in Linux: Understanding Facilities and Levels
What are Syslog Facilities and Levels? - Trend Micro
syslog-ng Open Source Edition 3.30 - Administration Guide
Syslog Logging Guide: Advanced Concepts - CrowdStrike
Which of the following files is not read directly by a Bash login shell?
Answer : A
Which file contains the date of the last change of a user's password?
Answer : D
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 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?
Answer : C
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
Which of the following commands can be used to convert text files in one character encoding to another character encoding?
Answer : D
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-ooption 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-loption. 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.
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
Your senior administrator asked you to change the default background of his machine, which uses XDM. Which file would you edit to achieve this?
Answer : A
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
After issuing:
function myfunction { echo $1 $2 ; }
in Bash, which output does:
myfunction A B C
Produce?
Answer : A
In Bash, a function is a block of code that can be invoked by its name. A function can take arguments, which are passed to the function as positional parameters. The$1variable refers to the first argument,$2to 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 functionmyfunctionsimply echoes the first and second arguments to the standard output. Therefore, when the commandmyfunction A B Cis executed, the output isA B, since the third argumentCis ignored by the function.Reference:
[LPI Linux Essentials - Topic 103: Command Line Basics]
[Bash Functions]