All is File - Test 1

5.4 Special Files and Directories

Understanding /tmp and link



Practice Exam Questions 1

Scenario:

1. A developer needs to store temporary files that should persist between reboots. Which directory should the developer choose?
a) /tmp
b) /var/tmp
c) /run
d) /var/run
/* --------------------- */

--------------------------

Answer 1 Below: 

--------------------------

/* --------------------- */

Explanation:
According to the Filesystem Hierarchy Standard (FHS), the /var/tmp directory is intended for storing temporary files that should not be cleared during system boot-up. Files stored in this directory are expected to persist between reboots, making it suitable for temporary data that needs to be retained across system restarts.


Explanation of incorrect answers:
a) /tmp:
The /tmp directory is recommended for temporary files that do not need to persist between invocations of a program. It is cleared during system boot-up, so files stored here will not survive a reboot.
c) /run:
The /run directory contains run-time variable data used by running processes, but it must be cleared during system boot-up. Files stored here will not persist between reboots.
d) /var/run:
Although /var/run was once used for run-time variable data, on some systems it may be a symbolic link to /run. Like /run, it must be cleared during system boot-up and does not guarantee persistence between reboots.
 
Correct answer 1: b) /var/tmp

Scenario:

2. A program needs to create multiple run-time files. Which directory should the program use?
a) /tmp
b) /var/tmp
c) /run
d) /var/run
/* --------------------- */

--------------------------

Answer 2 Below: 

--------------------------

/* --------------------- */

Explanation:
The /run directory contains run-time variable data used by running processes. If a program requires multiple run-time files, it may create subdirectories within the /run directory. However, it is important to note that the contents of the /run directory are cleared during system boot-up.


Explanation of incorrect answers:
a) /tmp:
The /tmp directory is not specifically intended for run-time variable data. It is cleared during system boot-up and is typically used for temporary files that do not need to persist between invocations of a program.
b) /var/tmp:
The /var/tmp directory is suitable for storing temporary files that should persist between reboots, but it is not specifically designed for run-time variable data.
d) /var/run:
Although /var/run was once used for run-time variable data, on some systems it may be a symbolic link to /run. The contents of this directory are cleared during system boot-up and are not guaranteed to persist between reboots.
 
Correct answer 2: c) /run

Scenario:

3. A developer wants to store temporary files that will be erased during system boot-up. Which directory should be used?
a) /tmp
b) /var/tmp
c) /run
d) /var/run
/* --------------------- */

--------------------------

Answer 3 Below: 

--------------------------

/* --------------------- */

Explanation:
According to the Filesystem Hierarchy Standard (FHS), the /tmp directory is recommended for temporary files that are not expected to persist between invocations of a program. The convention is to clear this directory during system boot-up, although it is not mandatory.

Explanation of incorrect answers:
b) /var/tmp:
The /var/tmp directory is intended for storing temporary files that should persist between reboots. It is not cleared during system boot-up.
c) /run:
The /run directory contains run-time variable data and must be cleared during system boot-up. Files stored here will not be erased solely during system boot-up.
d) /var/run: Although /var/run was once used for run-time variable data, on some systems it may be a symbolic link to /run. The contents of this directory are cleared during system boot-up, but it is not specifically designed for temporary files.

Correct answer 3: a) /tmp

Scenario:

4. A program needs to store temporary files but wants to follow the FHS conventions. Which directory should the program choose?
a) /tmp
b) /var/tmp
c) /run
d) Any location on the system
/* --------------------- */

--------------------------

Answer 4 Below: 

--------------------------

/* --------------------- */

Explanation:
The Filesystem Hierarchy Standard (FHS) recommends certain directories for storing temporary files, such as /tmp and /var/tmp. However, it does not restrict a program from creating temporary files elsewhere on the system. While it is good practice to follow FHS conventions, it is not mandatory.


Explanation of incorrect answers:
a) /tmp:
The /tmp directory is one of the recommended locations for storing temporary files according to FHS. However, it is not the only possible location, and the program can choose a different location if required.
b) /var/tmp:
The /var/tmp directory is another recommended location for storing temporary files. However, it is not the only permissible location, and the program can choose an alternative location if needed.
c) /run:
The /run directory is not specifically designated for storing general temporary files. It is intended for run-time variable data used by running processes, such as process identifier files.
 
Correct answer 4: d) Any location on the system

Scenario:

5. A developer wants to store temporary files that will persist between reboots. Which directory should be used?
a) /tmp
b) /var/tmp
c) /run
d) /var/run
/* --------------------- */

--------------------------

Answer 5 Below: 

--------------------------

/* --------------------- */

Explanation:
The /var/tmp directory is intended for storing temporary files that should not be cleared during system boot-up. Files stored in this directory will usually persist between reboots, making it suitable for temporary data that needs to be retained across system restarts.


Explanation of incorrect answers:
a) /tmp:
The /tmp directory is recommended for temporary files that do not need to persist between invocations of a program. It is cleared during system boot-up, so files stored here will not survive a reboot.
c) /run:
The /run directory contains run-time variable data used by running processes and must be cleared during system boot-up. Files stored here will not persist between reboots.
d) /var/run:
Although /var/run was once used for run-time variable data, on some systems it may be a symbolic link to /run. Like /run, it must be cleared during system boot-up and does not guarantee persistence between reboots.
 
Correct answer 5: b) /var/tmp

Scenario:

6. A program needs to create a process identifier file (.pid). Where should the program store this file?
a) /tmp
b) /var/tmp
c) /run
d) /var/run
/* --------------------- */

--------------------------

Answer 6 Below: 

--------------------------

/* --------------------- */

Explanation:
The /run directory contains run-time variable data used by running processes, including process identifier files (.pid). Storing the .pid file in the /run directory follows the recommended practice for managing run-time data.


Explanation of incorrect answers:
a) /tmp:
The /tmp directory is not specifically designed for storing process identifier files. While it is possible to store the .pid file here, it does not follow the recommended practice for managing run-time data.
b) /var/tmp:
The /var/tmp directory is intended for storing temporary files that should persist between reboots, but it is not specifically designated for process identifier files.
d) /var/run:
Although /var/run was once used for run-time variable data, on some systems it may be a symbolic link to /run. Storing the .pid file in this directory does not guarantee compatibility across different Linux distributions.
 
Correct answer 6: c) /run

Scenario:

7. A program decides to create temporary files in a non-standard location. What should the developer consider?
a) The files will be automatically erased during system boot-up.
b) The files may not follow the conventions set by the FHS.
c) The files will persist between reboots.
d) The files will be stored in the /var/tmp directory.
/* --------------------- */

--------------------------

Answer 7 Below: 

--------------------------

/* --------------------- */

Explanation:
The Filesystem Hierarchy Standard (FHS) defines standard locations for temporary files on Linux systems. While it does not prevent a program from creating temporary files elsewhere, it is good practice to respect the conventions set by the FHS. By choosing a non-standard location, the developer may deviate from established practices.


Explanation of incorrect answers:
a) The files will be automatically erased during system boot-up:
Whether the files will be automatically erased during system boot-up depends on the specific location chosen by the developer. It is not a universal outcome for all non-standard locations.
c) The files will persist between reboots:
The persistence of temporary files between reboots depends on the location chosen. If a non-standard location is selected, the files may or may not persist between reboots.
d) The files will be stored in the /var/tmp directory:
Choosing a non-standard location does not automatically imply that the files will be stored in the /var/tmp directory. It depends on the developer's decision on where to create the temporary files.

Correct answer 7: b) The files may not follow the conventions set by the FHS.
 
8. Which special permission prevents users from removing or renaming a file within a directory, unless they own the file?
a) Read permission
b) Write permission
c) Execute permission
d) Sticky bit
/* --------------------- */

--------------------------

Answer 8 Below: 

--------------------------

/* --------------------- */

Explanation:
The sticky bit is a special permission that, when set on a directory, prevents users from removing or renaming a file within that directory unless they own the file. It is commonly used for system-wide temporary directories to maintain file security in a multiuser environment.


Explanation of incorrect answers:
a) Read permission:
Read permission allows users to view the contents of a file but does not specifically prevent them from removing or renaming it.
b) Write permission:
Write permission allows users to modify or delete a file, but it does not provide the restriction imposed by the sticky bit.
c) Execute permission:
Execute permission enables users to execute a file as a program, but it does not offer the same file protection as the sticky bit.

Correct answer 8: d) Sticky bit
 
9. What symbol replaces the "x" permission in the output of "ls -l" for directories with the sticky bit set?
a) t
b) s
c) w
d) r
/* --------------------- */

--------------------------

Answer 9 Below: 

--------------------------

/* --------------------- */

Explanation:
Directories with the sticky bit set display a "t" symbol in place of the "x" permission in the output of "ls -l." This symbol visually represents the presence of the sticky bit and helps identify directories where file deletion or renaming by other users is restricted.

Explanation of incorrect answers:
b) s:
The "s" symbol typically represents the setuid or setgid permission, not the sticky bit.
c) w:
The "w" symbol represents the write permission, which is unrelated to the sticky bit.
d) r:
The "r" symbol represents the read permission, which is unrelated to the sticky bit.

Correct answer 9: a) t

10. What numeric mode should be used with "chmod" to set the sticky bit for a directory?
a) 644
b) 755
c) 1755
d) 1777
/* --------------------- */

--------------------------

Answer 10 Below: 

--------------------------

/* --------------------- */

Explanation:
The sticky bit for a directory can be set using the numeric mode with "chmod." The four-digit notation is used, with 1 as the first digit to represent the sticky bit. Therefore, the correct numeric mode to set the sticky bit is 1755.

Explanation of incorrect answers:
a) 644:
This numeric mode represents the permissions rw-r--r--, which does not include the sticky bit.
b) 755:
This numeric mode represents the permissions rwxr-xr-x, which does not include the sticky bit.
d) 1777:
This numeric mode includes the sticky bit, but it also sets the permissions to rwxrwxrwx, which is not necessary for directories and can compromise security.
 
Correct answer 10: c) 1755

11. In symbolic mode, what parameter is used with "chmod" to set the sticky bit for a directory?
a) +t
b) +s
c) +w
d) +r
/* --------------------- */

--------------------------

Answer 11 Below: 

--------------------------

/* --------------------- */

Explanation:
When using symbolic mode with "chmod," the parameter "+t" is used to set the sticky bit for a directory. The plus sign (+) signifies adding the specified permission, and "t" specifically represents the sticky bit.

Explanation of incorrect answers:
b) +s:
The "+s" parameter is typically used to set the setuid or setgid permissions, not the sticky bit.
c) +w:
The "+w" parameter represents adding write permission, which is unrelated to setting the sticky bit.
d) +r:
The "+r" parameter represents adding read permission, which is unrelated to setting the sticky bit.

Correct answer 11: a) +t
 
12. How can the sticky bit be disabled for a directory using "chmod"?
a) chmod -t directory
b) chmod +s directory
c) chmod -w directory
d) chmod -r directory
/* --------------------- */

--------------------------

Answer 12 Below: 

--------------------------

/* --------------------- */

Explanation:
The sticky bit can be disabled for a directory using the "chmod" command with the "-t" parameter. The minus sign (-) signifies removing the specified permission, and "t" indicates the sticky bit.


Explanation of incorrect answers:
b) chmod +s directory:
This command would set the setuid or setgid permissions, not disable the sticky bit.
c) chmod -w directory:
This command would remove write permission, but it does not specifically disable the sticky bit.
d) chmod -r directory:
This command would remove read permission, but it does not specifically disable the sticky bit. 
 
Correct answer: a) chmod -t directory

 

Disclaimer: 

The samples provided here are intended to serve as a general guide and reference for individuals preparing for the LPI Linux certifications. These samples are not meant to represent the exact questions that may appear on the actual exam. The LPI certification exams are constantly updated and revised, and the questions on each exam are carefully crafted to assess a candidate's knowledge and skills.

Therefore, while I have made every effort to ensure the accuracy and relevance of the samples provided, I cannot guarantee that they will reflect the content or difficulty level of the actual exam. Additionally, I do not endorse or have any affiliation with the Linux Professional Institute (LPI).

I strongly recommend that candidates use these samples as an additional resource for their exam preparation, in combination with other study materials and practice tests. Ultimately, success on the LPI Linux certification exams will depend on an individual's knowledge, experience, and understanding of the exam objectives.
 
By using these samples, you agree that neither the provider of these sample questions nor any of its affiliates or employees shall be liable for any damages arising from your use or reliance on these sample questions or any information provided herein.

Comments

Popular Posts