When using SSH, you can perform many different tasks. One of the more common tasks is to change file permissions of either files or folders. While you can also do this from within the cPanel, it is much easier to do it in SSH if you are already there. Below we describe and demonstrate how to do this.

To change permissions of a file or folder, you use the chmod command. You use the command, followed by the three digit permission structure you want to assign. Then, type the name of the file or folder you are changing. The basic command structure is shown below:

chmod ### file/folder

Changing the File Permissions

Now it is time for a demonstration. Below we will change the permissions of a file named testfile.txt from 644 to 755.

  1. First, we will log into our account with SSH.
  2. Next, we use the pwd command to see our location. That information is returned on the next line. We are in the public_html folder of our account.

    user5@example.com [~/public_html]# pwd
    /home/user5/public_html

  3. Next, we use the ls command to provide a list of the files and folders. We highlighted the target row in red for you. Note the permissions are in modal format and not the numeric format. -rw-r--r-- is the modal format for 644.

    user5@example.com [~/public_html]# ls -alh
    total 8.0K
    drwxr-xr-x 2 user5 user5 4.0K Dec 7 18:43 ./
    drwx--x--x 10 user5 user5 4.0K Dec 6 08:16 ../
    -rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file1.txt
    -rw-r--r-- 1 user5 user5 0 Dec 7 18:43 testfile.txt
    -rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file3.txt

  4. After locating the file, use the chmod command to edit the permissions.

    user5@example.com [~/public_html]# chmod 755 testfile.txt

  5. Lastly, we run the ls command to display the same file list. This time, the results show the file's new permissions. Again, the row is highlighted in red for you. Note the new permissions, -rwxr-xr-x are in the modal format for 755.

    user5@example.com [~/public_html]# ls -alh
    total 8.0K
    drwxr-xr-x 2 user5 user5 4.0K Dec 7 18:43 ./
    drwx--x--x 10 user5 user5 4.0K Dec 6 08:16 ../
    -rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file1.txt
    -rwxr-xr-x 1 user5 user5 0 Dec 7 18:43 file2.txt*
    -rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file3.txt


As you can see, testfile.txt's permissions were changed from 644 to 755.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Comments

n/a Points
2018-01-07 9:09 pm

Nice tutorial. But filenames do not match and therefore was a bit confusing.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}