Which permissions are set on a regular file once the permissions have been modified with the
command
chmod 654 file.txt?
E
Explanation:
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 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. Reference:
Linux Essentials Version 1.6 Objectives: 4.1.
Ownership and Permissions1
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 Command2
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to
the Exercises - Chapter 8. Security and File Permissions - 8.1.
Ownership and Permissions - Exercise
8.1.12
What is true about the owner of a file?
A
Explanation:
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:
Option B: The owner of a file does not always have full permissions when accessing 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 permissions 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 system, 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 capability, 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. Reference: 1: Chown Command in Linux (File Ownership) | Linuxize 2 3: Linux File
Permissions and Ownership Explained with Examples 4 2: 3 Ways to Find File Owner in Linux -
howtouselinux 1
Which of the following permissions are set on the /tmp/ directory?
A
Explanation:
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. Reference: :
[File system permissions] : [Sticky bit] : [chmod]
Which command adds the new user tux and creates the user’s home directory with default
configuration
files?
B
Explanation:
The useradd command in Linux is used to create new user accounts on the system1
.
The -m option
tells the command to create the user’s home directory as /home/username and copy the files from
/etc/skel directory to the user’s home directory2
.
The /etc/skel directory contains the default
configuration files for new users3
. Therefore, the command useradd -m tux will add the new user tux
and create the user’s home directory with default configuration files. The other options are either
invalid or do not create the user’s home directory. Reference:
Linux Essentials Version 1.6 Objectives, Topic 1.4: Command Line Basics, Subtopic: Basic Shell
Commands
Linux Essentials Version 1.6 Exam Preparation Guide, Section 1.4: Command Line Basics, Page 16
Linux useradd Command Tutorial for Beginners (15 Examples)
What information is stored in /etc/passwd? (Choose three correct answers.)
BCE
Explanation:
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:
Username: The string you type when you log into the system. Each username must be a unique string
on the machine. The maximum length of the username is restricted to 32 characters.
Password: In older Linux systems, the user’s encrypted password was stored in the /etc/passwd file.
On most modern systems, this field is set to x, and the user password is stored in the /etc/shadow
file.
User ID (UID): The user identifier is a number assigned to each user by the operating system to refer
to a user. It is used by the kernel to check for the user privileges and grant access to system
resources. The UID 0 is reserved for the root user and cannot be assigned to any other user.
Group ID (GID): The user’s group identifier number, referring to the user’s primary group. When a
user creates a file, the file’s group is set to this group. Typically, the name of the group is the same as
the name of the user. User’s secondary groups are listed in the /etc/group file.
User ID Info (GECOS): This is a comment field. This field contains a list of comma-separated values
with the following information: User’s full name or the application name, Room number, Work
phone number, Home phone number, Other contact information.
Home directory: The absolute path to the user’s home directory. It contains the user’s files and
configurations. By default, the user home directories are named after the name of the user and
created under the /home directory.
Login shell: The absolute path to the user’s login shell. This is the shell that is started when the user
logs into the system. On most Linux distributions, the default login shell is Bash.
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. Reference:
Linux Essentials Topic 104: The Linux Operating System
, section 104.4: Runlevels and Boot Targets.
Linux Essentials Topic 106: Security and File Permissions
, section 106.1: Basic security and identifying
user types.
Linux Essentials Topic 106: Security and File Permissions
, section 106.2: Creating users and groups.
Understanding the /etc/passwd File | Linuxize
Understanding the /etc/passwd File - GeeksforGeeks
passwd(5) - Linux manual page - man7.org
Understanding /etc/passwd file in Linux - DEV Community
Which of the following tar options handle compression? (Choose two correct answers.)
BD
Explanation:
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:
-c: create a new archive file.
-x: extract files from an existing archive file.
-t: list the contents of an archive file.
-v: show the progress of the operation.
-f: specify the name of the archive file.
-z: use gzip compression or decompression.
-j: use bzip2 compression or decompression.
-J: use xz compression or decompression.
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. Reference:
Linux Essentials Version 1.6 Objectives: 3.1.
Archiving Files on the Command Line1
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 9. The Power
of the Command Line - 9.1. Archiving Files on the Command Line - 9.1.1.
The tar Command2
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to
the Exercises - Chapter 9. The Power of the Command Line - 9.1.
Archiving Files on the Command
Line - Exercise 9.1.12
FILL BLANK
What keyword is used in a shell script to begin a loop? (Specify one keyword only, without any
additional
information.)
for
Explanation:
The keyword for is used in a shell script to begin a loop that iterates over a list of items or a range of
numbers. The syntax of the for loop is as follows:
for <var> in <list> do <commands> done
The variable <var> is assigned to each element of the <list> in turn, and the <commands> are
executed for each iteration. The <list> can be a sequence of words, numbers, filenames, or other
values. If the <list> is omitted, the for loop will iterate over the positional parameters ($1, $2, …). The
do and done keywords mark the beginning and the end of the loop body, respectively.
The for loop is
one of the three types of loops in shell scripting, along with the while and until loops. Reference: 1:
Looping Statements | Shell Script - GeeksforGeeks 1 2: unix - Shell script "for" loop syntax - Stack
Overflow 2 3: For Loop Shell Scripting - javatpoint 3
Which of the following commands creates an archive file work.tar from the contents of the directory
./
work/?
B
Explanation:
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 . tar --new work.tar ./work/ is incorrect because there is no --new option in the tar command. The
correct option for creating a new archive is --create or -c.
C . tar –create work.tgz –content ./work/ is incorrect because the -content option is not valid. The
correct option for specifying the source files or directories is --files-from or -T. Also, the work.tgz file
name implies compression, but the command does not use any compression option such as -z, -j, or -
J.
D . tar work.tar < ./work/ is incorrect because the tar command does not accept input redirection
from the standard input. The correct way to use the tar command is to provide the options and
arguments after the command name.
E . tar work > work.tar is incorrect because the tar command does not produce output redirection to
the standard output. The correct way to use the tar command is to use the -f option to specify the
output file name. Reference: :
tar command in Linux with examples - GeeksforGeeks
:
tar Command
in Linux With Examples | phoenixNAP KB
The current directory contains the following file:
-rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh
Given that the file is a valid shell script, how can this script be executed? (Choose two correct
answers.)
DE
Explanation:
A shell script is a file that contains a series of commands that can be executed by a shell interpreter.
To execute a shell script, there are two main methods:
Method 1: Specify the path to the script file. This method requires that the script file has the execute
permission, which can be granted by using the chmod command. The script file also needs to have a
shebang line at the beginning, which indicates which interpreter to use for the script. For example,
#!/bin/bash means to use the bash interpreter. To execute the script using this method, you can type
the absolute path or the relative path to the script file. If you are in the same directory as the script
file, you can use the ./ prefix to indicate the current directory. For example, ./test.sh will execute the
test.sh script in the current directory.
Method 2: Pass the script file as an argument to the interpreter. This method does not require the
execute permission or the shebang line for the script file. You can simply use the name of the
interpreter followed by the script file name as an argument. For example, bash test.sh will execute
the test.sh script using the bash interpreter.
Therefore, the correct answers are D and E. A. run test.sh is incorrect because run is not a valid
command in Linux. B. ${test.sh} is incorrect because this syntax is used for variable expansion, not for
executing a script. C. cmd ./test.sh is incorrect because cmd is not a valid command in
Linux. Reference:
Linux Essentials Topic 105: The Power of the Command Line
, section 105.3: Basic shell scripting.
How to Run a Shell Script in Linux [Essentials Explained] - It’s FOSS
How To Execute a Command with a Shell Script in Linux | DigitalOcean
How To Run the .sh File Shell Script In Linux / UNIX
Which of the following commands sorts the output of the command export-logs?
D
Explanation:
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. Reference:
Linux Essentials Version 1.6 Objectives: 3.2.
Searching and Extracting Data from Files1
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 9. The Power
of the Command Line - 9.2. Searching and Extracting Data from Files - 9.2.1.
The sort Command2
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 9. The Power
of the Command Line - 9.3. Turning Commands into a Script - 9.3.1.
Pipes and Redirection2
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to
the Exercises - Chapter 9. The Power of the Command Line - 9.2.
Searching and Extracting Data from
Files - Exercise 9.2.12
Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to
the Exercises - Chapter 9. The Power of the Command Line - 9.3.
Turning Commands into a Script -
Exercise 9.3.12