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 follows 1 2 :
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 va l ue 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 b e ing file, the list being *.txt (which matches all the files with the .txt extension in the cu r rent 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:
A. for *.txt as file = > echo $file uses an invalid syntax for a for loop. The as ke y word is not part of the shell script syntax, and the = > symbol is not a valid operator. The correct way to write this loop would be:
for file in *.txt do echo $file done
B. for *.txt ( echo $i ) uses an invalid syntax for a for loop. The parentheses are not part of the shell script syntax, and the loop body is missing the do and done keywords. The correct way to write this loop would be:
for i in *.txt do echo $i done
D. for ls *.txt exec {} ; uses an invalid syntax for a for loop. The ls command is not a valid variable name, and the exec {} ; is not a valid command. This looks like a mix of a for loop and a find command. The correct way to write this loop would be:
for file in *.txt do exec $file done
E. foreach @{file} { echo $i } uses an invalid syntax for a for loop. The foreach keyword is not part of the shell script syntax, and the @{file} and { echo $i } are not valid expressions. This looks like a mix of a for loop and a Perl syntax. The correct way to write this loop would be:
for file in * do echo $file done
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 d e fault, the sort command sorts the lines in ascending alphabetical order, using the first character 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 > sor t ed_data.csv will sort the lines of the file data.csv in alphabetical order and save the ou t put 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 :
Linux Essentials - Linux Professional Institute (LPI) , section 2.3.2
LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition , chapter 4, page 95.
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 n u meric 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 first digit 6 means rw- for the owner, which means the owner can read and write the file, but not execute it.
The second digit 5 means r-x for the group, which means the group can read and execute the file, but not write it.
The third digit 4 means r-- for the others, which means the others can only read the file, but not write or execute it.
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 :
Linux Essentials Version 1.6 Objectives: 4.1. Ownership and Permissions 1
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 8. Security and File Permissions - 8.1. Ownership and Permissions - 8.1.1. The chmod Command 2
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - A p pendix A. Answers to the Exercises - Chapter 8. Security and File Permissions - 8.1. Ownership and Permissions - Exercise 8.1.1 2
What can be found in the /proc/ directory?
One directory per installed program.
One device file per hardware device.
One file per existing user account.
One directory per running process.
One log file per running service.
The /proc/ directory is a virtual file system that contains information about the system and the processes running on it. It is not a conventional file system that stores files on a disk, but rather a dynamic view of the kernel’s data structures. One of the features of the /proc/ directory is that it contains one subdirectory for each process running on the sy s tem, which is named after the process ID (PID). For example, the subdirectory /proc/1/ contains information about the process with PID 1, which is usually the init process. The process subdirectories contain various files that provide information about the process, such as its status, memory usage, open files, environment variables, command line a r guments, and more. The /proc/ directory also contains a symbolic link called ‘self’, which points to the process that is accessing the /proc/ file system. Therefore, the correct a n swer is D. One directory per running process.
The other options are incorrect because:
A. One directory per installed program. This is not true, as the /proc/ directory does not contain information about installed programs, but only about running pr o cesses. Installed programs are usually stored in other directories, such as /bin/, /usr/bin/, /opt/, etc.
B. One device file per hardware device. This is not true, as the /proc/ directory does not contain device files, but only virtual files that represent kernel data. Device files are usually stored in the /dev/ directory, which is another special file system that pr o vides access to hardware devices.
C. One file per existing user account. This is not true, as the /proc/ directory does not contain information about user accounts, but only about processes. User accounts are usually stored in the /etc/ directory, which contains configuration files, such as /etc/passwd/ and /etc/shadow/, that define the users and their passwords.
E. One log file per running service. This is not true, as the /proc/ directory does not contain log files, but only information files. Log files are usually stored in the /var/log/ directory, which contains various files that record the activities of the system and the services.
How is a new Linux computing instance provisioned in an laaS cloud?
The standard Linux installer has to be run through a remote console.
After buying a Linux distribution, its vendor delivers it to a cloud instance.
The installation has to be prepared in a local virtual machine which is then copied to the cloud.
The cloud hosting organization provides a set of pre-prepared images of popular Linux distributions.
A provider-specific configuration file describing the desired installation is uploaded to the cloud provider.
In an Infrastructure as a Service (IaaS) cloud, the provider offers virtualized computing resources such as servers, storage, and network over the internet. The user can provision and manage these resources according to their needs. One of the common ways to provision a new Linux computing instance in an IaaS cloud is to use a pre-prepared image of a Linux distribution provided by the cloud hosting organization. An image is a snapshot of a virtual machine that contains the operating system and other software components. The user can choose from a variety of images that suit their requirements and launch a new instance from the image. This way, the user does not have to install and configure the Linux operating system from scratch, which saves time and effort. Some examples of cloud hosting organizations that provide pre-prepared images of popular Linux distributions are Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), and DigitalOcean. References: Linux Essentials - Topic 108: Cloud Computing and Linux Essentials - Topic 108: Cloud Computing - Exam Objectives
When typing a long command line at the shell, what single character can be used to split a command across multiple lines?
\
The backslash character () is used to escape the meaning of the next character in a command line. This means that the next character is treated as a literal character, not as a special character. For example, if you want to use a space in a file name, you can use a backslash before the space to prevent the shell from interpreting it as a separator. Similarly, if you want to split a long command line across multiple lines, you can use a backslash at the end of each line to tell the shell that the command is not finished yet. The shell will ignore the newline character and continue reading the next line as part of the same command. For example, you can write:
ls -l
/home/user/Documents
instead of:
ls -l /home/user/Documents
Both commands will produce the same output, but the first one is easier to read and type. References:
Linux Essentials - Linux Professional Institute (LPI) , section 2.1.2
2.1 Command Line Basics - Linux Professional Institute Certification Programs , slide 7.
Which of the following statements regarding Linux hardware drivers is correct?
Drivers are regular Linux programs which have to be run by the user who wants to use a device.
Drivers are not used by Linux because the BIOS handles all access to hardware on behalf of Linux.
Drivers are stored on their devices and are copied by the Linux kernel when a new device is attached
Drivers are downloaded from the vendor ' s driver repository when a new device is attached.
Drivers are either compiled into the Linux kernel or are loaded as kernel modules.
Linux hardware drivers are software components that enable the Linux kernel to co m municate with various devices, such as keyboards, mice, printers, scanners, network cards, etc. Drivers are either compiled into the Linux kernel or are loaded as kernel modules. Kernel modules are pieces of code that can be loaded and unloaded into the kernel on demand. They extend the functionality of the kernel without requiring to r e build or reboot the system. Drivers that are compiled into the kernel are always avail a ble, but they increase the size and complexity of the kernel. Drivers that are loaded as kernel modules are only available when needed, but they require a matching version of the kernel and the module. Linux supports a large number of hardware devices, thanks to the efforts of the open source community and some vendors who provide drivers for their products. However, some devices may not have a driver available for Linux, or may require a proprietary driver that is not included in the Linux distribution. In such cases, the user may need to install the driver manually from the vendor’s website or from a third-party repository. References :
Linux Essentials - Linux Professional Institute (LPI) , section 2.2.1
LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition , chapter 3, page 67.
Which statements about the directory /etc/skel are correct? (Choose two.)
The personal user settings of root are stored in this directory.
The files from the directory are copied to the home directory of the new user when starting the system.
The files from the directory are copied to the home directory of a new user when the account is created.
The directory contains a default set of configuration files used by the useradd command.
The directory contains the global settings for the Linux system.
The /etc/skel directory is a skeleton directory that contains the default files and direct o ries that are automatically copied to the home directory of a new user when the account is created by the useradd command 1 2 . The purpose of this directory is to provide a co n sistent and uniform environment for all new users and to save the system administr a tor’s time and effort in configuring the user settings 1 2 . The /etc/skel directory can be customized by adding or removing files and directories as needed, depending on the desired default settings for the new users 1 2 .
The other options are incorrect because:
A. The personal user settings of root are stored in this directory. This is not true, as the personal user settings of root are stored in the /root directory, which is the home directory of the root user 3 . The /etc/skel directory does not affect the root user’s se t tings, but only the settings of the new users created by the useradd command 1 2 .
B. The files from the directory are copied to the home directory of the new user when starting the system. This is not true, as the files from the directory are copied to the home directory of the new user when the account is created, not when starting the system 1 2 . The copying process only happens once, when the useradd command is ex e cuted, and not every time the system is started 1 2 .
E. The directory contains the global settings for the Linux system. This is not true, as the directory contains the default settings for the new users, not the global settings for the Linux system 1 2 . The global settings for the Linux system are usually stored in ot h er directories under /etc, such as /etc/default, /etc/sysconfig, /etc/init.d, etc 4 .
Which of the following statements is true about Free Software?
It is developed by volunteers only.
It may be modified by anyone using it.
It must always be available free of charge.
It only runs on Linux.
It is only distributed as a compiled binary.
The correct statement about Free Software is that it may be modified by anyone using it. This is one of the four essential freedoms of Free Software, which are: the freedom to run the program as you wish, for any purpose; the freedom to study how the program works, and change it so it does your computing as you wish; the freedom to redistribute copies so you can help your neighbor; and the freedom to distribute copies of your modified versions to others 1 . Access to the source code is a precondition for these fre e doms 1 .
The other statements are false for the following reasons:
Free Software is not developed by volunteers only. It can be developed by an y one, including individuals, companies, organizations, or communities. Some Free Sof t ware developers are paid for their work, while others do it as a hobby or for social ben e fit 1 .
Free Software does not have to be available free of charge. It can be sold or given away for any price. The term “free” refers to the users’ freedom, not the price of the software 1 . However, Free Software users have the freedom to redistribute copies, so they can obtain the software at no charge from someone who has a copy 1 .
Free Software does not only run on Linux. It can run on any operating system that supports it, such as Windows, MacOS, BSD, or Android. Linux is an example of a Free Software operating system, but not the only one 1 .
Free Software is not only distributed as a compiled binary. It can also be distri b uted as source code, or both. In fact, Free Software must provide access to the source code, otherwise the users cannot study or modify the software 1 .
What is true about a recursive directory listing?
It includes the content of sub-directories.
It includes the permissions of the directory listed.
It includes details of file system internals, such as inodes.
It includes ownership information for the files.
It includes a preview of content for each file in the directory.
A recursive directory listing is a way of displaying the files and folders in a directory and all its sub-directories. The recursive option can be used with various commands, such as ls, find, or dir, to list the files recursively. For example, the command ls -R will list all the files and folders in the current directory and any sub-directories, showing the hierarchy of the file system 1 2 3 A recursive directory listing does not include the permissions, ownership, or file system details of the files, unless specified by other options. For example, the command ls -lR will list the files recursively and also show the permissions, ownership, size, and modification date of each file 1 A recursive directory listing also does not include a preview of the content of each file, unless specified by other options. For example, the command ls -R --file-type will list the files recursively and also show the file type indicator, such as / for directories, * for executable files, @ for symbolic links, etc 1 References: 1 : ls (Unix) - Wikipedia 2 : Recursively List all directories and files - Stack Overflow 3 : Why is ls -R called “recursive” listing? - Ask Ubuntu
Which command copies the contents of the directory /etc/, including all sub-directories, to /root/?
copy /etc /root
cp -r /etc/* /root
cp -v /etc/* /root
rcp /etc/* /root
cp -R /etc/*.* /root
The correct command to copy the contents of the directory /etc/, including all sub-directories, to /root/ is cp -r /etc/* /root . This command uses the cp command, which stands for copy, and is used to copy files and directories on Linux and Unix sy s tems. The command also uses the following options and arguments 1 2 3 :
The -r option, which stands for recursive, and tells cp to copy all files and sub-directories of the source directory. Alternatively, the -R option can be used, which has the same effect as -r.
The /etc/* argument, which specifies the source directory and all its contents. The asterisk (*) is a wildcard character that matches any file or directory name. This arg u ment tells cp to copy everything inside the /etc/ directory, but not the directory itself.
The /root argument, which specifies the destination directory. This argument tells cp to copy the source files and sub-directories to the /root/ directory.
The other options are incorrect because they use different commands or syntax that do not copy the contents of the directory /etc/, including all sub-directories, to /root/. For example:
Option A uses the copy command, which is not a valid Linux command. The co r rect command is cp.
Option C uses the -v option, which stands for verbose, and tells cp to print ve r bose output. This option does not affect the copying process, but only the output. It a l so does not include the -r or -R option, which is necessary to copy the sub-directories.
Option D uses the rcp command, which stands for remote copy, and is used to copy files between different hosts on a network. This command is not relevant for cop y ing files on the same host.
Option E uses the -R option, which is correct, but also uses the . argument, which is incorrect. The dot (.) is a special character that matches any single character. This a r gument tells cp to copy only the files and directories that have a dot in their name, which may exclude some files and directories that do not have a dot.
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 ow n er 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:
Option B: The owner of a file does not always have full permissions when acces s ing the file. The permissions are determined by the file mode, which can be changed by the owner or the root user. The file mode specifies the read, write, and execute permi s sions for the owner, the group, and others. The owner can have different permissions than the group or others.
Option C: The user owning a file does not have to be a member of the file’s group. The owner can change the group ownership of the file to any group on the sy s tem, regardless of whether the owner belongs to that group or not. However, only the root user or a user with the CAP_CHOWN capability can change the group ownership to a group that the owner is not a member of.
Option D: When a user is deleted, all files owned by the user do not disappear. The files remain on the system, but their owner is changed to an invalid user ID (UID). The files can still be accessed by the group or others, depending on the permissions. The files can also be reclaimed by the root user or a user with the CAP_CHOWN capabi l ity, who can change the owner to a valid user.
Option E: The owner of a file can be changed once it is assigned to an owner. The owner can transfer the ownership to another user, or the root user or a user with the CAP_CHOWN capability can change the owner to any user on the system. The command to change the owner of a file is chown. References : 1 : Chown Command in Linux (File Ownership) | Linuxize 2 3 : Linux File Permissions and Ownership Explained with Exa m ples 4 2 : 3 Ways to Find File Owner in Linux - howtouselinux 1
Which of the following commands sets the variable USERNAME to the value bob?
set USERNAME bob
$USERNAME==bob
var USERNAME=bob
USERNAME < =bob
USERNAME=bob
The correct command to set the variable USERNAME to the value bob is USERNAME=bob. This command assigns the string bob to the variable name USERNAME, using the equal sign (=) as the assignment operator. There is no space around the equal sign, and the variable name and value are case-sensitive. This co m mand sets a shell variable, which is only valid in the current shell session. To make the variable an environment variable, which can be inherited by child processes and su b shells, you need to use the export command, such as export USERNAME=bob. The other commands are not valid for setting variables in Linux. The set command is used to set or unset shell options and positional parameters, not variables. The $ sign is used to refe r ence the value of a variable, not to assign it. The == sign is used for comparison, not a s signment. The var keyword is not used in Linux, but in some other programming la n guages. The < = sign is used for redirection, not assignment. References :
Linux Essentials - Linux Professional Institute (LPI)
How to Set and List Environment Variables in Linux | Linuxize
Which of the following permissions are set on the /tmp/ directory?
rwxrwxrwt
------rwX
rwSrw-rw -
rwxrwS---
r-xr-X--t
The correct permissions for the /tmp directory are rwxrwxrwt, which means that the owner, group, and others have read, write, and execute permissions, and that the sticky bit is set. The sticky bit is a special permission that prevents users from deleting or renaming files that they do not own in a shared directory. The /tmp directory is used for storing temporary files that may be created by different users and processes, so it needs to be accessible and writable by all, but also protected from unauthorized deletion or modification of files. The rwxrwxrwt permissions can be set by using the chmod command with either the octal mode 1777 or the symbolic mode a+trwx. References : : [File system permissions] : [Sticky bit] : [chmod]
Which of the following commands adds the directory /new/dir/ to the PATH environment variable?
$PATH=/new/dir: $PATH
PATH=/new/dir: PATH
export PATH=/new/dir: PATH
export $PATH=/new/dir: $PATH
export PATH=/new/dir: $PATH
The PATH environment variable is a colon-separated list of directories that the shell searches for commands. To add a new directory to the PATH, you need to append it to the existing value of the variable, using the syntax PATH=new/dir:PATH . However, this o n ly changes the PATH for the current shell session. To make the change permanent, you need to use the export command, which makes the variable available to all child pr o cesses of the shell. The export command takes the name of the variable as an argument, without the dollar sign ($). Therefore, the correct command to add /new/dir/ to the PATH and export it is export PATH=/new/dir:PATH . References :
Linux Essentials - Linux Professional Institute (LPI)
How to set the path and environment variables in Windows - Computer Hope
Which of the following tasks can the command passwd accomplish? (Choose two.)
Change a user ' s username.
Change a user ' s password.
Create a new user account.
Create a new user group.
Lock a user account.
The passwd command in Linux is used to change the password of a user account. A normal user can run passwd to change their own password, and a system administrator (the superuser) can use passwd to change another user’s password, or define how that account’s password can be used or changed 1 . The passwd command can also be used to lock or unlock a user account. Locking a user account means disabling the user’s ability to log in to the system, while unlocking a user account means restoring the user’s ability to log in. To lock a user account, the passwd command can be used with the -l option, followed by the username. To unlock a user account, the passwd command can be used with the -u option, followed by the username 1 2 . The passwd command cannot be used to change a user’s username, create a new user account, or create a new user group. These tasks require different commands, such as usermod, useradd, or groupadd 3 4 5 . References: 1 : Linux Passwd Command Help and Examples 2 : Passwd command in Linux: 8 Practical Examples 3 : usermod(8) - Linux man page 4 : useradd(8) - Linux man page 5 : groupadd(8) - Linux man page
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 vis i ble 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 environment 1 .
To make a shell variable an environment variable, we need to use the export co m mand. 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 it 2 . For exa m ple, 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 e x port command with the -n option to remove a variable from the environment, or with the -p option to list all the environment variables 2 .
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.sh 3 . 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.sh 1 . 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 want 4 . References:
Linux Essentials Exam Objectives , Version 1.6, Topic 103.1, Weight 2
Linux Essentials Certification Guide , Chapter 3, Page 51-52
env(1) - Linux manual page
Bash Variables - LinuxConfig.org
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 co m mand 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, d e scription, 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 Profe s sional Institute (LPI). References :
Linux Essentials - Linux Professional Institute (LPI)
Linux Commands Cheat Sheet: Beginner to Advanced - GeeksforGeeks
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 re c ords 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:
NS records are used to specify the authoritative name servers for a domain. They do not hold an IP address, but a domain name of the name server. For example, the NS record for example.com could be:
example.com. IN NS ns1.example.com.
This means that the name server ns1.example.com is authoritative for the domain e x ample.com.
MX records are used to specify the mail exchange servers for a domain. They do not hold an IP address, but a domain name of the mail server and a preference value. For example, the MX record for example.com could be:
example.com. IN MX 10 mail.example.com.
This means that the mail server mail.example.com has a preference value of 10 for r e ceiving email for the domain example.com.
CNAME records are used to create an alias for a domain name. They do not hold an IP address, but another domain name that the alias points to. For example, the CNAME record for www.example.com could be:
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.
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.sh leads 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 . sh to .bin.
The execute bit should be set in the file’s permissions.
The user executing the script should be added to the exec group.
The SetUID bit should be set in the file’s permissions
The script should be run using #!./test. sh instead 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 e i ther 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 e x ec 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:
Linux Essentials Version 1.6 Objectives 1 , Topic 1.4: Command Line Basics, Subto p ic: Basic Shell Commands
Linux Essentials Version 1.6 Exam Preparation Guide 2 , Section 1.4: Command Line Basics, Page 16
Execute vs Read bit. How do directory permissions in Linux work? 3
Which of the following commands output the content of the file Texts 2.txt? (Choose two.)
cat ' Texts 2.txt’
cat -- Texts 2.txt
cat |Texts 2.txt|
cat ' Texts\ 2.txt’
cat Texts\ 2.txt
The correct commands to output the content of the file Texts 2.txt are A and E. These commands use the cat command, which stands for concatenate, to display the content of one or more files. The cat command can take one or more filenames as arguments and print their content to the standard output (usually the terminal screen) 1 2 . The co m mands A and E use different ways to deal with the space character in the filename. The space character is a special character in Linux that separates words and commands. To prevent the shell from interpreting the space as a word separator, the commands A and E use either of the following methods 3 4 :
Option A uses single quotes ( ' ) around the filename to preserve the literal value of the space character. This tells the shell to treat the filename as a single argument and pass it to the cat command. For example: cat ‘Texts 2.txt’
Option E uses a backslash () before the space character to escape its special meaning. This tells the shell to ignore the space as a word separator and treat it as part of the filename. For example: cat Texts\ 2.txt
The other options are incorrect because they use different syntax that do not output the content of the file. For example:
Option B uses a double dash (–) before the filename to indicate the end of o p tions. This is usually used to prevent the shell from interpreting a filename that starts with a dash (-) as an option. However, in this case, the filename does not start with a dash, so the double dash is unnecessary and will cause the command to fail. For exa m ple: cat – Texts 2.txt
Option C uses vertical bars (|) around the filename to indicate a pipe. A pipe is a way of connecting the output of one command to the input of another command. Ho w ever, in this case, there is no command before or after the pipe, so the pipe is meanin g less and will cause the command to fail. For example: cat |Texts 2.txt|
Option D uses single quotes ( ' ) and a backslash () together around the filename. This is redundant and will cause the command to fail. The single quotes already preserve the literal value of the space character, so the backslash is not needed. Moreover, the backslash inside the single quotes will be treated as part of the filename, not as an e s cape character. For example: cat ‘Texts\ 2.txt’
TESTED 13 May 2026
