What is the purpose of the nsswitch.conf file?
It is used to configure where the C library looks for system information such as host names and user passwords.
It is used to configure network protocol port numbers such as for HTTP or SMTP.
It is used to configure LDAP authentication services for the local system.
It is used to configure which network services will be turned on during the next system boot.
The nsswitch.conf file is a configuration file that determines the sources and the order of the sources that are queried for various system databases, such as user information, group information, host names, network services, and more. The C library uses this file to look up various system information when a program or a command requests it. For example, when a user logs in, the C library will use the nsswitch.conf file to determine where to find the user’s password, whether it is in the local /etc/passwd file, or in a remote LDAP server, or both. The nsswitch.conf file allows the system administrator to configure the system databases in a flexible and modular way. References:
[LPI Linux Essentials - Topic 106: The Linux Operating System]
[LPI Linux Administrator - Exam 102 Objectives - Topic 110: Security]
[Linux man page for nsswitch.conf]
How many IP-addresses can be used for unique hosts inside the IPv4 subnet 192.168.2.128/28? (Specify the number only without any additional information.)
14
To find the number of IP-addresses that can be used for unique hosts inside an IPv4 subnet, we need to calculate the number of bits that are used for the host part of the IP address. The host part is the part that is not used for the network prefix, which is indicated by the slash notation (/) followed by a number. The number after the slash represents the number of bits that are used for the network prefix, out of the total 32 bits of an IPv4 address. The remaining bits are used for the host part. For example, in the subnet 192.168.2.128/28, the number 28 means that the first 28 bits are used for the network prefix, and the last 4 bits are used for the host part.
The number of IP-addresses that can be used for unique hosts is equal to 2^n - 2, where n is the number of bits in the host part. The -2 is because the first and the last IP addresses in a subnet are reserved for the network address and the broadcast address, respectively, and cannot be assigned to hosts. Therefore, in the subnet 192.168.2.128/28, the number of IP-addresses that can be used for unique hosts is 2^4 - 2, which is 14.
References:
IPv4 - Subnetting - Online Tutorials Library
IP Subnet Calculator
Which of the following may occur as a consequence of using the command ifconfig? (Choose THREE correct answers.)
New name servers may be added to the resolver configuration.
Network interfaces may become active or inactive.
The routing table may change.
IP addresses may change.
The system's host name may change.
Network interfaces may become active or inactive, the routing table may change, and IP addresses may change. Comprehensive Explanation: The ifconfig command is a network management tool that is used to configure and view the status of the network interfaces in Linux operating systems1. With ifconfig, you can assign IP addresses, enable or disable interfaces, manage ARP cache, routes, and more1. Some of the possible consequences of using the ifconfig command are:
Network interfaces may become active or inactive. The ifconfig command can take an interface name as an argument and display the configuration information for that interface. For example, to view the configuration of the eth0 interface, one can run:
ifconfig eth0
The output shows whether the interface is UP or DOWN, meaning active or inactive. The ifconfig command can also activate or deactivate an interface by using the up or down options. For example, to deactivate the eth0 interface, one can run:
sudo ifconfig eth0 down
To activate the eth0 interface, one can run:
sudo ifconfig eth0 up
The routing table may change. The ifconfig command can assign IP addresses, netmask, and broadcast address to a network interface. For example, to assign an IP address of 192.168.1.10, a netmask of 255.255.255.0, and a broadcast address of 192.168.1.255 to the eth0 interface, one can run:
sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
These parameters affect the routing table, which is a list of rules that determine where the packets are sent. The routing table can be viewed by using the route command. For example, to view the routing table, one can run:
route -n
The output shows the destination, gateway, netmask, flags, metric, reference, use, and interface for each route. The ifconfig command can also delete an IP address from an interface, which may remove the corresponding route from the routing table. For example, to delete the IP address of 192.168.1.10 from the eth0 interface, one can run:
sudo ifconfig eth0 0
IP addresses may change. The ifconfig command can assign or delete IP addresses to a network interface, as explained above. The IP address is a unique identifier that allows the network interface to communicate with other devices on the network. The IP address can be viewed by using the ifconfig command without any options or with the interface name only. For example, to view the IP address of the eth0 interface, one can run:
ifconfig eth0
The output shows the inet addr, which is the IP address of the interface. The ifconfig command can also create an alias for the network interface, which is a virtual interface that shares the same physical interface but has a different IP address. For example, to create an alias for the eth0 interface with an IP address of 192.168.1.11, one can run:
sudo ifconfig eth0:0 192.168.1.11
The alias can be viewed by using the ifconfig command with the alias name. For example, to view the configuration of the eth0:0 alias, one can run:
ifconfig eth0:0
The output shows the inet addr, which is the IP address of the alias.
The other options are not correct because:
New name servers may be added to the resolver configuration. The ifconfig command does not affect the resolver configuration, which is a file that contains the names and addresses of the name servers that resolve domain names to IP addresses. The resolver configuration is stored in the /etc/resolv.conf file and can be viewed or edited by using a text editor. For example, to view the resolver configuration, one can run:
cat /etc/resolv.conf
The output shows the nameserver entries, which are the IP addresses of the name servers. The ifconfig command does not add or remove name servers from this file.
The system’s host name may change. The ifconfig command does not affect the host name, which is a name that identifies the system on the network. The host name is stored in the /etc/hostname file and can be viewed or edited by using a text editor. For example, to view the host name, one can run:
cat /etc/hostname
The output shows the host name of the system. The ifconfig command does not change the host name of the system. References:
Which of the following is a valid IPv6 address?
2001:db8:3241::1
2001::db8:4581::1
2001:db8:0g41::1
2001%db8%9990%%1
2001.db8.819f..1
A valid IPv6 address is represented as a set of 16-bit hexadecimals separated by colons. The address is divided into eight groups, and each 16-bit group is represented by four hexadecimal numbers. A valid IPv6 address is in the form “x1:x2:x3:x4:x5:x6:x7:x8” where each xi is a hexadecimal string which may contain digits, lower-case English letter (‘a’ to ‘f’) and upper-case English letters (‘A’ to ‘F’). Leading zeros are allowed in xi. The longest sequence of consecutive all-zero fields is replaced with two colons (::).1
Option A is the only one that follows these rules. Option B has two consecutive colons twice, which is not allowed. Option C has an invalid hexadecimal character ‘g’. Option D uses percentage signs instead of colons, which is not a valid separator. Option E uses dots instead of colons, and has two consecutive dots, which are both invalid.
References: 1: IPv4 and IPv6 address formats - IBM
Which of the following IPv4 networks are reserved by IANA for private address assignment and private routing? (Choose THREE correct answers.)
127.0.0.0/8
10.0.0.0/8
169.255.0.0/16
172.16.0.0/12
192.168.0.0/16
According to the RFC 19181, the Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IPv4 address space for private internets:
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
These address blocks are not globally routable and are intended for use within private networks, such as home, office, or campus networks. They can be assigned to any device that does not need to communicate directly with the public internet, or that can use network address translation (NAT) to do so. Private addresses allow for more efficient use of the limited IPv4 address space and reduce the need for public addresses.
The other options are not reserved for private use by IANA. Option A, 127.0.0.0/8, is reserved for loopback addresses, which are used to refer to the local host. Option C, 169.255.0.0/16, is a typo and should be 169.254.0.0/16, which is reserved for link-local addresses, which are used for automatic address configuration on a local network segment. Option F, 224.0.0.0/4, is reserved for multicast addresses, which are used for one-to-many communication.
References:
RFC 1918: Address Allocation for Private Internets - RFC Editor
IANA IPv4 Special-Purpose Address Registry
Private network - Wikipedia
Which port is the default server port for the HTTPS protocol? (Specify the port number using digits.)
443
The port number 443 is the default server port for the HTTPS protocol, which is a secure version of HTTP that uses SSL/TLS certificates to encrypt the data transmission between web servers and browsers. The port number 443 is recognized by the Internet Engineering Task Force (IETF) as the standard port for HTTPS connections1. The port number 443 is part of the topic 109.1: Fundamentals of internet protocols, which is one of the objectives of the LPI Linux Administrator - 102 exam23. References: 1: HTTPS Port: What It Is, How to Use It, and More (2023) - Hostinger 2: LPI Linux Administrator - 102 (LPIC-1) 3: Exam 102 Objectives
Which keyword must be listed in the hosts option of the Name Service Switch configuration file in order to make host lookups consult the /etc/hosts file?
files
The keyword files must be listed in the hosts option of the Name Service Switch configuration file in order to make host lookups consult the /etc/hosts file. The files service specifies that the local files, such as /etc/hosts, should be used as a source of information. The order of the services on the line determines the order in which those services will be queried, in turn, until a result is found. For example, if the hosts option is set to:
hosts: files dns
then the /etc/hosts file will be searched first, and if no match is found, the DNS server will be queried next. If the hosts option is set to:
hosts: dns files
then the DNS server will be queried first, and if no match is found, the /etc/hosts file will be searched next. References:
LPI 102-500 Exam Objectives, Topic 110: Network Fundamentals, Weight: 4, 110.3 Basic network troubleshooting
LPI 102-500 Study Guide, Chapter 10: Network Fundamentals, Section 10.3: Basic Network Troubleshooting, Page 125-126
nsswitch.conf: Name Service Switch configuration file
Which of the following tools used for DNS debugging, reports not only the response from the name server but also details about the query?
dnsq
dig
hostname
dnslookup
zoneinfo
The tool that reports not only the response from the name server but also details about the query is dig. Dig stands for domain information groper and it is a command-line tool that can query DNS servers for various types of records. Dig can also provide additional information such as the query time, the server address, the query options, and the response code. Dig is a powerful and flexible tool that can be used for DNS troubleshooting and testing123 References:
1: How to use the dig command - Linux.com
2: dig(1) - Linux manual page - man7.org
3: Top 6 Tools for DNS Troubleshooting | Total Uptime®
Which of the following statements is valid in the file /etc/nsswitch.conf?
multi on
192.168.168.4 dns-server
hosts: files dns
include /etc/nsswitch.d/
The statement hosts: files dns is valid in the file /etc/nsswitch.conf. It means that the system will use the local /etc/hosts file and the Domain Name System (DNS) to resolve host names to IP addresses. The order of the sources on the line determines the order in which they will be queried. In this case, the system will first check the /etc/hosts file for a matching host name, and if not found, it will query the DNS servers configured in /etc/resolv.conf. The other statements in the question are not valid in the /etc/nsswitch.conf file. The statement multi on is not a valid keyword or source for any database. The statement 192.168.168.4 dns-server is not a valid syntax for specifying a source or an action. The statement include /etc/nsswitch.d/ is not a valid way to include another file or directory in the /etc/nsswitch.conf file. References:
[LPI Linux Administrator - Exam 102 Objectives - Topic 109: Networking Fundamentals]
nsswitch.conf(5) - Linux manual page
What is the /etc/nsswitch.conf file in Linux – TecAdmin
Which of the following lines are valid in the file /etc/hosts? (Choose TWO correct answers.)
2001:db8::15 www.example.com www
www.example.com www 203.0.13.15
203.0.113.15 www.example.com www
www.example.com,www 203.0.13.15,2001:db8::15
2003.0.113.15,2001:db8::15 www.example.com www
The valid lines in the file /etc/hosts are A and C. The format of the /etc/hosts file is as follows12:
IP_address canonical_hostname [aliases...]
where IP_address is the IPv4 or IPv6 address of the host, canonical_hostname is the official name of the host, and aliases are optional alternative names for the host. Each field is separated by whitespace (spaces or tabs). The # character indicates the beginning of a comment, and the rest of the line is ignored.
The lines B, D, and E are invalid because they do not follow the format of the /etc/hosts file. Line B has the hostname and aliases before the IP address, which is incorrect. Line D has multiple IP addresses and hostnames separated by commas, which is also incorrect. Line E has two IP addresses for the same host, which is not supported by the /etc/hosts file. If a host has more than one IP address, it should have a separate line for each address3.
References:
1: hosts(5) - Linux manual page - man7.org
2: Format of /etc/hosts on Linux (different from Windows?)
3: hosts File Format for TCP/IP - IBM
Which of the following keywords can be used in the file /etc/nsswitch.conf to specify a source for host name lookups? (Choose TWO correct answers.)
resolve
dns
remote
files
hosts
The keywords dns and files can be used in the /etc/nsswitch.conf file to specify a source for host name lookups. The keyword dns means that the system will use the Domain Name System (DNS) to resolve host names to IP addresses. The keyword files means that the system will use the local /etc/hosts file to resolve host names to IP addresses. The order of the keywords on the line determines the order in which the sources will be queried. For example, the following line in /etc/nsswitch.conf:
hosts: files dns
means that the system will first check the /etc/hosts file for a matching host name, and if not found, it will query the DNS servers configured in /etc/resolv.conf. The other keywords in the question are not valid for the hosts database. The keyword resolv is used for the services database, which contains network service names and port numbers. The keyword remote is not a standard keyword, but it may be used by some applications to implement their own name service providers. The keyword hosts is the name of the database itself, not a source for it. References:
[LPI Linux Administrator - Exam 102 Objectives - Topic 109: Networking Fundamentals]
nsswitch.conf(5) - Linux manual page
What is the /etc/nsswitch.conf file in Linux – TecAdmin
Which command, depending on its options, can display the open network connections, the routing tables, as well as network interface statistics. (Specify ONLY the command without any path or parameters.)
netstat, /bin/netstat, ss, /usr/bin/ss
The netstat command, meaning network statistics, is a command-line utility in the Linux system to display network configuration and activity, including network connections, routing tables, interface statistics, masquerade connections, and multicast memberships1. The netstat command can display different types of network data depending on the command line option selected. Some of the common options are:
-a: This option displays active TCP connections, TCP connections with the listening state, as well as UDP ports that are being listened to.
-r: This option displays the routing table information, which is a list of rules that determine where the packets are sent.
-i: This option displays the network interface information, such as the name, MTU, RX-OK, TX-OK, etc.
-s: This option displays the network statistics by protocol, such as TCP, UDP, ICMP, IP, etc.
For example, to display the open network connections, one can run:
netstat -a
To display the routing table, one can run:
netstat -r
To display the network interface statistics, one can run:
netstat -i
To display the network statistics by protocol, one can run:
netstat -s
For more details and examples, please refer to the web search results1 or the question answering results2. References:
What information related to a user account is modified using the change command?
Default ownership for new files
Group membership
Set of commands available to the user
Password expiry information
Default permissions for new files
What the echo $$ command?
The process ID of the current shell.
The process ID for the following command.
The process ID of the last command executed.
The process ID of the last command which has been placed in the background.
The process ID of the echo command.
The echo command is a built-in Linux feature that prints out arguments as the standard output1. The echo command can take various options and arguments to display different types of information. One of the arguments that can be used with the echo command is $$, which represents the process ID (PID) of the current shell2. A process ID is a unique number that identifies a running process in the system. The current shell is the shell that is executing the echo command. For example, if you are using the Bash shell and run the following command:
echo $$
The output will show the PID of the Bash shell, such as:
1234
The echo
commandcanbeusefultocheckwhichshellyouareusing,ortofindoutthePIDofthecurrentshellfordebuggingormonitoringpurposes.Theecho
command is different from the following commands:
echo $!: This command displays the PID of the last command executed in the background2. A background command is a command that runs without blocking the shell, allowing you to continue using the shell while the command executes. For example, if you run the following command:
sleep 10 &
This command will put the sleep command, which pauses the execution for 10 seconds, in the background. The output will show the PID of the sleep command, such as:
1 2345
If you then run the following command:
echo $!
The output will show the same PID of the sleep command, such as:
2345
echo $?: This command displays the exit status of the last command executed2. The exit status is a number that indicates whether the command was successful or not. A zero exit status means the command was successful, while a non-zero exit status means the command failed or encountered an error. For example, if you run the following command:
ls /home
This command will list the contents of the /home directory. If the command succeeds, the output will show the files and directories in the /home directory, such as:
alice bob charlie
If you then run the following command:
echo $?
The output will show the exit status of the ls command, which is zero, meaning the command was successful:
0
echo $0: This command displays the name of the current shell or script2. The name of the current shell is the name of the executable file that runs the shell, such as bash, zsh, ksh, etc. The name of the current script is the name of the file that contains the script, such as script.sh, script.py, etc. For example, if you are using the Bash shell and run the following command:
echo $0
The output will show the name of the current shell, such as:
bash
References:
2
Which of the following are valid host addresses for the subnet 203.0.113.64/28? (Choose TWO correct answers.)
2030.113.64
2030.113.78
203.0.113.65
203.0.113.80
203.0.113.81
What is Irue aboul Network Manager on a Linux syslem that uses its distribution's mechanisms lo configure network interfaces? (Choose TWO correct answers.)
NetworkManager reconfigures all network interfaces to use DHCP unless they are specifically managed by NetworkManager
NetworkManager musl be explicitly enabled for each interface it should manage.
NetworkManager by default does not change interfaces which are already configured.
NetworkManager disables all interfaces which were not configured by NetworkManager.
NetworkManager can be configured to use the distribution's network interface configuration.
Which of Ihe following commands will delete Ihe defaull gateway from the system's IP touting table? (Choose TWO correct answers.)
Ifconfig unaet default
Route del default
Ip route del default
Netstat –r default
Sysct1 ipv1default_gw=0
Which command is used to set restrictions on the size of a core file that is created for a user when a program crashes?
core
edquota
ulimit
quota
The ulimit command is used to set or display the limitations on the system resources available to the current shell and its descendants. One of the resources that can be controlled by ulimit is the maximum size of a core file that is created when a program crashes. A core file is a snapshot of the memory and registers of a process at the time of termination, which can be used for debugging purposes. By default, the core file size limit is zero, which means no core file will be generated. To change the core file size limit, the option -c can be used with ulimit, followed by a number that represents the maximum number of blocks (usually 512 bytes) that can be written to a core file. For example, the command ulimit -c 1000 will set the core file size limit to 512000 bytes. To remove the core file size limit, the option -c can be used with ulimit, followed by unlimited. For example, the command ulimit -c unlimited will allow core files of any size to be created. References:
LPIC-1 Exam 102 Objectives, Topic 103: Linux Installation and Package Management, Subtopic 103.3: Manage shared libraries, Weight: 1, Key Knowledge Areas: Identify the location and purpose of important file and directories as defined in the FHS, Objective: Use the ulimit command to set or display limitations on the system resources available to the current shell and its descendants.
LPIC-1 Exam 102 Learning Materials, Topic 103: Linux Installation and Package Management, Subtopic 103.3: Manage shared libraries, Section 103.3.2: ulimit, Page 14-15.
Which of the following tasks can the date command accomplish? (Choose two.)
Set the system’s date and time.
Set the system’s date but not the time.
Calculate the time span between two dates.
Print a calendar for a month or a year.
Display time in a specific format.
The date command is used to display or set the system’s date and time. The date command has the following syntax:
date [options] [+format] [time]
The options can modify the behavior of the date command, such as setting the time zone, printing the date in RFC 3339 format, or updating the hardware clock. The +format argument can specify the output format of the date command, using various conversion specifiers that represent different components of the date and time, such as %Y for the year, %m for the month, %d for the day, %H for the hour, %M for the minute, and %S for the second. The time argument can set the system’s date and time, using the format MMDDhhmm[[CC]YY][.ss], where MM is the month, DD is the day, hh is the hour, mm is the minute, CC is the century, YY is the year, and ss is the second.
Therefore, the date command can accomplish the following tasks:
A. Set the system’s date and time. For example, to set the system’s date and time to November 8, 2023, 18:30:00, the command would be:
date 110818302023.00
E. Display time in a specific format. For example, to display the current date and time in the format YYYY-MM-DD HH:MM:SS, the command would be:
date +%Y-%m-%d %H:%M:%S
The other options in the question are not correct for this task. The date command cannot set the system’s date but not the time, as the time argument requires both the date and the time components. The date command cannot calculate the time span between two dates, as it can only display or set the current date and time. The date command cannot print a calendar for a month or a year, as that is the function of the cal command.
References:
LPI 102-500 Exam Objectives, Topic 105.1: Customize and use the shell environment
LPI 102-500 Study Guide, Chapter 5: Customizing Shell Environments, Section 5.1: Working with the Shell
date man page
Which of the following statements is true regarding systemd timer units?
Timer units can only be defined within a service unit’s file.
The command executed by the timer is specified in the timer unit’s [Cmd] section.
A dedicated system service, systemd-cron, handles the execution of timer units.
Timer units only exist in the system scope and are not available for users.
Each systemd timer unit controls a specific systemd service unit.
systemd timer units are a type of systemd unit files that define when and how to activate another systemd unit, usually a service unit. Each timer unit has a corresponding service unit that it controls, and by default, the name of the timer unit matches the name of the service unit, except for the suffix. For example, a timer unit named foo.timer activates and manages a service unit named foo.service. The service unit defines what to run when the timer elapses, and the timer unit defines when and how to run the service unit. The timer unit can specify different types of timers, such as calendar-based or monotonic timers, and various options to control the frequency, accuracy, and persistence of the timer. The timer unit can also override the service unit to activate by using the Unit= option in the [Timer] section of the timer unit file.
The other statements listed are false regarding systemd timer units. Timer units are not defined within a service unit’s file, but in a separate file with the .timer extension. The command executed by the timer is not specified in the timer unit’s file, but in the service unit’s file that the timer controls. There is no dedicated system service named systemd-cron that handles the execution of timer units, as timer units are managed by systemd itself. Timer units can exist in both the system scope and the user scope, and users can create and manage their own timer units in their home directories. References:
systemd/Timers - ArchWiki
systemd.timer - freedesktop.org
Working with systemd Timers - SUSE Documentation
Which of the following connection types, as seen in unroll connection show, may exist in Network Manager? (Choose THREE correct answers.)
tcp
Ethernet
wifi
ipv6
bridge
The connection types, as seen in nmcli connection show, are the types of network configurations that Network Manager can manage. They are not the same as the network protocols or layers, such as TCP or IPv6, but rather the logical or physical ways of connecting to a network. According to the Network Manager reference manual1, some of the possible connection types are:
wifi: This connection type is for wireless network interfaces that use the IEEE 802.11 standard. It requires a wifi device and a wifi access point to establish a connection. The connection settings include the SSID, security, password, etc.
bridge: This connection type is for creating a network bridge, which is a device that connects two or more network segments and forwards packets between them. It requires a bridge device and one or more slave devices to be attached to the bridge. The connection settings include the bridge name, MAC address, STP, etc.
vpn: This connection type is for creating a virtual private network, which is a secure tunnel between two or more network endpoints. It requires a VPN plugin and a VPN service provider to establish a connection. The connection settings include the VPN type, service name, user name, password, etc.
The other options are not correct because:
tcp: This is not a connection type, but a network protocol that operates at the transport layer. It provides reliable, ordered, and error-checked delivery of data between applications. It is not a configuration option for Network Manager.
Ethernet: This is not a connection type, but a network technology that operates at the physical and data link layers. It defines the standards for wiring, signaling, and framing of data packets. It is not a configuration option for Network Manager, but rather a device type that can be used by other connection types, such as bridge or vpn.
ipv6: This is not a connection type, but a network protocol that operates at the network layer. It provides addressing and routing of data packets across networks. It is not a configuration option for Network Manager, but rather an IP configuration option that can be used by other connection types, such as wifi or vpn. References:
What argument to the -type option of find will match files that are symbolic links? (Specify only the argument and no other options or words.)
l
The -type option of the find command allows you to specify the type of file you want to search for. The argument l (lowercase L) will match files that are symbolic links, which are special files that point to another file or directory. Symbolic links are also known as soft links or symlinks. For example, the command find /home -type l will find all the symbolic links in the /home directory and its subdirectories.
References: 1: How do I find all of the symlinks in a directory tree? - Stack Overflow 2: find(1) - Linux manual page - man7.org 3: Symbolic Links (GNU Findutils 4.9.0) 4: Find All Symbolic Links in Linux - Linux Handbook 5: Find all symbolic links with the find command
Which of the following commands lists all queued print jobs?
lpd
lpr
lp
lsq
lpq
The lpq command, meaning list print queue, is a command-line utility in the Linux system to display the status of the print queue for a specified printer or class1. The lpq command can take various options and arguments to filter and format the output. By default, the lpq command shows the print queue for the default printer or class, which is determined by the PRINTER or LPDEST environment variables, or the /etc/printcap file. For example, to display the print queue for the default printer, one can run:
lpq
The output shows the printer name, status, rank, owner, job number, file size, and file name for each print job. For example, the output may look like:
Printer: lp@localhost ‘HP LaserJet 1020’ Queue: no printable jobs in queue Server: no server active Status: printer idle. enabled since Tue 09 Nov 2021 10:00:00 AM EST Rank Owner Job File(s) Total Size 1st alice 123 report.pdf 1024 bytes 2nd bob 124 memo.docx 2048 bytes 3rd charlie 125 presentation.pptx 4096 bytes
This shows that there are three print jobs in the queue for the printer lp@localhost, which is an HP LaserJet 1020. The first job belongs to alice, the second to bob, and the third to charlie. The lpq command can also display the print queue for a specific printer or class by using the -P option, followed by the printer or class name. For example, to display the print queue for the printer lp1, one can run:
lpq -P lp1
The output shows the print queue for the printer lp1, which may be different from the default printer. The lpq command can also display the print queue for all printers or classes by using the -a option. For example, to display the print queue for all printers or classes, one can run:
lpq -a
The output shows the print queue for each printer or class, separated by a blank line. The lpq command is different from the following commands:
lpd: This is not a command, but a daemon that provides print spooling and network printing services for the Linux system2. The lpd daemon is started by the system initialization scripts and runs in the background. It does not display the print queue for any printer or class.
lpr: This is a command that submits print jobs to the print queue for a specified printer or class3. The lpr command can take various options and arguments to specify the print options and the files to be printed. For example, to print the file report.pdf to the default printer, one can run:
lpr report.pdf
The lpr command does not display the print queue for any printer or class.
lp: This is a command that submits print jobs to the print queue for a specified printer or class, similar to the lpr command4. The lp command can take various options and arguments to specify the print options and the files to be printed. For example, to print the file report.pdf to the printer lp1, one can run:
lp -d lp1 report.pdf
The lp command does not display the print queue for any printer or class.
lsq: This is not a valid command in the Linux system. It may be a typo or a misspelling of the lpq command. It does not display the print queue for any printer or class. References:
1
Which of the following commands display a list of jobs in the print queue? (Choose TWO correct answers.)
Cups—list
Iprm -1
Lpstat
Ipr –q
ipq
Which file used by XDM specifies the default wallpaper?
/etc/X11/xdm/Xsetup
/etc/X11/xdm.conf
/etc/X11/xdm/Defaults
/etc/X11/defaults.conf
The file that specifies the default wallpaper for XDM is /etc/X11/xdm/Xsetup. XDM is a display manager for the X Window System that provides a graphical login screen and manages user sessions. The /etc/X11/xdm/Xsetup file is executed when XDM starts the X server and before any user login or session starts. This file can be used to configure the X server, set X resources, and perform any other system-wide setup tasks, such as setting the wallpaper. To set the wallpaper, one can use a command like qiv -z /usr/local/share/backgrounds/wallpaper.jpg in the /etc/X11/xdm/Xsetup file, where qiv is an image viewer and /usr/local/share/backgrounds/wallpaper.jpg is the path to the desired wallpaper image1.
The other options are not correct/etc/X11/xdm.conf is the configuration file for XDM, which specifies how XDM should behave, such as the access control, the login window, and the session types2/etc/X11/xdm/Defaults is the directory where the default XDM configuration files are stored, such as Xresources, Xsession, and Xwilling2. /etc/X11/defaults.conf is not a valid file or directory related to XDM or X Window System. References:
XDM - ArchWiki
Configuring XDM - Linux Documentation Project
Why is the xhost program considered dangerous to use?
It makes it difficult to uniquely identify a computer on the network.
It allows easy access to your X server by other users.
It logs sensitive information to syslog.
It makes your computer share network resources without any authentication.
It is a graphical DNS tool with known exploits.
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. References:
xhost linux command man page - commandlinux.com
Linux Xhost Command Help and Examples - Computer Hope
xhost(1) — Arch manual pages
For accessibility assistance, which of the following programs is an on-screen keyboard?
xkb
atkb
GOK
xOSK
GOK stands for GNOME On-screen Keyboard, and it is a program that provides a virtual keyboard for users who have difficulty using a physical keyboard. GOK is designed to be accessible and customizable, and it supports different keyboard layouts, input methods, and modes. GOK can also generate mouse and gesture events, and it can be controlled by various input devices, such as switches, joysticks, or head trackers. GOK is part of the GNOME desktop environment, and it can be enabled from the Universal Access settings panel123.
The other options are not correct because:
A. xkb is not a program, but a component of the X Window System that handles keyboard configuration and mapping. XKB stands for X Keyboard Extension, and it allows users to define the behavior and appearance of their keyboards, such as the layout, the modifiers, the symbols, and the actions. XKB does not provide an on-screen keyboard, but it can be used by other programs that do45.
B. atkb is not a valid name for any known program or component related to on-screen keyboards. There is no such program or component in the LPI Linux certification program or in the common Linux distributions. The closest match is ATK, which stands for Accessibility Toolkit, and it is a library that provides a set of interfaces for accessibility support in GNOME applications. ATK does not provide an on-screen keyboard, but it can be used by GOK and other programs that do6 .
D. xOSK is a program that provides an on-screen keyboard, but it is not the one that is mentioned in the LPI Linux certification program or in the common Linux distributions. xOSK stands for X On-Screen Keyboard, and it is a simple and lightweight virtual keyboard that can be used with any X11 application. xOSK is not part of any desktop environment, and it has to be installed and launched manually. xOSK is not as accessible and customizable as GOK, and it does not support different input methods or modes .
References: 1: GOK - GNOME Wiki! 2: How to Set Up a Virtual On-Screen Keyboard in Linux 3: Working With On-Screen Keyboards - Oracle Help Center 4: X keyboard extension - Wikipedia 5: XKB Configuration Guide 6: Accessibility Toolkit - GNOME Developer : Accessibility - ArchWiki : xosk - X On-Screen Keyboard : How to use on-screen virtual keyboard on Linux - Xmodulo
Which of the following lines is an example of a correct setting for the DISPLAY environment variable?
hostname:displayname
hostname:displaynumber
hostname/displayname
hostname/displaynumber
hostname
The correct format for the DISPLAY environment variable is hostname:displaynumber.screennumber, where hostname is the name of the computer where the X server runs, displaynumber is a sequence number (usually 0) that identifies a display, and screennumber is the number of the screen within that display (usually 0). The screennumber can be omitted if it is 0. For example, localhost:0 or myhost:1.0 are valid values for the DISPLAY variable. The other options are either missing the colon, using the wrong separator, or not specifying the display number. References:
X11 - DISPLAY (environment variable) - Datacadamia
x11 - How can I specify a display? - Stack Overflow
What is the $DISPLAY environment variable? - Ask Ubuntu
On a system running the KDE Display Manager, when is the /etc/kde4/kdm/Xreset script automatically executed?
When KDM starts
When a user's X session exits
When KDM crashes
When X is restarted
When X crashes
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. References:
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 …
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.)
xdm
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. References:
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
How is a display manager started?
It is started by a user using the command startx.
It is started like any other system service by the init system.
It is started by inetd when a remote hosts connects to the X11 port.
It is started automatically when a X11 user logs in to the system console.
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:
A. It is started by a user using the command startx. This option is false because the startx command is used to start an X session without a display manager. The startx command launches an X server and runs the user’s .xinitrc or .xsession file, which contains the commands to start the desired desktop environment or window manager. The startx command does not invoke a display manager or a graphical login screen .
C. It is started by inetd when a remote hosts connects to the X11 port. This option is false because inetd is a daemon that listens for incoming network connections and launches the appropriate service for each connection. Inetd does not start a display manager, but it can be used to enable remote access to an X session using the XDMCP protocol. XDMCP stands for X Display Manager Control Protocol, and it allows a remote host to request a graphical login screen from a display manager running on another host. However, this is not the same as starting a display manager, and it requires the display manager to be already running on the host that provides the XDMCP service .
D. It is started automatically when a X11 user logs in to the system console. This option is false because a display manager is not started by a user login, but by the init system. A user login can trigger the start of an X session, but not a display manager. A display manager is independent of the user login, and it can run on multiple virtual consoles or display devices. A display manager can also allow multiple users to log in to different X sessions simultaneously123.
References: 1: LPI Linux Certification/Setup A Display Manager - Wikibooks 2: Working with Display Managers - LPIC-1 102 Linux certification - Linux … 3: How to Change the Default Display Manager in Ubuntu 20.04 : startx - ArchWiki : How to start GUI from command line? - Ask Ubuntu : inetd - Wikipedia : XDMCP - ArchWiki
Your senior administrator asked you to change the default background of his machine, which uses XDM. Which file would you edit to achieve this?
/etc/X11/xdm/Xsetup
/etc/X11/xdm.conf
/etc/X11/xdm/Defaults
/etc/X11/defaults.conf
The file /etc/X11/xdm/Xsetup contains commands that are executed by XDM before displaying the login screen. This file can be used to set the background image, color, or run other programs on the X display. The other files are either not related to XDM or do not exist by default. References:
XDM - ArchWiki
Customizing the XDM Login Screen | Linux Journal
An administrator wants to determine the geometry of a particular window in X, so she issues the __________ -metric command and then clicks on the window.
/usr/bin/xwininfo, xwininfo
The xwininfo command is a utility for displaying information about windows in X. It can show various attributes of a window, such as its location, size, depth, border width, visual class, colormap, map state, and event masks. The -metric option specifies that all dimensions should be displayed in metric units (millimeters) rather than pixels. By issuing the xwininfo -metric command and then clicking on a window, the administrator can determine the geometry of that window, including the decorations, in millimeters. References:
xwininfo(1) — Arch manual pages
[command line -
The X11 configuration file xorg.conf is grouped into sections. How is the content of the section SectionName associated with that section?
It is placed in curly brackets as in Section SectionName { ... }.
It is placed between a line containing Section "SectionName" and a line containing EndSection.
It is placed between the tags
It is placed after the row [SectionName].
It is placed after an initial unindented Section "SectionName" and must be indented by exactly one tab character.
The X11 configuration file xorg.conf is grouped into sections, and the content of the section SectionName is associated with that section by placing it between a line containing Section “SectionName” and a line containing EndSection. For example, the following is a section named ServerLayout that defines the layout of the X server:
Section “ServerLayout” Identifier “X.org Configured” Screen 0 “Screen0” 0 0 InputDevice “Mouse0” “CorePointer” InputDevice “Keyboard0” “CoreKeyboard” EndSection
The other options are incorrect for the following reasons:
A: Curly brackets are not used to delimit sections in xorg.conf. They are used to enclose values that are lists, such as Option “XkbLayout” “{us,fr}”.
C: Tags are not used to delimit sections in xorg.conf. They are used in XML files, which have a different syntax and structure than xorg.conf.
D: Rows are not used to delimit sections in xorg.conf. They are used to define key-value pairs within a section, such as Identifier “Screen0”.
E: Indentation is not required to delimit sections in xorg.conf. It is used to improve readability and clarity, but it does not affect the functionality of the file.
References:
xorg.conf - X Window System
Editing basics for the xorg.conf file - Linux.com
106.1 Lesson 1 - Linux Professional Institute Certification Programs
What is the default name of the configuration file for the Xorg X11 server? (Specify the file name only without any path.)
xorg.conf
The default name of the configuration file for the Xorg X11 server is xorg.conf. This file is used to store initial setup for X, such as settings for video cards, monitors, input devices, and other options. The Xorg X11 server is a display server that uses a configuration file called xorg.conf and files ending in the suffix .conf for its initial setup1. The xorg.conf file is typically located in /etc/X11/xorg.conf, but its location may vary across operating system distributions2. The xorg.conf file is not mandatory, as the Xorg X11 server can automatically configure most hardware and settings. However, it can be created and edited manually if needed3. References:
Xorg - ArchWiki
xorg.conf - Wikipedia
How to Configure X11 in Linux: 10 Steps (with Pictures) - wikiHow
Which of the following commands shows the current color depth of the X Server?
xcd
xcdepth
xwininfo
xcolordepth
cat /etc/X11
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. References:
What output will the command seq 10 produce?
A continuous stream of numbers increasing in increments of 10 until stopped.
The numbers 1 through 10 with one number per line.
The numbers 0 through 9 with one number per line.
The number 10 to standard output.
The seq command in Linux is used to print a sequence of numbers, which can be piped to other commands or used in for loops and bash scripts1. The command can generate a list of integers or real numbers, with options to control the start, end, and increment of the sequence. The general syntax of the command is seq [options] specification1.
If you launch seq with a single number as a command-line parameter, it counts from one to that number. It then prints the numbers in the terminal window, one number per line2. For example, seq 10 will produce the following output:
1
2
3
4
5
6
7
8
9
10
Therefore, the correct answer is B. The numbers 1 through 10 with one number per line.
References: 1: 10+ Seq Commands with Examples in Linux – LinuxWizardry 2: How to Use the seq Command on Linux - How-To Geek
What output will the following command produce?
seq 1 5 20
1
6
1
1
1
6
1
5
10
15
1
2
3
4
2
3
4
5
5
10
15
20
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:
1 5 10 15
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. References:
Seq Command in Linux [Explained With Examples]
seq Man Page - Linux - SS64.com - SS64 Command line reference
What is the difference between the commands test -e path and test -f path?
They are equivalent options with the same behaviour.
The -f option tests for a regular file. The -e option tests for an empty file.
Both options check the existence of the path. The -f option also confirms that it is a regular file.
The -f option tests for a regular file. The -e option tests for an executable file.
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
References:
Which command makes the shell variable named VARIABLE visible to subshells?
export $VARIABLE
export VARIABLE
set $VARIABLE
set VARIABLE
env VARIABLE
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. References:
[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management]
[LPI Linux Administrator - Exam 102 Objectives - Topic 105: Shells and Shell Scripting]
Which command allows you to make a shell variable visible to subshells?
export $VARIABLE
export VARIABLE
set $VARIABLE
set VARIABLE
env VARIABLE
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. References:
[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]
After issuing:
function myfunction { echo $1 $2 ; }
in Bash, which output does:
myfunction A B C
Produce?
A B
A B C
A C
B C
C B A
In Bash, a function is a block of code that can be invoked by its name. A function can take arguments, which are passed to the function as positional parameters. The $1 variable refers to the first argument, $2 to the second argument, and so on. The function can access the number of arguments passed to it by using the $# variable. In this case, the function myfunction simply echoes the first and second arguments to the standard output. Therefore, when the command myfunction A B C is executed, the output is A B, since the third argument C is ignored by the function. References:
[LPI Linux Essentials - Topic 103: Command Line Basics]
[Bash Functions]
Which of the following SQL queries counts the number of occurrences for each value of the field order_type in the table orders?
SELECT order_type,COUNT(*) FROM orders WHERE order_type=order_type;
SELECT order_type,COUNT(*) FROM orders GROUP BY order_type;
COUNT(SELECT order_type FROM orders);
SELECT COUNT(*) FROM orders ORDER BY order_type;
SELECT AUTO_COUNT FROM orders COUNT order_type;
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.
References:
[SQL COUNT Function]
[SQL GROUP BY Statement]
[SQL SELECT Statement]
What word is missing from the following SQL statement?
__________ count(*) from tablename;
(Please specify the missing word using lower-case letters only.)
select
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 data. 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. References: SQL COUNT() Function - W3Schools, SQL COUNT: The Ultimate Guide To SQL COUNT Function - SQL Tutorial, The SQL Count Function Explained With 7 Examples.
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
result: 3 4 5 6 2 1
result: 1 2 3 4 5 6
result: 6 5 4
result: 6 5 4 3 2 1
result: 3 2 1
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. References: Bash while Loop | Linuxize, Bash Scripting - While Loop - GeeksforGeeks
Which of the following words is used to restrict the records that are returned from a SELECT query based on a supplied criteria for the values in the records?
LIMIT
FROM
WHERE
IF
The correct keyword for restricting the records that are returned from a SELECT query based on a supplied criteria for the values in the records is WHERE. The WHERE clause is used to filter records based on one or more conditions. The syntax of the WHERE clause is:
SELECT column1, column2, … FROM table_name WHERE condition;
The condition can be a logical expression that evaluates to true, false, or unknown. The condition can also use comparison operators, logical operators, and wildcards to specify the criteria. For example, the following query selects all the records from the employees table where the salary is greater than 50000:
SELECT * FROM employees WHERE salary > 50000;
The other options are incorrect because they have different purposes in SQL:
LIMIT is used to specify the maximum number of records to return from a query. For example, the following query returns only the first 10 records from the employees table:
SELECT * FROM employees LIMIT 10;
FROM is used to specify the table or tables from which to retrieve data. For example, the following query selects all the columns from the employees table:
SELECT * FROM employees;
IF is used to execute a block of code conditionally. For example, the following query updates the salary of an employee based on their performance:
UPDATE employees SET salary = IF(performance = ‘excellent’, salary * 1.1, salary) WHERE employee_id = 123; References:
Which of the following are requirements in order to run a shell script like a regular command from anywhere in the filesystem? (Choose THREE correct answers.)
The user issuing the command must be in the group script.
The script file must be found in the $PATH.
The script file must have the executable permission bit set.
The script must begin with a shebang-line (#!) that points to the correct interpreter.
The file system on which the script resides must be mounted with the option scripts.
In order to run a shell script like a regular command from anywhere in the filesystem, the following requirements must be met:
The script file must be found in the $PATH. The $PATH is a variable that contains a list of directories where the shell looks for executable files when a command is issued. If the script file is not in one of these directories, the shell will not be able to find it unless the full path is specified.
The script file must have the executable permission bit set. This is a file attribute that determines whether the file can be executed by the user, the group, or others. The executable permission bit can be set using the chmod command, for example: chmod +x script.sh.
The script must begin with a shebang-line (#!) that points to the correct interpreter. This is a special line at the beginning of the script that tells the shell which program to use to run the script, such as #!/bin/bash for bash scripts, or #!/usr/bin/perl for perl scripts. The shebang-line must match the exact path of the interpreter, otherwise the script will not run.
The other options are not requirements for running a shell script like a regular command. There is no such group as script, and the file system mount option scripts does not exist. References:
[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management]
[LPI Linux Professional - Exam 102 Objectives - Topic 105: Shells and Shell Scripting]
What keyword is missing from this code sample of a shell script?
____ i in *.txt; do
echo $i
done
for
loop
until
while
The set command is used to display or modify the shell variables and functions in the current shell. When used without any arguments, it prints the names and values of all shell variables, including environment variables and user-defined variables, in alphabetical order. The output also includes the shell options and the positional parameters. The set command can be used in any POSIX-compliant shell, such as bash, zsh, ksh, etc123.
The other options are not correct because:
env is used to print or modify the environment variables, not the shell variables. It does not show the user-defined variables or the shell options. It can also be used to run a command in a modified environment45.
env -a is an invalid option for the env command. The -a option is not supported by the env command in any standard or common implementation45.
echo $ENV is used to print the value of the environment variable ENV, not the list of all shell variables. The ENV variable is usually set to the name of a file that contains commands or aliases to be executed by the shell. It is mainly used by the ksh and some versions of bash .
References: 1: How can I list all shell variables? - Unix & Linux Stack Exchange 2: 2.1 Command Line Basics - Linux Professional Institute Certification … 3: set - The Open Group Base Specifications Issue 7, 2018 edition 4: How to set and list environment variables on Linux 5: env - The Open Group Base Specifications Issue 7, 2018 edition : What is the difference between .bash_profile and .bashrc? - Unix & Linux Stack Exchange : ENV - The Open Group Base Specifications Issue 7, 2018 edition
Which file, when using Sendmail or a similar MTA system, will allow a user to redirect all their mail to another address and is configurable by the user themselves?
/etc/alias
~/.alias
/etc/mail/forwarders
~/.forward
~/.vacation
The ~/.forward file is a file that users can create in their home directories to redirect mail or send mail using sendmail or a similar MTA system. The file contains a list of recipient addresses, which can be email addresses, file names, program names, or :include: files. The file must be owned by the user and have the read permission bit set for the owner. The file cannot be a symbolic link or have more than one hard link. The file is processed by sendmail when a recipient address selects a delivery agent with the F=w flag set. If the file contains a backslash, further processing is disabled and the message is delivered to the user’s mail-spooling directory. If the file does not exist or cannot be read, it is silently ignored. The ~/.forward file is different from the /etc/aliases file, which is a system-wide file that maps aliases to one or more recipient addresses. The /etc/aliases file is maintained by the system administrator and requires running the newaliases command after any changes. The ~/.alias file is not a valid file for sendmail or similar MTA systems. The /etc/mail/forwarders file is not a standard file for sendmail or similar MTA systems. The ~/.vacation file is a file that contains a vacation message that is sent to the sender when the user is away. The ~/.vacation file is used in conjunction with the vacation program, which can be invoked from the ~/.forward file. References:
Which of the following parameters are used for journalctl to limit the time frame of the output? (Choose TWO correct answers.)
--from=
--since=
--until=
--upto=
--date=
The journalctl command is a tool for viewing and filtering the systemd journal logs. It accepts various parameters to control the output format, the source of the logs, and the filtering criteria. Two of the parameters that are used to limit the time frame of the output are --since= and --until=. These parameters take a date and time value in the format of “YYYY-MM-DD hh:mm:ss” or a relative value such as “-1h” for one hour ago. For example, the command journalctl --since="2023-11-22 23:00:00" --until="2023-11-23 00:00:00" will show the logs from 11:00 PM to 12:00 AM on November 22, 2023. The --since= and --until= parameters are part of the LPI’s multi-level Linux professional certification program, and they are covered in the topic 106.1 System logging of the exam 102 objectives1. References: 1:
What command should be used to print a listing of email in the system's mail queue?
lpq
mailq
mlq
sendmail –l
The mailq command prints the list of messages that are in the mail queue. The mail queue is where outgoing mail is stored until a receiving server connection is available. The mailq command is the same as the sendmail -bp command, which also prints the mail queue. The mailq command is part of the topic 108.3: Mail transfer agent (MTA) basics, which is one of the objectives of the LPI Linux Administrator - 102 exam12. References: 1: 2:
What is pool.ntp.org?
A deprecated feature for maintaining system time in the Linux kernel
A website which provides binary and source packages for the OpenNTPD project
A virtual cluster of various timeservers
A community website used to discuss the localization of Linux
C. pool.ntp.org is indeed a virtual cluster of various timeservers. It provides a reliable and easy-to-use NTP (Network Time Protocol) service for millions of clients worldwide. The pool.ntp.org project allows systems to synchronize their clocks with internet time servers, which are part of a large virtual cluster1.
References:
pool.ntp.org: the internet cluster of ntp servers, which explains the purpose and functioning of the pool.ntp.org project.
How do I setup NTP to use the pool?, which provides instructions on how to use pool.ntp.org for time synchronization.
NTP pool - Wikipedia, which offers additional information about the NTP pool and its role in time synchronization across the internet.
To exclude all log messages of a given logging facility, you should use a logging priority of _____ .
none
To exclude all log messages of a given logging facility, you should use a logging priority of none. This means that no messages from that facility will be logged, regardless of their severity level. For example, if you want to exclude all messages from the local0 facility, you can use local0.none in your syslog configuration file. This will prevent any messages from local0 from being written to any log file or destination that matches that selector12. The logging priority of none is part of the LPI’s multi-level Linux professional certification program, and it is covered in the topic 106.1 System logging of the exam 102 objectives3. References: 1: logging - exclude syslog facility from all others - Server Fault 2: rsyslog.conf(5) - Linux manual page - man7.org 3: Exam 102 Objectives
What is true about the ntpdate command?
It is the primary management command for the NTP time server.
It updates the local system's date (i.e. day, month and year) but not the time (i.e. hours, minutes, seconds).
It queries one or more NTP time servers and adjusts the system time accordingly.
It sends the local system time to one or many remote NTP time servers for redistribution.
It can be used by any user to set the user clock independently of the system clock.
The ntpdate command is a tool used to synchronize the system date and time with the NTP (Network Time Protocol) server(s) specified as arguments. It can be run manually as necessary to set the system clock, or it can be run from a cron script to periodically update the system clock. The ntpdate command has the following syntax:
ntpdate [options] server [server ...]
The ntpdate command obtains a number of samples from each server and applies a subset of the NTP clock filter and selection algorithms to select the best one. It then adjusts the system clock either by stepping it (if the offset is larger than 0.5 seconds) or by slewing it (if the offset is smaller than 0.5 seconds). The ntpdate command can also be used to query the date and time from a server without setting the system clock by using the -q option.
The other statements are false because:
It is not the primary management command for the NTP time server. The primary management command for the NTP time server is ntpd, which is a daemon that runs continuously and disciplines the system clock using sophisticated algorithms.
It updates both the local system’s date and time, not just the date. The ntpdate command sets the system date and time according to the configured timezone information.
It does not send the local system time to any remote NTP time servers. The ntpdate command only queries the time from the servers and does not transmit any time information to them.
It cannot be used by any user to set the user clock independently of the system clock. The ntpdate command must be run as root on the local host and it affects the system clock for all users.
References:
Linux ntpdate Command Tutorial – LinuxTect
ntpdate - set the date and time via NTP
How to Use NTPDATE to Sync Time in Ubuntu Linux? – TheITBros
Why is the correct configuration of a system's time zone important?
Because the conversion of Unix timestamps to local time relies on the time zone configuration.
Because the time zone is saved as part of the modification times of files and cannot be changed after a file is created.
Because the environment variables LANG and LC_MESSAGES are, by default, set according to the time zone.
Because NTP chooses servers nearby based on the configured time zone.
The correct configuration of a system’s time zone is important because it affects how the system displays and interprets the local time from the Unix timestamps. A Unix timestamp is a number that represents the number of seconds that have elapsed since January 1, 1970 (UTC)1. Unix timestamps are independent of time zones and are the same for all systems1. However, when a system needs to display or interpret the local time from a Unix timestamp, it needs to know the offset from UTC, which is determined by the time zone configuration23. If the time zone configuration is incorrect, the system may display or interpret the local time incorrectly, which can cause problems with scheduling tasks, logs, and other applications45.
For example, suppose a system has a Unix timestamp of 1638374400, which corresponds to December 1, 2021, 12:00:00 UTC6. If the system’s time zone is configured correctly as UTC, it will display the local time as December 1, 2021, 12:00:00. However, if the system’s time zone is configured incorrectly as EST (Eastern Standard Time), which is 5 hours behind UTC, it will display the local time as December 1, 2021, 07:00:00, which is 5 hours earlier than the actual local time6. This can lead to confusion and errors for the system and the user.
Therefore, the correct answer is A. Because the conversion of Unix timestamps to local time relies on the time zone configuration.
References: 1: Unix time - Wikipedia 2: How to Set or Change the Time Zone in Linux – TecAdmin 3: Set the date, time, and timezone on a Linux server 4: Configure the time zone (TZ) on Linux systems - Linux Audit 5: Setting the timezone under Linux - Learn Linux Configuration 6: Epoch Converter - Unix Timestamp Converter
On a dual boot system, every time the system is booted back into Linux the time has been set backward by one day. Which of the following commands will correct the problem?
date -d '+ 1 day'
hwclock --systohc --localtime
ntpdate pool.ntp.org
time hwclock
The command that will correct the problem of the time being set backward by one day on a dual boot system is hwclock --systohc --localtime. This command will set the hardware clock (RTC) to the current system time and use the local time standard instead of UTC12. This will prevent the time inconsistency issue that occurs when dual booting Linux and Windows, as Windows assumes that the hardware clock is using local time while Linux assumes that it is using UTC34. By using the same time standard for both operating systems, the time will be displayed correctly on both Linux and Windows.
The other commands are either invalid or ineffective for solving the problem. The date -d '+ 1 day' command will display the date and time one day ahead of the current system time, but it will not change the system time or the hardware clock5. The ntpdate pool.ntp.org command will synchronize the system time with an NTP server, but it will not affect the hardware clock or the time standard6. The time hwclock command will measure the time taken by the hwclock command, which will display the hardware clock time, but it will not change anything7.
References: 1: hwclock(8) - Linux man page 2: How to Fix Windows and Linux Showing Different Times When Dual Booting 3: Dual-Booting Linux Messed Up Windows Time? Here’s How to Fix It 4: Wrong Time in Windows 10 After Dual Boot With Linux 5: date(1) - Linux man page 6: ntpdate(8) - Linux man page 7: time(1) - Linux man page
Which command is used to sync the hardware clock to the system clock? (Specify ONLY the command without any path or parameters.)
hwclock, /sbin/hwclock, /usr/sbin/hwclock
The command that is used to sync the hardware clock to the system clock is:
hwclock --systohc
This command copies the current system time to the hardware clock, which runs even when the system is shut down. It is equivalent to the command hwclock -w12. The hardware clock is also called the BIOS clock or the RTC (Real Time Clock)3.
Which of the following are commonly used Mail Transfer Agent (MTA) applications? (Choose THREE correct answers.)
Postfix
Procmail
Sendmail
Exim
SMTPd
Postfix, Sendmail, and Exim are three of the most commonly used Mail Transfer Agent (MTA) applications on Linux systems. An MTA is a software that transfers and routes electronic mail messages from one computer to another using the Simple Mail Transfer Protocol (SMTP). An MTA receives messages from another MTA or from a Mail User Agent (MUA), which is a computer application that end users use to access or send emails. An MTA can also query the MX records of the recipient’s domain to find the destination mail server and forward the message accordingly. An MTA can also perform other functions such as filtering, encryption, authentication, and bounce handling.
Postfix is a cross-platform, popular MTA that was designed and developed by Wietse Zweitze Venema for his mail server while working at the IBM research department. It was primarily developed as an alternative to well-known and popular Sendmail MTA. Postfix runs on Linux, Mac OSX, Solaris, and several other Unix-like operating systems. It borrows a lot of Sendmail properties on the outside, but it has a totally and comprehensively distinct internal operation. Additionally, it bids to be fast in performance with easy configurations and secure operation mechanism1.
Sendmail, now known as Proofpoint (after Proofpoint, Inc acquired Sendmail, Inc), is by far the most popular and one of the oldest MTA on the Linux server platform. Sendmail has a lot of limitations though, in comparison to modern MTAs. Because of its complicated configuration steps and demands, and weak security mechanisms, many new MTAs have come up as alternatives to Sendmail, but importantly, it offers everything to do with mail on a network1.
Exim is a free MTA developed for Unix-like operating systems such as Linux, Mac OSX, Solaris, and many more. Exim offers a great level of flexibility in routing mail on a network, with outstanding mechanisms and facilities for incoming mail monitoring. Its notable features include among others: no support for POP and IMAP protocols, supports protocols such as RFC 2821 SMTP and RFC 2033 LMTP email message transport, configurations include access control lists, content scanning, encryption, routing controls among others1.
Procmail is not an MTA, but a mail processing utility that can be used to filter, sort, and deliver incoming mail. It can be invoked by an MTA or run as a standalone program. Procmail can process mail based on various criteria such as sender, subject, header, body, size, date, and more. It can also execute external programs, forward mail to another address, or write mail to a file.
SMTPd is not an MTA, but a generic name for a daemon (a background process) that implements the SMTP protocol. A daemon is a program that runs continuously and performs certain tasks at predefined times or in response to certain events. An SMTP daemon listens for incoming SMTP connections from other MTAs or MUAs and handles the mail transfer accordingly. SMTPd can also refer to a specific SMTP daemon that is part of the OpenSMTPD project, which is a free implementation of the SMTP protocol for Unix systems. References:
7 Best Mail Transfer Agents (MTA’s) for Linux
Mail Transfer Agent (MTA) Explained | Mailtrap Blog
What is a Message Transfer Agent (MTA)? - Definition from Techopedia
Mail Transfer Agent (MTA) – Glossary of Email Terms | Mailgun
[Procmail - Wikipedia]
[SMTP daemon - Wikipedia]
Please specify the top directory containing the configuration files for the CUPS printing system. (Specify the full path to the directory.)
/etc/cups, /etc/cups/
The top directory containing the configuration files for the CUPS printing system is /etc/cups. This directory stores various files that control the behavior and functionality of the CUPS scheduler, cupsd (8), such as cups-files.conf (5), cupsd.conf (5), mime.convs (5), mime.types (5), printers.conf (5), and subscriptions.conf (5). The /etc/cups directory also contains subdirectories for classes, interfaces, ppd, and ssl, which store information about printer classes, device interfaces, printer drivers, and encryption certificates, respectively12. The /etc/cups directory is part of the LPI’s multi-level Linux professional certification program, and it is covered in the topic 105.5 Print service of the exam 102 objectives3. References: 1: cups-files (5) - Linux Manuals 2: cupsd.conf - server configuration file for cups 3: Exam 102 Objectives
Which file inside the CUPS configuration directory contains the definition of the printers?
cups-devices.conf
snmp.conf
printcap.conf
printers.conf
cupsd.conf
The printers.conf file inside the CUPS configuration directory contains the definition of the printers. It is a text file that lists the names, locations, descriptions, and options for each printer queue. Each printer queue has a corresponding
cups-files.conf - file and directory configuration file for cups
[printers.conf - printer configuration file for cups]
Which TWO statements about crontab are true?
Every user may have their own crontab.
Changing a crontab requires a reload/restart of the cron daemon.
The cron daemon reloads crontab files automatically when necessary.
hourly is the same as "0 * * * *".
A cron daemon must run for each existing crontab.
A. It is true that every user may have their own crontab. This allows individual users to schedule tasks to be run at specific times without requiring administrative privileges1. C. The cron daemon does indeed reload crontab files automatically when necessary. This means that after editing a crontab file, there is no need to manually restart the cron service for the changes to take effect1.
References:
107.2 Lesson 1 - Linux Professional Institute Certification Programs, which covers the automation of system administration tasks by scheduling jobs with cron.
The LPIC2 Exam Prep, which provides additional information on the LPIC-2 objectives and topics related to crontab and cron daemon.
The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m.:
* 3,4,5 1 * * chklog
3 3,4,5 1 * * chklog
3 15,16,17 * * * chklog
0 15,16,17 1 * * chklog
* 15,16,17 1 * * chklog
The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m. is:
3 15,16,17 * * * chklog
The crontab entry has five fields that specify the time and frequency of the job, followed by the command or script to be executed. The fields are:
Minute: the minute of the hour when the job should run, from 0 to 59
Hour: the hour of the day when the job should run, from 0 to 23 (in 24-hour format)
Day of month: the day of the month when the job should run, from 1 to 31
Month: the month of the year when the job should run, from 1 to 12
Day of week: the day of the week when the job should run, from 0 to 6 (where 0 and 7 are Sunday)
The asterisk (*) means any value, and the comma (,) means a list of values. Therefore, the crontab entry above means:
Run the job at the 3rd minute of the hour
Run the job at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.)
Run the job on any day of the month
Run the job on any month of the year
Run the job on any day of the week
This will execute the script chklog three times per day, every day of the month, and every month of the year, which is equivalent to three times per month.
The other options are incorrect because:
A. This will run the job at any minute of the hour, but only at the 3rd, 4th, and 5th hour of the day (which are 3 a.m., 4 a.m., and 5 a.m.), and only on the 1st day of the month.
B. This will run the job at the 3rd minute of the hour, but only at the 3rd, 4th, and 5th hour of the day (which are 3 a.m., 4 a.m., and 5 a.m.), and only on the 1st day of the month.
D. This will run the job at the 0th minute of the hour (which is the top of the hour), but only at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.), and only on the 1st day of the month.
E. This will run the job at any minute of the hour, but only at the 15th, 16th, and 17th hour of the day (which are 3 p.m., 4 p.m., and 5 p.m.), and only on the 1st day of the month.
References:
Crontab Explained in Linux [With Examples]
‘crontab’ in Linux with Examples - GeeksforGeeks
Linux Crontab Command Help and Examples - Computer Hope
Crontab in Linux with 20 Useful Examples to Schedule Jobs - TecAdmin
Linux crontab tutorial with Examples - Linux Tutorials - Learn Linux …
What is the conventional purpose of Linux UIDs that are lower than 100?
They are reserved for super user accounts.
They are reserved for the system admin accounts.
They are reserved for system accounts.
They are unused, aside from 0, because they are targets of exploits.
They are used to match with GIDs in grouping users.
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. References: 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
Which file specifies the user accounts that can NOT submit jobs via at or batch? (Provide the full path and filename)
/etc/at.deny
The /etc/at.deny file specifies the user accounts that can NOT submit jobs via at or batch. The format of the file is a list of usernames, one on each line. Whitespace is not permitted. The superuser may always use at. If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at. If /etc/at.allow does not exist, /etc/at.deny is checked12. The at and batch commands use the files /usr/lib/cron/at.allow and /usr/lib/cron/at.deny to restrict usage on some systems3. References:
at.allow(5) - Linux man page
at.deny(5) [linux man page] - The UNIX and Linux Forums
The at.allow and at.deny files - IBM
Each entry in a crontab must end with what character?
Tab
Space
Backslash
Newline
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. References:
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?
Add the specific user to /etc/at.allow file.
Add the specific user to [deny] section in the /etc/atd.conf file.
Add the specific user to /etc/at.deny file.
Add the specific user to nojobs group.
Run the following: atd --deny [user].
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. References:
at Command in Linux with Examples - GeeksforGeeks
How to Use the Linux at Command {9 Examples} - phoenixNAP
at(1) - Linux man page
How is the file format of /etc/crontab different from a normal crontab file? (Select TWO correct answers)
The /etc/crontab file can specify a year field.
A normal crontab file must be installed with the crontab command.
A normal crontab file allows for environment variable substitution.
The /etc/crontab file has a user field for commands.
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.
References:
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
Of the ways listed, which is the best method to temporarily suspend a user's ability to interactively login?
Use passwd -d username to give the user an empty password.
Use chage to expire the user account.
Change the user's password.
Add the command exit to the user's .login file.
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. References:
Of the ways listed, which is the best way to temporarily suspend a single user's ability to interactively login?
Add the user name to /etc/nologin.
Change the user's password.
Change the user name in /etc/passwd.
Use change to expire the user account.
Place the command logout in the user's profile.
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:
# chage -l linuxconfig
Last password change : Aug 24, 2021
Password expires : never
Password inactive : never
Account expires : Jan 01, 1970
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
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. References: 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 command will set the local machine's timezone to UTC?
cat UTC > /etc/timezone
ln -s /usr/share/zoneinfo/UTC /etc/localtime
date --timezone=UTC
mv /usr/timezone/UTC /etc
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. References: 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
Copyright © 2014-2024 Examstrust. All Rights Reserved