In this tutorial, we'll show you how you can edit file permissions and adjust file ownership settings while in SSH. This is not the only way to change permissions settings however, it can be done within your cPanel's File Manager as well.

Changing File Permissions

The chmod command is used to change file permissions. The basic syntax is:

chmod ### file/folder

We'll now show you the command in action. We'll first log into our account via SSH and use the pwd command to see which folder we're in. We'll then run the ls command to see the current files and their permissions, run the chmod command to edit permissions, and then finally use ls again to see that the permissions have been changed.

user5@yourdomain.com [~/testa]# pwd
/home/user5/testa

user5@yourdomain.com [~/testa]# 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 file2.txt
-rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file3.txt

user5@yourdomain.com [~/testa]# chmod 755 file2.txt

user5@yourdomain.com [~/testa]# 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, file2.txt was changed from 644 to 755.

Changing File Ownership Settings

The chown command is used to change file ownership settings. The basic syntax is:

chown user:user file/folder

The act of changing permissions is much more common than changing ownership. One reason is that most of the time you'll need root access to use chown, and root access is not given by default to accounts.

In the example below, we'll log into our account via SSH and change the ownership settings from user5:user5 to user5:nobody for the file file2.txt.

root@yourdomain.com [/home/user5/testa]# pwd
/home/user5/testa

root@yourdomain.com [/home/user5/testa]# 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

root@yourdomain.com [/home/user5/testa]# chown user5:nobody file2.txt

root@yourdomain.com [/home/user5/testa]# 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 nobody 0 Dec 7 18:43 file2.txt*
-rw-r--r-- 1 user5 user5 0 Dec 7 18:43 file3.txt

There are many more ways you can use chown and chmod other than the basic examples we've listed above. Usually if you need a way to get something done, there are additional options you can use to get it done. If you need assistance, feel free to post in the comments and we'll show you how you may be able to do it!

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!

Like this Article?

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!
Ask a Question

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.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

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

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!