Permissions and User Groups
File permission in linux is very important on any file system. We need to grant the necessary permissions to files/folders as well as to specific users. A file/folder to be able to read by an application should have the necessary read permissions. Whereas, a file that has to be written into needs to have the write permission. Hence the permissions have to be set for each file or folder. The below command enables the user to change the file permissions:
Command:
The chmod command is used to change the file permission. The command means “change mode”. The -r flag added to it denotes that the permission will be changed for all files within that directory.
chmod |
Below are the types of permission:
PERMISSION | DENOTATION | VALUE | RIGHTS |
READ | r | 4 | View Access |
WRITE | w | 2 | Write Access |
EXECUTE | x | 1 | Run Access |
NILL | – | 0 | No Access |
Below are the types of users:
USER | ROLE |
OWNER | The person who created the file |
GROUP | A user-group that has similar access |
WORLD | Any user who is not an owner or part of a group |
Permission Modes:
For any file or folder, the permission is set for the 3 user roles Owner, Group and World. A permission of 755 is shown below:
7 5 5
OWNER GROUP WORLD
r+w+x r-x r-x
4+2+1 4+1 4+1
Sample Permission Modes:
VALUE | PERMISSION |
777 | rwx rwx rwx |
755 | rwx r-x r-x |
744 | rwx r– r– |
655 | rw- r-x r-x |
644 | rw- r—r– |
A 777 permission, denotes a full permission. Which is not normally set as it makes the file full accessible for read, write and execution and thereby vulnerable to attack. Hence, always thick twice before setting a 777 permission. 755 is the normal value set for directories and files should. Executable scripts within the cgi-bin folder must be 755. Images, media, and text files like HTML should be 644.
Changing the File Permission in Linux
Suppose you want to change a file permission on linux from 777 to 755
Method 1: Using Command Prompt:
1. Execute the below command to check the file permission. It lists all files in the directory including their permission:
ls -l
2. Run the chmod command to change the permission to 755
chmod 755 file_name
Replace filename with the original filename
Method 2: Using cPanel:
1. Login to your cPanel
2. Click ‘File Manager’
3. Access the file you want the permission changed.
4. Change permission by either of the below 3 methods:
a. Permission option on top
b. Double clicking the permission corresponding to the file
c. Right mouse the file name and select Change Permission from Options
5. Set the permission to 755
Conclusion
Following the above steps helps admin to change the file permission in Linux for any file/directory.
If you want all your KPI‘s or Business metrics monitored on a single dashboard, join our BETA.