Which of the following outputs could stem from the commandlast?
1 ls
2 cat text.txt
3 logout
Password for user last changed at Sat Mar 31 16:38:57 EST 2018
Last login: Fri Mar 23 10:56:39 2018 from server.example.com
EXT4-fs (dm-7): mounted filesystem with ordered data mode. Opts: (null)
root tty2 Wed May 17 21:11 - 21:11 (00:00)
The last command in Linux is used to display the list of all the users logged in and out since the file /var/log/wtmp was created1. The output of the last command shows the username, the terminal, the IP address, the login time and date, and the duration of the session for each record2. The option E is the only one that matches this format. Theother options are not related to the last command. Option A shows a list of commands executed by a user. Option B shows the password change information for a user. Option C shows the last login information for a user. Option D shows the mount information for a filesystem. References:
Which package management tool is used in Red Hat-based Linux Systems?
portage
rpm
apt-get
dpkg
packagectl
RPM stands for RPM Package Manager (formerly known as Red Hat Package Manager), which is a powerful, command-line package management tool developed for the Red Hat operating system. It is now used as a core component in many Linux distributions such as CentOS, Fedora, Oracle Linux, openSUSE and Mageia1. RPM can install, uninstall,and query individual software packages, but it cannot manage dependency resolution like YUM2. YUM is another package management tool that is based on RPM and can handle dependencies automatically. YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux2. Therefore, the correct answer is B. rpm, as it is the underlying package management tool used in Red Hat-based Linux systems. References:
A new server needs to be installed to host services for a period of several years. Throughout this time, the server should receive important security updates from its Linux distribution.
Which of the following Linux distributions meet these requirements? (Choose two.)
Ubuntu Linux LTS
Fedora Linux
Debian GNU/Linux Unstable
Ubuntu Linux non-LTS
Red Hat Enterprise Linux
Ubuntu Linux LTS and Red Hat Enterprise Linux are two Linux distributions that meet the requirements of hosting services for a period of several years and receiving important security updates from their Linux distribution. LTS stands for Long Term Support, which means that these versions of Ubuntu Linux are supported by Canonical, the company behind Ubuntu, for five years with security patches, bug fixes, and software updates1. Red Hat Enterprise Linux is a commercial Linux distribution that offers a stable and secure platform for enterprise applications, with a 10-year life cycle and regular security updates from Red Hat, the company behind RHEL2. Fedora Linux, Debian GNU/Linux Unstable, and Ubuntu Linux non-LTS are not suitable for the requirements, because they have shorter support cycles and are more focused on providing the latest features and software versions, rather than stability and security. Fedora Linux releases a new version every six months and each version is supported for 13 months3. Debian GNU/Linux Unstable is the development branch of Debian, which is constantly updated with new packages and changes, but is not intended for production use4. Ubuntu Linux non-LTS releases a new version every six months and each version is supported for nine months1. 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 of the following outputs comes from the commandfree?

Option A
Option B
Option C
Option D
Option E
The file script.sh in the current directory contains the following content:
#!/bin/bash echo $MYVAR
The following commands are used to execute this script:
MYVAR=value
./script.sh
The result is an empty line instead of the content of the variable MYVAR. How should MYVAR be set in order to make script.sh display the content of MYVAR?
!MYVAR=value
env MYVAR=value
MYVAR=value
$MYVAR=value
export MYVAR=value
The reason why the script.sh does not display the content of the variable MYVAR is that the variable is not exported to the environment of the script. When a script is executed, it runs in a separate process that inherits the environment variables from the parent process, but not the shell variables. A shell variable is a variable that is defined and visible only in the current shell session, while an environment variable is a variable that is exported to the environment and visible to all processes that run in that environment1.
To make a shell variable an environment variable, we need to use the export command. The export command takes a shell variable name and adds it to the environment of the current shell and any subshells or processes that are created from it2. For example, to export the variable MYVAR with the value value, we can use:
export MYVAR=value
This will make the variable MYVAR available to the script.sh when it is executed, and the script will print the value of MYVAR as expected. Alternatively, we can also use the export command with the -n option to remove a variable from the environment, or with the -p option to list all the environment variables2.
The other options are not valid ways to set MYVAR as an environment variable. The !MYVAR=value option is not a valid syntax for setting a variable in bash. The env MYVAR=value option will run the env command with the MYVAR=value argument, which will print the environment variables with the addition of MYVAR=value, but it will not affect the current shell or the script.sh3. The MYVAR=value option will set MYVAR as a shell variable, but not as an environment variable, so it will not be visible to the script.sh1. The $MYVAR=value option will try to set the variable whose name is the value of MYVAR to the value value, which is not what we want4. 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 tar command in Linux is used to create, extract, list, and manipulate archive files1. The -c option tells the command to create a new archive file. The -f option specifies the name of the archive file. The last argument is the name of the directory or file to be archived. Therefore, the command tar -cf work.tar ./work/ will create an archive file named work.tar from the contents of the directory ./work/. The other options are either invalid or do not create the desired archive file. Option A uses an unrecognized option --new. Option C uses an incorrect option --content and an incorrect extension .tgz for a plain tar archive. Option D and E use an incorrect syntax for redirecting the input or output of the tar command. References:
Which of the following examples shows the general structure of a for loop in a shell script?
for *.txt as file => echo $file
for *.txt ( echo $i )
for file in *.txt do
echo $i done
for ls *.txt exec {} \;
foreach @{file} { echo $i
}
The general structure of a for loop in a shell script is as follows12:
for variable in list do commands done
The variable is the name of a loop counter or iterator that takes on the values of the items in the list. The list can be a sequence of words, numbers, filenames, or the output of a command. The commands are the body of the loop that are executed for each value of the variable. The do and done keywords mark the beginning and the end of the loop body.
The option C. for file in *.txt do echo $i done follows this structure, with the variable being file, the list being *.txt (which matches all the files with the .txt extension in the current directory), and the command being echo $i (which prints the value of the variable i, which is presumably set somewhere else in the script).
The other options are incorrect because:
for file in *.txt do echo $file done
for i in *.txt do echo $i done
for file in *.txt do exec $file done
for file in * do echo $file done
References:
What is true about the owner of a file?
Each file is owned by exactly one user and one group.
The owner of a file always has full permissions when accessing the file.
The user owning a file must be a member of the file’s group.
When a user is deleted, all files owned by the user disappear.
The owner of a file cannot be changed once it is assigned to an owner.
In Linux, every file and directory is associated with an owner and a group. The owner is the user who created the file or directory, and the group is the group to which the owner belongs. Therefore, each file is owned by exactly one user and one group. This is true for option A. The other options are false for the following reasons:
What are the differences between a private web browser window and a regular web browser window? (Choose three.)
Private web browser windows do not allow printing or storing websites.
Private web browser windows do not store cookies persistently.
Private web browser windows do not support logins into websites.
Private web browser windows do not keep records in the browser history.
Private web browser windows do not send regular stored cookies.
A private web browser window is a mode of browsing that prevents the browser from saving your browsing history, cookies, and other site data, or information entered in forms. However, it does not prevent websites, your employer or school, or your internet service provider from tracking your online activity. The main differences between a private web browser window and a regular web browser window are:
References: Browse in private - Computer - Google Chrome Help, Browse InPrivate in Microsoft Edge - Microsoft Support, Private Browsing: What Is It and How to Use It | Edge Learning Center
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 puts the lines of the file data.csv into alphabetical order?
a..z data.csv
sort data.csv
abc data.csv
wc -s data.csv
grep --sort data.csv
The sort command is used to sort the lines of a file or a stream of input according to a specified criterion, such as alphabetical order, numerical order, reverse order, etc. By default, the sort command sorts the lines in ascending alphabetical order, using the firstcharacter of each line as the key. For example, the command sort data.csv will sort the lines of the file data.csv in alphabetical order and display the output on the screen. If you want to save the sorted output to a new file, you can use the redirection operator (>) to specify the output file name. For example, the command sort data.csv > sorted_data.csv will sort the lines of the file data.csv in alphabetical order and save the output to a new file named sorted_data.csv. The other commands are either invalid or do not perform the sorting operation. The a…z command does not exist, the abc command is a text editor, the wc command counts the number of words, lines, and bytes in a file, and the grep command searches for a pattern in a file or a stream of input. Therefore, the correct answer is B. References:
Which of the following commands creates the ZIP archive poems.zip containing all files in the current directory whose names end in .txt?
zip *.txt > poems.zip
zcat *.txt poems.zip
zip poems.zip *.txt
zip cfz poems.zip *.txt
cat *.txt | zip poems.zip
The zip command is used to create compressed archive files that can contain one or more files or directories. The zip command takes the name of the archive file as the first argument, followed by the names of the files or directories to be included in the archive. You can also use wildcards to match multiple files or directories with a common pattern. For example, the command zip poems.zip *.txt will create the ZIP archive poems.zip containing all files in the current directory whose names end in .txt. The other commands are either invalid or do not perform the desired operation. The command zip *.txt > poems.zip will try to create an archive for each file ending in .txt and redirect the output to poems.zip, which is not a valid archive file. The command zcat *.txt poems.zip will try to decompress and concatenate the contents of the files ending in .txt and poems.zip, which is not a valid ZIP file. The command zip cfz poems.zip *.txt will fail because the options c, f, and z are not valid for the zip command. The command cat *.txt | zip poems.zip will try to read the contents of the files ending in .txt from the standard input and create an archive named poems.zip, but this will not preserve the file names or attributes of the original files. References:
What is the preferred source for the installation of new applications in a Linux based operating system?
The vendor's version management system
A CD-ROM disk
The distribution's package repository
The vendor's website
A retail store
The distribution’s package repository is the preferred source for the installation of new applications in a Linux based operating system. A package repository is a collection of software packages that are maintained by the distribution and can be easily installed, updated, or removed using a package manager. Package repositories offer several advantages, such as:
The other sources are not preferred because they may not offer these benefits and may cause problems with the system. The vendor’s version management system, the vendor’s website, or a CD-ROM disk may contain packages that are not compatible with the distribution or may conflict with other packages. A retail store may not have the latest or the most suitable packages for the system. References:
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:
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:
What is true about links in a Linux file system?
A symbolic link can only point to a file and not to a directory.
A hard link can only point to a directory and never to a file.
When the target of the symbolic link is moved, the link is automatically updated.
A symbolic link can point to a file on another file system.
Only the root user can create hard links.
A symbolic link, also known as a symlink or soft link, is a special type of file that points to another file or directory by its name. A symbolic link can point to a file or directory on the same or different file system, as long as the target is accessible. For example, you can create a symbolic link to a file on a USB drive or a network share, as long as the device is mounted or the connection is established. However, if the target of the symbolic link is moved, renamed, or deleted, the link becomes broken and does not work. To create a symbolic link, you can use the ln command with the -s or --symbolic option, followed by the target name and the link name. For example, ln -s /mnt/usb/file.txt link.txt creates a symbolic link named link.txt that points to the file.txt on the USB drive mounted at /mnt/usb.
The other options are not true about links in a Linux file system. A symbolic link can point to a directory as well as a file. A hard link, which is a direct reference to the same data as another file, can only point to a file and not a directory. A hard link cannot span across different file systems, because it depends on the inode number, which is unique within a file system. When the target of the symbolic link is moved, the link is not automatically updated, but becomes broken. Any user can create hard links, as long as they have the permission to read and write the target file and the link directory.
References:
Which of the following directories contains information, documentation and example configuration files for
installed software packages?
/usr/share/doc/
/etc/defaults/
/var/info/
/doc/
/usr/examples/
The /usr/share/doc/ directory is the standard location for documentation files for installed software packages on Linux systems12. It contains subdirectories for each package, which may include README files, manuals, license information, changelogs, examples, and other useful resources12. The /usr/share/doc/ directory is part of the Filesystem Hierarchy Standard (FHS), which defines the structure and layout of files and directories on Linux and other Unix-like operating systems3.
The other options are incorrect because:
References:
Which of the following commands can be used to resolve a DNS name to an IP address?
dnsname
dns
query
host
iplookup
The host command is used to resolve a DNS name to an IP address or vice versa. It can also perform other DNS queries, such as finding the mail servers for a domain. The host command has the following syntax: host [options] [name] [server]. The name argument can be a hostname, such as www.lpi.org, or an IP address, such as 192.168.0.1. The server argument is optional and specifies the name or IP address of the DNS server to query. If no server is given, the default system resolver is used. References:
Which of the following values could be a process ID on Linux?
/bin/bash
60b503cd-019e-4300-a7be-922f074ef5ce
/sys/pid/9a14
fff3
21398
A process ID on Linux is a unique integer value that identifies a running process. The process ID can range from 0 to a maximum limit, which is usually 32768 or higher, depending on the system configuration. The process ID of 0 is reserved for the kernel’s idle task, and the process ID of 1 is reserved for the init system, which is the first process launched by the kernel. The process IDs are assigned sequentially to new processes, and are recycled when a process terminates. Therefore, the only valid value for a process ID among the given options is 21398, which is an integer within the possible range. The other values are not valid process IDs because they are either strings, hexadecimal numbers, or file paths, which do not match the format of a process ID on Linux. References:
Which of the following types of bus can connect hard disk drives with the motherboard?
The RAM bus
The NUMA bus
The CPU bus
The SATA bus
The Auto bus
A bus is a communication system that transfers data between components inside a computer or between computers. There are different types of buses that serve different purposes. The RAM bus connects the CPU with the main memory, the NUMA bus connects multiple processors in a multiprocessor system, the CPU bus connects the CPU with other components on the motherboard, and the Auto bus is a fictional bus that can transform into a robot. The SATA bus is the correct answer because it is a type of bus that can connect hard disk drives with the motherboard. SATA stands for Serial Advanced Technology Attachment and it is a standard interface for connecting storage devices such as hard disk drives, solid state drives, and optical drives. SATA offers faster data transfer rates, lower power consumption, and improved cable management compared to older interfaces such as IDE and SCSI. References: : [Bus (computing)] : [Transformers: Robots in Disguise (2015 TV series)] : [Serial ATA]3) : [SATA vs. IDE: What’s the Difference?]
Which of the following commands finds all lines in the file operating-systems.txt which contain the term
linux, regardless of the case?
igrep linux operating-systems.txt
less -i linux operating-systems.txt
grep -i linux operating-systems.txt
cut linux operating-systems.txt
cut [Ll] [Ii] [Nn] [Uu] [Xx] operating-systems.txt
The grep command is used to search for a pattern in a file or input. The -i option makes the search case-insensitive, meaning that it will match both uppercase and lowercase letters. The grep command takes the pattern as the first argument and the file name as the second argument. Therefore, the command grep -i linux operating-systems.txt will find all lines in the file operating-systems.txt which contain the term linux, regardless of the case. References: Linux Essentials - Topic 103: Finding Linux Documentation and Linux Essentials - Topic 104: Command Line Basics
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
What is the return value of a shell script after successful execution?
1
0
-1
-255
255
The return value of a shell script after successful execution is 0. This is a convention followed by most UNIX and Linux commands, programs, and utilities. A return value of 0 indicates that the command or script completed successfully, without any errors. A return value of non-zero (1-255) indicates that the command or script failed, and the value can be interpreted as an error code. The return value of a command or script is stored in the special variable $? and can be used to test the outcome of a command or script123. For example, the following script will print a message based on the return value of the ls command:
#!/bin/bash ls if [ $? -eq 0 ]; then echo “ls command executed successfully” else echo “ls command failed” fi
References: 1: Exit and Exit Status - Linux Documentation Project 2: Linux Passwd Command Help and Examples 3: bash - Which is the best way to check return result? - Unix & Linux Stack Exchange
Copyright © 2014-2025 Certensure. All Rights Reserved