How to Change File Permissions in Linux from the Terminal

Download ArticleDownload 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.

  1. 1
    Open the Terminal. You will be using the terminal to change file permissions.
  2. 2
    Locate 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
  3. 3
    View 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.
      How.com.vn English: Screen Shot 2022 04 03 at 9.28.57 PM.png
  4. How.com.vn English: Screen Shot 2022 04 03 at 9.31.28 PM.png
    4
    Understand 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)
  5. How.com.vn English: Screen Shot 2022 04 03 at 9.35.04 PM.png
    5
    Find 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.
  6. How.com.vn English: Screen Shot 2022 04 03 at 9.36.33 PM.png
    6
    Use 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.
  7. How.com.vn English: Screen Shot 2022 04 03 at 9.38.42 PM.png
    7
    Verify 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.
  8. 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
      Thanks for submitting a tip for review!

      About This Article

      How.com.vn is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 24,436 times.
      How helpful is this?
      Co-authors: 3
      Updated: April 4, 2022
      Views: 24,436
      Categories: Linux
      Thanks to all authors for creating a page that has been read 24,436 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement