Skip to main content

LPI E - Permission Test

5.3 Managing File Permissions and Ownership

Understanding and manipulating file permissions and ownership settings

Practice Exam Scenarios 2

Sceario #1 Here: https://www.certificationmethods.com/2023/05/lpi-e-sticky-gid-uid-test.html

Scenario 1:

You are trying to execute a shell script located in the /home/user/scripts directory. The script is owned by the user "user" and has the following permissions:

-rwxrwx---

You are logged in as the user "guest" and are not a member of the "user" group. 
 
Can you execute the script? 
 
If not, what steps can you take to execute the script?

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

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

Answer 1 Below: 

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

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

No, you cannot execute the script as the "guest" user. The "rwx" permissions at the beginning of the file permissions indicate that the owner, group, and others have read, write, and execute permissions. Since the "guest" user is not the owner or a member of the group associated with the file, they fall under the "others" category. 
 
In this case, "others" only have "rwx" permission, which means they can read the file, but not execute it. To execute the script, you could either change the ownership of the file to the "guest" user or change the permissions to include the "x" attribute for "others" by running the command: chmod o+x /home/user/scripts/script.sh.

Scenario 2:

You are a member of the "admin" group on a Linux server, and you need to modify a configuration file located in the /etc directory. The file is owned by the user "root" and has the following permissions:

-rw-r--r--
 
What steps can you take to modify the file as a member of the "admin" group?
 
/* --------------------- */

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

Answer 2 Below: 

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

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

As a member of the "admin" group, you can use the "sudo" command to modify the configuration file. The "sudo" command allows you to temporarily elevate your privileges to perform administrative tasks. 
 
In this case, you would run the command: sudo vi /etc/config-file. This would allow you to open and modify the file as the "root" user.

Scenario 3:

You are the owner of a file located in the /var/log directory that has the following permissions:

-rw-r-----, and you want to allow all users on the system to read the file. 
 
What command should you use to modify the file permissions and what are the new permissions after running the command?
 
/* --------------------- */

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

Answer 3 Below: 

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

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

To allow all users to read the file, you can modify the permissions using the "chmod" command. Specifically, you can add the "r" permission for "others" by running the command: chmod o+r /var/log/filename. This will change the file permissions to "-rw-r--r--", which means that all users on the system can now read the file.

Scenario 4:

You are trying to access a directory located in the /home/user directory, but you receive the following error message: "Permission denied". The directory has the following permissions:

drwxr-xr--
 
What steps can you take to access the directory?
 
/* --------------------- */

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

Answer 4 Below: 

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

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

The "Permission denied" error message indicates that you do not have the necessary permissions to access the directory. The directory permissions are set to "drwxr-xr--", which means that the owner has read, write, and execute permissions, the group has read and execute permissions, and "others" have no permissions. 
 
To access the directory, you can either change the permissions of the directory using the "chmod" command or change the ownership of the directory to the "guest" user. For example, you could use the command: chmod o+rx /home/user/directory to add read and execute permissions for "others".

Scenario 5:

You are a member of the "developers" group and you need to create a new directory in the /home directory that is accessible to all members of the "developers" group. 
 
What steps should you take to create the directory with the appropriate permissions and group ownership? 
 
/* --------------------- */

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

Answer 5 Below: 

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

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

To create a new directory in the /home directory that is accessible to all members of the "developers" group, you can use the "mkdir" and "chgrp" commands. First, create the new directory using the "mkdir" command: mkdir /home/new_directory. Then, change the group ownership of the directory to the "developers" group using the "chgrp" command: chgrp developers /home/new_directory. 
 
Finally, set the permissions for the directory to allow read, write, and execute access for the owner and group, and read and execute access for others using the "chmod" command: chmod 775 /home/new_directory. The resulting directory permissions should be "drwxrwxr-x".