If you have ever worked on a website, there is a good chance that you have had problems with file permissions. In this article, I’m going to walk you through how to reset file permissions on your whole site to the recommended standard file permissions via linux command line.
- The first step in this process is to connect to the server via a terminal program. The standard today is to use Secure Shell (SSH) to connect to a server via terminal. SSH is an encrypted (secure) way to connect to a server and view a terminal screen. The SSH client that I use is called Putty. It’s free, and works very well. I link mine together with my FTP/SCP client program, WinSCP.
I’m not going to cover how to use Putty or WinSCP in this brief tutorial, but you will need to use a terminal client such as putty to connect to your linux server. - Next, type the following command to set all of the file permissions of every file in your account to 644.
chmod -R 644 *
This command will change the permissions on the file to be writeable and readable (6) by you, and readable (4) by other members of the group you belong to and the rest of the world. The readable by everybody is especially important because on a web site, you need to make the files viewable to the world. And if you want plugins to function correctly, the files need to be editable by you.
- Next, type the following command to set all of the directory/folder permissions of every file in your account to 755. (or copy and paste)
find . -type d -exec chmod 0755 {} \;
This searches through all of the files in your site and sets the directory permissions to 755 – Read/Write/Execute for you, and Read/Execute for group and world (everyone except you.) In the Linux/Unix world directories must be executable or nobody will be able to access them.
I hope this tutorial on resetting file permissions is useful for you.
Leave a Reply