Linux Essentials Certificate Exam - version 1.6 Questions and Answers
Which of the following outputs could stem from the commandlast?
Options:
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)
Answer:
EExplanation:
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:
- Linux Essentials Version 1.6 Objectives3, Topic 1.4: Command Line Basics, Subtopic: Basic Shell Commands
- Linux last Command Tutorial for Beginners (8 Examples)4
- Linux Essentials Version 1.6 Exam Preparation Guide, Section 1.4: Command Line Basics, Page 16
Which command adds the new usertuxand creates the user’s home directory with default configuration
files?
Options:
defaultuser tux
useradd –m tux
usercreate tux
useradd –o default tux
passwd –a tux
Answer:
BExplanation:
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. References:
- 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 is true about links in a Linux file system?
Options:
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.
Answer:
DExplanation:
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:
- Linux Essentials - Linux Professional Institute (LPI)
- Ln Command in Linux (Create Symbolic Links) | Linuxize
What is the purpose of the PATH environment variable?
Options:
It allows the execution of commands without the need to know the location of the executable.
It increases security by preventing commands from running in certain locations.
It specifies the location of a user's home directory.
It indicates the location of the default shell to be used when a user logs in.
It contains the absolute path to the current directory.
Answer:
AExplanation:
The PATH environment variable is a special variable that contains a list of directories that the system searches when looking for a command to execute12. The purpose of the PATH variable is to make it easier and faster for users to run commands without having to type the full path to the executable file. For example, if you want to run the ls command, which is located in the /bin directory, you don’t have to type /bin/ls every time. You can just type ls, and the system will find the executable file in the /bin directory, which is one of the directories in the PATH variable. The PATH variable can be viewed with the echo command12:
$ echo $PATH
The PATH variable can also be modified by adding or removing directories, either temporarily or permanently, depending on the user’s needs12. For example, if you have acustom script or program in your home directory, and you want to run it from anywhere, you can add your home directory to the PATH variable with the export command12:
$ export PATH=$PATH:~/myprogram
This will append your home directory to the end of the PATH variable, and the system will search it last when looking for a command. To make this change permanent, you need to edit a configuration file, such as ~/.bashrc or ~/.profile, and add the export command there12.
References:
- How To View and Update the Linux PATH Environment Variable | DigitalOcean
- Linux path environment variable - Linux command line - LinuxConfig.org
What is the UID of the user root?
Options:
1
-1
255
65536
0
Answer:
EExplanation:
The UID of the user root is always 0 on Linux systems. This is because the kernel uses the UID 0 to check for the superuser privileges and grant access to all system resources. The name of the user account with UID 0 is usually root, but it can be changed or have aliases. However, some applications may expect the name root and not work properly with a different name. The UID 0 is reserved for the root user and cannot be assigned to any other user. The UID 0 is stored in the /etc/passwd file along with other user information. References:
- 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.
Which of the following programs is a graphical editor for vector graphics?
Options:
Python
NGINX
Samba
Inkscape
MySQL
Answer:
DExplanation:
A vector graphics editor is a software program that allows users to create and edit vector graphics, which are images composed of mathematical curves and shapes. Vector graphics are scalable, meaning they can be resized without losing quality or clarity. Python, NGINX, Samba, and MySQL are not vector graphics editors, but rather other types of software. Python is a programming language, NGINX is a web server, Samba is a file and print server, and MySQL is a database management system. Inkscape is a free and open source vector graphics editor that supports the SVG (Scalable Vector Graphics) format, as well as other formats. Inkscape can be used to create logos, icons, diagrams, illustrations, and other graphics. Inkscape is one of the applications covered in the Linux Essentials certification program from the Linux Professional Institute (LPI). References:
- Linux Essentials - Linux Professional Institute (LPI)
- Draw Freely | Inkscape
Which of the following values could be a process ID on Linux?
Options:
/bin/bash
60b503cd-019e-4300-a7be-922f074ef5ce
/sys/pid/9a14
fff3
21398
Answer:
EExplanation:
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:
- Linux Essentials - Linux Professional Institute (LPI)
- How Are Linux PIDs Generated? | Baeldung on Linux
Which of the following characters in a shell prompt indicates the shell is running with root privileges?
Options:
!
#
*
&
$
Answer:
BExplanation:
The shell prompt is a symbol or a string of characters that indicates the shell is ready to accept commands. The shell prompt can be customized by the user or by the system administrator. The default shell prompt for a normal user is usually a dollar sign ($), while the default shell prompt for the root user is usually a hash sign (#). The root user is the superuser or the administrator of the system, who has full access and control over all files, commands, and resources. Running commands as root can be dangerous, as it can cause irreversible damage to the system if done incorrectly. Therefore, it is advisable to use sudo or su to run commands as root only when necessary, and to switch back to a normal user as soon as possible. The shell prompt indicates the shell is running with root privileges when it ends with a hash sign (#). References:
- Linux Essentials - Linux Professional Institute (LPI)
- Running a shell command as root - Unix & Linux Stack Exchange
What happens to a file residing outside the home directory when the file owner's account is deleted? (Choose two.)
Options:
During a file system check, the file is moved to /lost +found.
The file is removed from the file system.
The UID of the former owner is shown when listing the file's details.
The user root is set as the new owner of the file.
Ownership and permissions of the file remain unchanged.
Answer:
C, EExplanation:
When a user account is deleted, the files owned by that user are not automatically deleted from the file system, unless they are in the user’s home directory. The files residing outside the home directory will remain unchanged, but they will have an invalid owner. The owner of a file is identified by a numeric user ID (UID), which is mapped to a user name by the /etc/passwd file. When a user is deleted, the corresponding entry in the /etc/passwd file is removed, but the UID of the file is not changed. Therefore, when listing the file’s details, the UID of the former owner is shown instead of the user name. For example, if the user alice with UID 1001 is deleted, and she owns a file named report.txt in the /tmp directory, the output of ls -l /tmp/report.txt will look something like this:
-rw-r–r-- 1 1001 users 1024 Nov 20 14:11 /tmp/report.txt
The user root is not set as the new owner of the file, nor is the file moved to /lost+found or removed from the file system. The /lost+found directory is used to store files that are recovered from a corrupted file system after running the fsck command, not from deleted user accounts. The file system check does not affect the ownership or permissions of the files, unless there is a serious inconsistency that needs to be fixed. References:
- Linux Essentials - Linux Professional Institute (LPI), section 5.2.1
- 5.2 Lesson 1 - Linux Professional Institute Certification Programs, slide 6.
What command displays manual pages? (Specify ONLY the command without any path or parameters.)
Options:
Answer:
man
Explanation:
The command that displays manual pages for Linux commands is the man command. The man command is used to display the manual pages for a given command or topic. For example, to view the manual page for the ls command, you can type:
man ls
This will open the manual page for the ls command in a pager, which allows you to scroll and search through the text. You can also specify the section number of the manual page if there are multiple pages with the same name. For example, to view the manual page for the passwd command in section 1, you can type:
man 1 passwd
The man command is one of the most useful and important commands for learning and using Linux. It provides detailed information about the syntax, options, arguments, examples, and other aspects of a command or topic. You can also use the --help option to get a brief summary of the usage and options of a command. For example, to get a quick help for the man command, you can type:
man --help
To learn more about the man command and how to use it effectively, you can refer to the following resources:
- Linux Essentials Exam Objectives, Version 1.6, Topic 103.1, Weight 2
- Linux Essentials Certification Guide, Chapter 3, Page 51-52
- How to Access Manual Pages for Linux Commands - Linux Tutorials - Learn Linux Configuration
- How to Easily Read a Linux Man Page - Make Tech Easier
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
Options:
/etc/id
/etc/passwd
/etc/group
/home/index
/var/db/users
Answer:
B, CExplanation:
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:
- Linux Essentials Exam Objectives, Version 1.6, Topic 103.1, Weight 2
- Linux Essentials Certification Guide, Chapter 3, Page 51-52
- Linux Filesystem Hierarchy, Chapter 3, Page 17-18
- Linux Users and Groups, Chapter 2, Page 9-10
Which of the following commands creates an archive filework.tarfrom the contents of the directory./
work/?
Options:
tar --new work.tar ./work/
tar –cf work.tar ./work/
tar –create work.tgz –content ./work/
tar work.tar < ./work/
tar work > work.tar
Answer:
BExplanation:
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:
- 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
- Tar Command in Linux (Create and Extract Archives) | Linuxize2
Which of the following examples shows the general structure of a for loop in a shell script?
Options:
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
}
Answer:
CExplanation:
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:
- A. for *.txt as file => echo $file uses an invalid syntax for a for loop. The as keyword 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
References:
- Looping Statements | Shell Script - GeeksforGeeks
- How do I write a ‘for’ loop in Bash? - Stack Overflow
What can be found in the /proc/ directory?
Options:
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.
Answer:
DExplanation:
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 system, 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 arguments, and more. The /proc/ directory also contains a symbolic link called ‘self’, whichpoints to the process that is accessing the /proc/ file system. Therefore, the correct answer 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 processes. 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 provides 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.
References:
- The /proc Filesystem — The Linux Kernel documentation
- A Beginner’s Guide to the /proc File System in Linux - Tecmint
- Appendix E. The proc File System Red Hat Enterprise Linux 6 | Red Hat …
- Chapter 5. The proc File System Red Hat Enterprise Linux 4 | Red Hat …
- proc file system in Linux - GeeksforGeeks
The ownership of the file doku.odt should be changed. The new owner is named tux. Which command accomplishes this change?
Options:
chmod u=tux doku.odt
newuser doku.odt tux
chown tux doku.odt
transfer tux: doku.odt
passwd doku.odt:tux
Answer:
CExplanation:
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:
- Option A uses the chmod command, which stands for change mode, and is used to change the permissions of files and directories, not the ownership3.
- Option B uses the newuser command, which is used to create a new user account, not to change the ownership of a file4.
- Option D uses the transfer command, which is not a valid Linux command.
- Option E uses the passwd command, which is used to change the password of a user account, not the ownership of a file5.
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 is defined by a Free Software license?
Options:
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.
Answer:
EExplanation:
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
Which of the following tasks can the command passwd accomplish? (Choose two.)
Options:
Change a user's username.
Change a user's password.
Create a new user account.
Create a new user group.
Lock a user account.
Answer:
B, EExplanation:
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 beused or changed1. 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 username12. 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, orgroupadd345. 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
What information is stored in/etc/passwd? (Choose three correct answers.)
Options:
The user’s storage space limit
The numerical user ID
The username
The encrypted password
The user\s default shell
Answer:
B, C, EExplanation:
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. References:
- 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
What is the preferred source for the installation of new applications in a Linux based operating system?
Options:
The vendor's version management system
A CD-ROM disk
The distribution's package repository
The vendor's website
A retail store
Answer:
CExplanation:
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:
- They ensure compatibility and stability with the system and other packages.
- They provide security updates and bug fixes for the packages.
- They reduce the risk of malware or corrupted files.
- They simplify the dependency management and configuration of the packages.
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:
- Linux Essentials - Linux Professional Institute (LPI), section 1.3 Installing, Updating and Removing Software Packages
- LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition, chapter 4 Working on the Command Line, section 4.2 Managing Software
- Table of Contents - Linux Professional Institute Certification Programs, section 1.3 Installing, Updating and Removing Software Packages
Which command displays file names only and no additional information?
Options:
ls -a
ls -lh
ls -l
ls -alh
ls -nl
Answer:
AExplanation:
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:
- Linux Essentials - Linux Professional Institute (LPI), section 2.1.1
- 2.1 Lesson 1 - Linux Professional Institute Certification Programs, slide 6.
Which of the following commands sets the variable USERNAME to the value bob?
Options:
set USERNAME bob
$USERNAME==bob
var USERNAME=bob
USERNAME<=bob
USERNAME=bob
Answer:
EExplanation:
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 command 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 subshells, 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 orunset shell options and positional parameters, not variables. The $ sign is used to reference the value of a variable, not to assign it. The == sign is used for comparison, not assignment. The var keyword is not used in Linux, but in some other programming languages. 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 command copies the contents of the directory /etc/, including all sub-directories, to /root/?
Options:
copy /etc /root
cp -r /etc/* /root
cp -v /etc/* /root
rcp /etc/* /root
cp -R /etc/*.* /root
Answer:
BExplanation:
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 systems. The command also uses the following options and arguments123:
- 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 argument 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 correct command is cp.
- Option C uses the -v option, which stands for verbose, and tells cp to print verbose output. This option does not affect the copying process, but only the output. It also 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 copying 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 argument 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.
References: 1: Cp Command in Linux (Copy Files) | Linuxize 2: cp command in Linux with examples - GeeksforGeeks 3: How to Copy Files and Directories in the Linux Terminal
How is a new Linux computing instance provisioned in an laaS cloud?
Options:
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.
Answer:
DExplanation:
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
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?
Options:
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.
Answer:
BExplanation:
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:
- Linux Essentials Version 1.6 Objectives1, Topic 1.4: Command Line Basics, Subtopic: Basic Shell Commands
- Linux Essentials Version 1.6 Exam Preparation Guide2, Section 1.4: Command Line Basics, Page 16
- Execute vs Read bit. How do directory permissions in Linux work?3