Download Article
Download Article
Understanding how to view and change file permissions in Linux is an important skill to have. Your files and your system could potentially be compromised if certain users can access all of your files. This skill allows you to protect your files and prohibit other users from accessing certain files.
Steps
-
1Open the Terminal . You will be using the terminal to change file permissions.
-
2Locate your file. In order to change the permissions of a file, you must be in the directory where the file is located. You can change directories by using the command cd , followed by a space and the name of the directory you want to switch to.Advertisement
-
3View the current permissions of the file. You should check the current permissions of the files before changing them. The permissions may not need to be changed. Use the command ls -l . Your output will provide details on each file in the directory.
- In the image above, the red square is the current file permissions and the blue square is the name of the file.
-
4Understand the permissions of the file. The file permission string is broken up into blocks. The entities that are files will always begin their permission string with "-". This is shown in the green square. The rest of the permission string (after the "-") represents:
- Permissions for the owner (e.g., the first three characters ("rw-") in the red square)
- Permissions for the group owner (e.g., the second three characters ("r--") in the yellow square)
- Permissions for others (e.g., the last three characters ("r--") in the blue square)
-
5Find the octal number that matches the permissions you want. Use the chart to find the octal number of the permissions you want the file to have. This octal number will be used in changing file permissions.
-
6Use the "chmod" command to change the file's permissions. Use chmod followed by the octal number and the file name. In this case, we are changing the permissions of the file "f5". This command will change your file's permissions to the permissions that correspond with the octal number.
-
7Verify that the file's permissions have been changed. After using the "chmod" command, it is important to make sure the file now has the permissions you want. To view the current file permissions, use the command ls -l . If the permissions of the file have changed to what you want, you have successfully changed your file's permissions.
Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
References
About This Article
Thanks to all authors for creating a page that has been read 29,485 times.
Advertisement