File permissions in Linux

Project description

This project will focus on updating the file permissions for certain files and directories within the projects directory. The permissions do not currently reflect the level of authorization that should be given. Checking and updating these permissions will help keep their system secure. To complete this task, I performed the following tasks:


Check file and directory details

The following code demonstrates how I used Linux commands to determine the existing permissions set for a specific directory in the file system.



The first line of the screenshot displays the command I entered, and the other lines display the output. The code lists all contents of the projects directory. I used the ls command with the -la option to display a detailed listing of the file contents that also returned hidden files. The output of my command indicates that there is one directory name drafts, one hidden file name .project_x.txt, and four other project files. The 10-character string in the first column represents the permissions set on each file and directory. 


Describe the permission string

The 10-character string can be deconstructed to determine who is authorized to access the file and their specific permissions. The characters and what they represent are as follows:

  • 1st character: This character indicates is either a d or hyphen (-) and indicates the file type. If it is a d, it is a directory. If it is a hyphen (-), it is a regular file. 
  • 2nd-4th characters: Those characters indicate the read (r), write (w), and execute (x) permissions for the user. When one of these is a hyphen(-) instead, it indicates that this permission is not granted to the user. 
  • 5th-7th characters: Those characters indicates the read(r), write(w), and execute(x) permissions for the group. When one of those is a hyphen(-) instead, it indicates that this permission is not granted to the group. 
  • 8th-10th characters: Those characters indicates the read(r), write(w), and execute(x) permissions for other. This owner type consists of all other users on the system apart from the user and the group. When one of those characters is a hyphen(-) instead, that indicates that this permission is not granted for other.

For example, the file permissions for .project_x.txt are -rw-r--r--. Since the first character is a hyphen(-), this indicates that .project_x.txt is a file, not a directory. The second, fifth, and eighth characters are r, which means that user, group, and other all have read permissions. The third character is w indicates that only the user has write permissions. No one has execute permissions for .project_x.txt.


Change file permissions

This project requires that user, group and other should not have write access to any of their files. To comply with this, I referred to the file permissions that I previously returned. I determined most of the files in the folder projects have write access permission. The following code demonstrates how I used Linux commands to do this: 



The first two lines of the screenshot display the commands I entered, and the other lines display the output of the second command. The chmod command changes the permission on all the files within the folder. The first augment indicates what permissions should be changed, and the second argument specifies the file or directory. In this example, I removed write permissions from user, group and other for all the projects. After this, I used ls -la to review the updates I made. 


Change file permissions on a hidden file

There is a project that was added to the folder that needs to have the write permission removed and only user and group be allowed to read access. 

The following code demonstrates how I used Linux commands to change the permissions: 



The first two lines of the screenshot display the commands I entered, and the other lines display the output of the second command. I know .project_x.txt is a hiding file because it starts with a period (.). In this example, I removed write permissions from the user and removed read permissions from other. By executing u-w, I removed user write permissions, then by executing o-r, I removed read permissions for other


Change directory permissions

This project requires that cyberx user to have access to the drafts directory and its contents. This means that no one other than cyberx should have execute permissions. 

The following code demonstrates how I used Linux commands to change the permissions: 



The first two lines of the screenshot display the commands I entered, and the other lines display the output of the second command. I previously determined group and other have read and execute permissions. On the other hand, user had only read and execute and missing write permissions. I used the chmod command to remove permissions from group and other. Also, I added write permission to cyberx since it was missing.


Summary

I changed multiple permissions to match the level of authorization this project required for files and directories in the projects directory. The first step in this was using ls -la to check the permissions for the directory. The output showed me that some of those files and folders needed to be modified. I then used the chmod command multiple times to change the permissions of files and directories.