LPIC-1 Exam 101, Part 1 of 2 101-500 Exam Questions

Page: 1 / 14
Total 296 questions
Question 1

Which mechanism does ssh use to interact with the SSH agent?



Answer : E


Question 2

Which of the following is true for hard linked files? (Choose three.)



Answer : B, C, E

A hard link is a directory entry that points to the same inode as another file. An inode is a data structure that stores the metadata and the location of the data blocks of a file. A hard link is not a separate file, but an additional name for an existing file. Therefore, the following statements are true for hard linked files:

The hard linked files have the same permissions and owner. Since the hard linked files point to the same inode, they share the same attributes, such as the file type, the file size, the access permissions, the owner, the group, and the timestamps. Any changes made to one hard link will affect the other hard links as well. For example, if you change the permissions of one hard link, the other hard links will have the same permissions. You can use the stat command to view the attributes of a file or a hard link.

The hard linked files share the same inode. This is the definition of a hard link. The inode number is a unique identifier for each file on a filesystem. The hard linked files have the same inode number, which means they point to the same data blocks on the disk. You can use the ls -i command to view the inode number of a file or a hard link.

The hard linked files must be on the same filesystem. A hard link cannot cross different filesystems or partitions, because each filesystem has its own inode table. A hard link can only point to an inode that exists on the same filesystem as the hard link. If you try to create a hard link to a file on a different filesystem, you will get an error message saying:

ln: failed to create hard link 'link' => 'file': Invalid cross-device link

The other statements are not true for hard linked files, because:

The output of stat will report hard instead of regular file. This is not true, because the stat command does not distinguish between a regular file and a hard link. The stat command will report the same file type for both the original file and the hard link, which is regular file. The only way to tell if a file is a hard link is to check the link count, which is the number of directory entries that point to the same inode. If the link count is more than one, it means there are hard links to the file. You can use the stat -c %h command to view the link count of a file or a hard link.

The hard linked files are indicated by a -> when listed with ls -l. This is not true, because the -> symbol is used to indicate a symbolic link, not a hard link. A symbolic link, also known as a soft link, is a special type of file that contains a path to another file or directory. A symbolic link does not point to the same inode as the target file, but to the name of the target file. A symbolic link has its own inode number, file type, permissions, and timestamps, which can be different from the target file. You can use the ls -l command to view the file type, permissions, and name of a file or a symbolic link. A symbolic link will have the file type l and the name will be followed by a -> symbol and the path to the target file. For example:

lrwxrwxrwx. 1 user user 9 Aug 29 15:10 link -> file


Hard links and soft links in Linux explained | Enable Sysadmin

Hard Link in Linux: Everything Important You Need to Know

A Brief Introduction to Hard and Soft Links in Linux - LinuxForDevices

How to create links between files in the Linux? - Online Tutorials Library

What is a hard link? -- definition by The Linux Information Project (LINFO)

Question 3

Which of the following commands can be used to locate programs and their corresponding man pages and configuration files?



Answer : E

The correct command to locate programs and their corresponding man pages and configuration files iswhereis. Thewhereiscommand searches for the binary, source, and manual files for a given command name in a list of standard Linux directories. It can also accept a list of directories to search in by using the -B, -M, or -S options. Thewhereiscommand is useful for finding the location and documentation of a program. The other commands are not suitable for this task. Thedirnamecommand strips the last component from a file name and returns the directory name. Thewhichcommand shows the full path of a command that is in the $PATH variable. Thebasenamecommand strips the directory and suffix from a file name and returns the base name. Thequerycommand is not a standard Linux command.Reference:

[LPI Linux Essentials - 1.1 The Linux Community and a Career in Open Source]

[LPI Linux Essentials - 1.2 Finding Your Way on a Linux System]

[LPI Linux Essentials - 1.4 Finding Files]

whereis command in Linux with Examples - GeeksforGeeks

Whereis Command in Linux | Linuxize

Linux whereis Command Explained for Beginners (5 Examples) - HowtoForge

whereis command | Linux# - Geek University

whereis command in Linux - LinuxForDevices


Question 4

Which of the following commands enables the setuid (suid) permission on the executable /bin/foo?



Answer : B

The correct command to enable the setuid (suid) permission on the executable /bin/foo is:

B . chmod 4755 /bin/foo

The chmod command is used to change the permissions of files and directories in Linux. The chmod command can take either a symbolic or a numeric mode to specify the new permissions. The numeric mode is composed of four digits, each representing a different set of permissions: the first digit is for the special permissions, such as setuid, setgid, and sticky bit; the second digit is for the user permissions; the third digit is for the group permissions; and the fourth digit is for the others permissions. Each digit can range from 0 to 7, where 0 means no permissions, 1 means execute permission, 2 means write permission, 4 means read permission, and the sum of these values means a combination of permissions. For example, 5 means read and execute permissions, and 6 means read and write permissions.

The setuid permission is a special permission that allows an executable to run with the privileges of the owner of the file, instead of the user who launched it. The setuid permission is represented by the value 4 in the first digit of the numeric mode. For example, to enable the setuid permission on an executable file, use the following command:

chmod 4xxx file

where xxx is the combination of the user, group, and others permissions.

In this question, the executable file is /bin/foo, and the desired permissions are:

setuid permission enabled

user permissions: read, write, and execute

group permissions: read and execute

others permissions: read and execute

Therefore, the numeric mode for these permissions is 4755, where:

4 means setuid permission enabled

7 means user permissions: read, write, and execute

5 means group permissions: read and execute

5 means others permissions: read and execute

The correct command to enable the setuid permission on /bin/foo with these permissions is:

chmod 4755 /bin/foo

This command will change the permissions of /bin/foo to -rwsr-xr-x, where the s in the user section indicates the setuid permission.

The other options are not correct because:

A . chmod 1755 /bin/foo: This command will enable the sticky bit, not the setuid permission, on /bin/foo. The sticky bit is another special permission that prevents users from deleting or renaming files that they do not own in a shared directory. The sticky bit is represented by the value 1 in the first digit of the numeric mode. For example, to enable the sticky bit on a directory, use the following command:

chmod 1xxx directory

where xxx is the combination of the user, group, and others permissions.

C . chmod u-s /bin/foo: This command will disable the setuid permission, not enable it, on /bin/foo. The u-s option is a symbolic mode that means remove the setuid permission from the user permissions. For example, to disable the setuid permission on an executable file, use the following command:

chmod u-s file

D . chmod 755+s /bin/foo: This command is not valid because it mixes the numeric and the symbolic modes, which are not compatible. The 755 is a numeric mode that means user permissions: read, write, and execute; group permissions: read and execute; others permissions: read and execute. The +s is a symbolic mode that means add the setuid and setgid permissions to the user and group permissions, respectively. The chmod command does not accept both numeric and symbolic modes at the same time, and it will fail with an error message saying:

chmod: invalid mode: '755+s' Try 'chmod --help' for more information.


SetUID, SetGID, and Sticky Bits in Linux File Permissions - GeeksforGeeks

How to use special permissions: the setuid, setgid and sticky bits - Linux Tutorials - Learn Linux Configuration

chmod(1): change file mode bits - Linux man page

Question 5

Where is the systemd journal stored?



Answer : C


Question 6

Which of the following commands is used to change metadata and options for ext3 filesystems?



Answer : D

The tune2fs command is used to change metadata and options for ext2, ext3, and ext4 filesystems. The tune2fs command can adjust various parameters such as the maximum mount count, the check interval, the reserved blocks percentage, the volume label, and the UUID. The tune2fs command can also enable or disable some filesystem features, such as the journal, the dir_index, the acl, and the user_xattr. The tune2fs command requires the device name or the UUID of the filesystem as an argument, and one or more options to specify the changes to be made. For example, to change the volume label of an ext3 filesystem on /dev/sda1 to ''data'', use the following command:

tune2fs -L data /dev/sda1

The other options are not valid commands or options. The mod3fs and mod2fs commands do not exist on a standard Linux system. The tune3fs command is a synonym for tune2fs, but it is not commonly used. The dump2fs command is used to display the superblock and blocks group information for ext2, ext3, and ext4 filesystems, but it does not change any parameters or options.Reference:

tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 ...

Chapter 5. The Ext3 File System - Red Hat Customer Portal

Chapter 37. Getting started with an ext3 file system - Red Hat Customer ...


Question 7

Which of the following commands displays the contents of a gzip compressed tar archive?



Answer : B

The command that displays the contents of a gzip compressed tar archive is tar ztf archive.tgz. This command uses the following options:

-z: Tells tar to read or write archives through gzip, allowing it to work on compressed files directly. -t: Lists the contents of an archive without extracting it. -f archive.tgz: Specifies the name of the archive file.

The output of this command will show the names of the files and directories stored in the archive, one per line. For example, if the archive contains three files named file1, file2, and file3, the output will be:

file1 file2 file3

The other commands are incorrect for the following reasons:

gzip archive.tgz | tar xvf -: This command will decompress the archive using gzip and pipe it to tar, which will extract the files to the current directory. The - option tells tar to read the archive from the standard input. This command does not display the contents of the archive, but rather extracts them.

gzip -d archive.tgz | tar tvf -: This command is similar to the previous one, except that it uses the -d option for gzip to decompress the archive instead of compressing it, and the -t option for tar to list the contents instead of extracting them. However, this command is redundant and inefficient, as tar can handle compressed archives directly with the -z option. Also, the -d option for gzip will delete the original archive file after decompression, which may not be desirable.

tar cf archive.tgz: This command will create a new archive named archive.tgz from the files and directories given as arguments. However, this command does not use the -z option, so the archive will not be compressed with gzip. Also, this command does not display the contents of the archive, but rather creates it.


Page:    1 / 14   
Total 296 questions