Which of the following commands sorts the output of the commandexport-logs?
export-logs < sort
export-logs > sort
export-logs & sort
export-logs | sort
export-logs <> sort
The sort command is used to sort the lines of a text file or the output of another command in alphabetical, numerical, or other order. The sort command has the following syntax: sort [options] [file…]. The file argument is the name of one or more files to be sorted. If no file is given, the sort command reads from the standard input, which is usually the keyboard or the output of another command.
The | (pipe) symbol is used to connect the output of one command to the input of another command. This allows the creation of pipelines of commands that process data sequentially. The pipe symbol has the following syntax: command1 | command2. The command1 argument is the name of the first command, whose output is sent to the input of the second command. The command2 argument is the name of the second command, which receives the output of the first command as its input.
Therefore, the command export-logs | sort sorts the output of the export-logs command in alphabetical order. The export-logs command is assumed to be a custom command that exports some logs to the standard output. The sort command receives the output of the export-logs command as its input and sorts it according to the default criteria, which is the first character of each line. The sorted output is then displayed on the screen or can be redirected to a file or another command.
The other options in the question are incorrect because they use the wrong symbols to connect the commands. The < (input redirection) symbol is used to read the input of a command from a file instead of the keyboard. The > (output redirection) symbol is used to write the output of a command to a file instead of the screen. The & (background) symbol is used to run a command in the background, which means the command does not wait for user input and allows the user to run other commands simultaneously. The <> (bidirectional redirection) symbol is used to read and write the input and output of a command from and to the same file. None of these symbols can be used to sort the output of the export-logs command. References:
The ownership of the file doku.odt should be changed. The new owner is named tux. Which command accomplishes this change?
chmod u=tux doku.odt
newuser doku.odt tux
chown tux doku.odt
transfer tux: doku.odt
passwd doku.odt:tux
The correct command to change the ownership of the file doku.odt to a new owner named tux is chown tux doku.odt. This command uses the chown command, which stands for change owner, followed by the name of the new owner and the name of the file as arguments. The chown command allows you to change the user and/or group ownership of a given file, directory, or symbolic link12. The other options are incorrect because they use different commands or syntax that do not change the ownership of the file. For example:
References: 1: Chown Command in Linux (File Ownership) | Linuxize 2: chown command in Linux with Examples - GeeksforGeeks 3: Chmod Command in Linux (File Permissions) | Linuxize 4: newusers(8) - Linux man page 5: passwd(1) - Linux man page
What information is stored in/etc/passwd? (Choose three correct answers.)
The user’s storage space limit
The numerical user ID
The username
The encrypted password
The user\s default shell
The /etc/passwd file is a plain text-based database that contains information for all user accounts on the system. It is owned by root and has 644 permissions. The file can only be modified by root or users with sudo privileges and readable by all system users. Each line of the /etc/passwd file contains seven comma-separated fields, representing a user account. The fields are as follows:
Therefore, the correct answers are B, C, and E. The user’s storage space limit (A) is not stored in the /etc/passwd file, but in the /etc/quota file. The encrypted password (D) is not stored in the /etc/passwd file, but in the /etc/shadow file. References:
Most commands on Linux can display information on their usage. How can this information typically be displayed?
By running the command with the option /? or /??.
By running the command with the option ?! or ?=!.
By running the command with the option /doc or /documentation.
By running the command with the option -h or --help.
By running the command with the option -m or --manpage.
Most commands on Linux can display information on their usage by running the command with the option -h or --help. This option shows a brief summary of the command syntax, options, arguments, and examples. For example, running ls -h or ls --help will display the usage information for the ls command, which lists files and directories. The -h or --help option is a standard convention for most Linux commands, and it is useful for learning how to use a command or checking its available options. However, some commands may not support this option, or may use a different option to display usage information. In that case, you can use the man command to access the manual page for the command, which provides more detailed information on the command usage, description, options, arguments, examples, and references. For example, running man ls will display the manual page for the ls command. The man command is one of the applications covered in the Linux Essentials certification program from the Linux Professional Institute (LPI). References:
Which of the following commands shows the absolute path to the current working directory?
who
cd ..
pwd
ls -l
cd ~/home
The command pwd stands for “print working directory”. It will print the absolute path of the current working directory to the terminal. For example, if we are currently in the /home/user/directory, it will print out that exact path1. The pwd command is useful for finding out where we are in the file system hierarchy and for verifying the location of files and directories2.
The other options are not commands that show the absolute path to the current working directory. The who command shows the users who are currently logged in to the system3. The cd … command changes the current working directory to the parent directory of the current one2. The ls -l command lists the files and directories in the current working directory in a long format, which shows the permissions, ownership, size, date, and name of each file and directory2. The cd ~/home command changes the current working directory to the /home directory under the user’s home directory, which may or may not exist2. References:
What is true about thedmesgcommand? (Choose two correct answers.)
It traces the execution of a command and shows each step the program carries out.
It sends messages to the command lines of all current user sessions.
It displays the content of the Linux kernel’s ring buffer.
It immediately outputs all new messages written to the system journal.
It might not display older information because it was overwritten by newer information.
The dmesg command is used to display the messages from the kernel that are stored in a ring buffer. A ring buffer is a fixed-size data structure that overwrites the oldest entries when it is full. Therefore, the dmesg command might not display older information because it was overwritten by newer information. The dmesg command is useful for troubleshooting system issues and checking hardware information. The dmesg command is not used to trace the execution of a command, send messages to user sessions, or output the system journal. Those functions are performed by other commands such as strace, write, and journalctl respectively. References: : [dmesg] : [Ring buffer] : [strace] : [write (Unix)] : [journalctl]4)
Which of the following programs are web servers? (Choose two.)
Apache HTTPD
Postfix
Curl
Dovecot
NGINX
A web server is a program that listens for requests from web browsers and serves web pages, images, or other resources. Apache HTTPD and NGINX are two popular web servers that can run on Linux systems. They can handle multiple protocols, such as HTTP, HTTPS, FTP, and SMTP. Postfix, Curl, and Dovecot are not web servers, but they are related to web or network services. Postfix is a mail transfer agent (MTA) that can send and receive emails. Curl is a command-line tool that can transfer data from or to a web server. Dovecot is a mail delivery agent (MDA) that can store and retrieve emails from a local mailbox. References:
What is defined by a Free Software license?
Details of the technical documentation each contributor has to provide.
The programming languages which may be used to extend the licensed program.
A complete list of libraries required to compile the licensed software.
Limits on the purposes for which the licensed software may be used.
Conditions for modifying and distributing the licensed software.
A free software license is a notice that grants the recipient of a piece of software extensive rights to modify and redistribute that software. These actions are usually prohibited by copyright law, but the rights-holder (usually the author) of a piece of software can remove these restrictions by accompanying the software with a software license which grants the recipient these rights. Software using such a license is free software (or free and open-source software) as conferred by the copyright holder. Free software licenses grant users the freedom to use it for any purpose, study and change the source code and copy and redistribute the software with or without modifications. Free software must come with source code or provide access to it, while the freedom to redistribute includes the right to give away copies gratis as well as sell copies1 References: 1: Free-software license - Wikipedia
Members of a team already have experience using Red Hat Enterprise Linux. For a small hobby project, the team wants to set up a Linux server without paying for a subscription. Which of the following Linux distributions allows the team members to apply as much of their Red Hat Enterprise Linux knowledge as possible?
Ubuntu Linux LTS
Raspbian
Debian GNU/Linux
CentOS
openSUSE
CentOS is a Linux distribution that is based on the source code of Red Hat Enterprise Linux (RHEL). It is a free and open-source community-supported OS that provides an enterprise-level computing platform. CentOS is fully compatible with RHEL and can run the same applications and packages. Therefore, CentOS allows the team members to apply as much of their Red Hat Enterprise Linux knowledge as possible for their hobby project. References:
Which of the following commands extracts the contents of the compressed archive file1.tar.gz?
tar -czf file1.tar.gz
ztar file1.tar.gz
tar -xzf file1.tar.gz
tar --extract file1.tar.gz
detar file1.tar.gz
The correct command to extract the contents of the compressed archive file1.tar.gz is tar -xzf file1.tar.gz. This command uses the following options:
The other commands are incorrect for the following reasons:
References:
Which files are the source of the information in the following output? (Choose two.)
uid=1000 (bob) gid=1000 (bob) groups=1000 (bob), 10 (wheel), 150
(docker), 1001 (libvirt)(wireshark),989
/etc/id
/etc/passwd
/etc/group
/home/index
/var/db/users
The files /etc/passwd and /etc/group are the source of the information in the following output:
uid=1000 (bob) gid=1000 (bob) groups=1000 (bob), 10 (wheel), 150 (docker), 1001 (libvirt) (wireshark), 989
The /etc/passwd file contains information about user accounts, such as the username, password, user ID (UID), group ID (GID), full name, home directory, and login shell1. The /etc/group file contains information about groups, such as the group name, password, group ID (GID), and members2.
The output shows the UID, GID, and group membership of the user bob. The UID and GID of bob are 1000, which can be found in the /etc/passwd file. The groups that bob belongs to are bob, wheel, docker, libvirt, wireshark, and 989, which can be found in the /etc/group file. The group names are shown in parentheses after the GID, except for the last group, which has no name.
The other options are not files that store user and group information in Linux. The /etc/id file does not exist by default. The /home/index file is not a standard file and has no relation to user and group information. The /var/db/users file is not a standard file and has no relation to user and group information. References:
Which of the followingtaroptions handle compression? (Choose two correct answers.)
-bz
-z
-g
-j
-z2
The tar command is used to create or extract compressed archive files that contain multiple files or directories. The tar command has the following syntax: tar [options] [archive-file] [file or directory…]. The options argument specifies how the tar command should operate and what kind of compression should be used. The archive-file argument is the name of the archive file to be created or extracted. The file or directory argument is the name of one or more files or directories to be included in or extracted from the archive file.
The following are some of the common options for the tar command:
The options -z and -j are used to handle compression with the tar command. The option -z uses the gzip program to compress or decompress the archive file, which usually has the extension .tar.gz or .tgz. The option -j uses the bzip2 program to compress or decompress the archive file, which usually has the extension .tar.bz2 or .tbz. Both gzip and bzip2 are popular compression programs that reduce the size of files by removing redundant or unnecessary information.
For example, to create a compressed archive file called backup.tar.gz that contains the files and directories in the current directory, the following command can be used:
tar -czvf backup.tar.gz .
To extract the files and directories from the archive file backup.tar.gz to the current directory, the following command can be used:
tar -xzvf backup.tar.gz
To create a compressed archive file called backup.tar.bz2 that contains the files and directories in the current directory, the following command can be used:
tar -cjvf backup.tar.bz2 .
To extract the files and directories from the archive file backup.tar.bz2 to the current directory, the following command can be used:
tar -xjvf backup.tar.bz2
The other options in the question are not related to compression. The option -bz is invalid, as there is no such option for the tar command. The option -g is used to create or update an incremental archive file, which only contains the files that have changed since the last backup. The option -z2 is also invalid, as there is no such option for the tar command. References:
The current directory contains the following file:
-rw-r—r— 1 root exec 24551 Apr 2 12:36 test.sh
The file contains a valid shell script, but executing this file using./test.shleads to this error:
bash: ./test.sh: Permission denied
What should be done in order to successfully execute the script?
The file’s extension should be changed from .shto.bin.
The execute bit should be set in the file’s permissions.
The user executing the script should be added to theexecgroup.
The SetUID bit should be set in the file’s permissions
The script should be run using#!./test. shinstead of./test.sh.
The execute bit in Linux is a permission bit that allows the user to run an executable file or enter a directory. For regular files, such as scripts or binaries, the execute bit must be set for the user to run them. For directories, the execute bit allows the user to access the files and subdirectories inside. Therefore, to successfully execute the script test.sh, the execute bit should be set in the file’s permissions. This can be done by using the chmod command with the +x option, for example: chmod +x test.sh. The other options are either irrelevant or incorrect. The file’s extension does not affect its executability, only its association with a program. The user executing the script does not need to be in the exec group, as long as the user has the execute permission on the file. The SetUID bit is a special permission bit that allows the user to run the file as the file’s owner, regardless of the user’s identity. This is not necessary for executing the script, and may pose a security risk. The #!./test.sh syntax is invalid, as the #! is used to specify the interpreter for the script, not the script itself. References:
Which command displays file names only and no additional information?
ls -a
ls -lh
ls -l
ls -alh
ls -nl
The ls command is used to list the files and directories in a given path. By default, the ls command displays only the file names, without any additional information. However, the ls command can also take various options to modify its output. For example, the -l option tells ls to display the long format, which includes the file permissions, owner, group, size, date, and name. The -h option tells ls to display the file sizes in a human-readable format, such as KB, MB, GB, etc. The -a option tells ls to display all files, including thehidden ones that start with a dot (.). The -n option tells ls to display the numeric user ID and group ID instead of the user name and group name. Therefore, the only option that does not add any additional information to the file names is the -a option. The command ls -a will display all the file names in the current directory, including the hidden ones, but nothing else. References:
Which permissions are set on a regular file once the permissions have been modified with the command
chmod 654 file.txt?
drw-r-xr--
d—wxr-x--
–wxr-x--x
–rwxrw---x
-rw-r-xr--
The chmod command is used to change the permissions of files and directories. The permissions are represented by three sets of three characters, indicating the permissions for the owner, the group, and the others. Each character can be either r (read), w (write), x (execute), or - (no permission). The chmod command can use either symbolic or numeric mode to specify the permissions. In this question, the numeric mode is used, which consists of three digits from 0 to 7. Each digit is the sum of the permissions for each set, where r is 4, w is 2, and x is 1. For example, 7 means rwx, 6 means rw-, and 4 means r–. Therefore, the command chmod 654 file.txt sets the permissions as follows:
The resulting permissions are -rw-r-xr–, which is the correct answer. The other options are incorrect because they either have the wrong permissions or the wrong file type. A regular file does not have the d (directory) prefix, and a directory cannot have the - (no file type) prefix. References:
Which of the following is a protocol used for automatic IP address configuration?
NFS
LDAP
SMTP
DNS
DHCP
DHCP stands for Dynamic Host Configuration Protocol. It is a protocol that provides quick, automatic, and central management for the distribution of IP addresses within a network. It also configures other network information, such as the subnet mask, default gateway, and DNS server information, on the device1. DHCP uses a client/server architecture, where a DHCP server issues unique IP addresses and automatically configures the devices that request them2. DHCP allows devices to move freely from one network to another and receive an IP address automatically, which is helpful with mobile devices1.
The other options are not protocols used for automatic IP address configuration. NFS stands for Network File System, which is a protocol that allows a user to access and modify files over a network as if they were on their own computer. LDAP stands for Lightweight Directory Access Protocol, which is a protocol that provides access to a centralized directory service that stores information about users, groups, computers, and other resources on a network. SMTP stands for Simple Mail Transfer Protocol, which is a protocol that enables the sending and receiving of email messages over a network. DNS stands for Domain Name System, which is a protocol that translates domain names into IP addresses and vice versa. References:
What parameter of ls prints a recursive listing of a directory's content? (Specify ONLY the option name without any values or parameters.)
ls -R
The -R parameter of the ls command prints a recursive listing of a directory’s content, meaning that it will list not only the files and directories in the current directory, but also the files and directories in all the subdirectories12. For example, if you have a directory structure like this:
/home/user/├──dir1│├──file1│└──file2└──dir2├──file3└──file4
You can use the command ls -R /home/user/ to list all the files and directories recursively, and the output will look like this:
/home/user/: dir1 dir2
/home/user/dir1: file1 file2
/home/user/dir2: file3 file4
The -R parameter is also known as the --recursive option, which is the long form of the same parameter12. You can use either -R or --recursive to achieve the same result.
References:
What is a Linux distribution?
The Linux file system as seen from the root account after mounting all file systems.
A bundling of the Linux kernel, system utilities and other software.
The set of rules which governs the distribution of Linux kernel source code.
An operating system based on Linux but incompatible to the regular Linux kernel.
A set of changes to Linux which enable Linux to run on another processor architecture.
A Linux distribution is a collection of software that is based on the Linux kernel and can be installed on a computer or a device to create a functional operating system. A Linux distribution typically includes the Linux kernel, a set of system utilities and libraries, a graphical user interface (GUI), a package manager, and various applications and services. A Linux distribution may also include additional software or features that are specific to the distribution’s goals, target audience, or philosophy. For example, some Linux distributions are designed for desktop users, while others are optimized for servers, embedded systems, or security. Some Linux distributions are based on other Linux distributions, while others are developed independently. Some Linux distributions are free and open source, while others are proprietary or commercial. Some Linux distributions are popular and widely used, while others are niche or experimental. Some examples of Linux distributions are Ubuntu, Fedora, Debian, Mint, Arch, and Red Hat. References:
Which of the following DNS record types hold an IP address? (Choose two.)
NS
AAAA
MX
A
CNAME
The DNS record types that hold an IP address are the A and AAAA records. These records are used to map a domain name to an IP address of the host, which is necessary for establishing a connection between a client and a server. The A record holds a 32-bit IPv4 address, while the AAAA record holds a 128-bit IPv6 address. For example, the A record for www.example.com could be:
www.example.com. IN A 192.0.2.1
This means that the domain name www.example.com resolves to the IPv4 address 192.0.2.1. Similarly, the AAAA record for www.example.com could be:
www.example.com. IN AAAA 2001:db8::1
This means that the domain name www.example.com resolves to the IPv6 address 2001:db8::1.
The other options are incorrect because:
example.com. IN NS ns1.example.com.
This means that the name server ns1.example.com is authoritative for the domain example.com.
example.com. IN MX 10 mail.example.com.
This means that the mail server mail.example.com has a preference value of 10 for receiving email for the domain example.com.
www.example.com. IN CNAME example.com.
This means that the domain name www.example.com is an alias for the domain name example.com.
References:
Which of the following commands creates an archive filework.tarfrom the contents of the directory./
work/?
tar --new work.tar ./work/
tar –cf work.tar ./work/
tar –create work.tgz –content ./work/
tar work.tar < ./work/
tar work > work.tar
The correct command to create an archive file work.tar from the contents of the directory ./work/ is tar –cf work.tar ./work/. This command uses the -c option to create a new archive, the -f option to specify the file name, and the ./work/ argument to indicate the source directory. The other commands are incorrect for various reasons:
A directory contains the following files:
What would be the output of the following shell script?
for file in *.txt
*.txt
a b
c.cav
A.txt
A. txt
txt
The shell script uses a for loop to iterate over the files that match the pattern *.txt in the current directory. The pattern *.txt means any file name that ends with .txt, regardless of the case. The loop body simply prints the value of the variable file, which holds the name of the current file in each iteration. Therefore, the output of the shell script would be the names of the files that end with .txt, one per line. In this case, the files are A.txt and b.txt, so the output would be:
A.txt b.txt
This corresponds to option E. The other options are incorrect for the following reasons:
References: 1: 9 Examples of for Loops in Linux Bash Scripts - How-To Geek 2 3: Looping Statements | Shell Script - GeeksforGeeks 1 4: shell - Loop through all the files with .txt extension in bash - Stack Overflow 5