How to Change Some Files in your Hosting Account from Read and Write to Read Only so Your Files are Hack Proof
There are a million and one ways in which you can get hacked and even if you apply every single defense you can think about, there is no guarantee that your hosting account and the sites you host are safe. However, this doesn’t mean that there are no little steps you can (and should) take in order to defend your sites from hackers. Hosting nerds know many useful tricks and one of them is how to change some files in your hosting account from Read and Write to Read-only.
If you aren’t a hosting nerd, maybe you are wondering why you should bother changing file permissions. The answer is easy – because when your files can be modified (i.e. when you have enabled the Write permission for them), this is a security risk.
Not all files in your cpanel hosting account are subject to the same risk level and this why you need to know which files are to be modified. There are files, which are more important than others and which are easier to modify to include malicious code in them. When a hacker gets hold of such a file, he or she can add a virus code. Later on, when somebody loads your page in his or her browser, his or her computer will get infected – this is the way viruses are distributed all over the Net.
Which Files Need a Special Protection?
There isn’t a universal prescription which files need to be protected but generally the list includes host’s file, or a file with access permissions, such as the .htaccess file in your cpanel account. Files with hardcoded usernames and passwords for database access are also very vulnerable.
In addition to them, database files (i.e. those files with an .mdb extension) and .txt files are also a lucrative target for a hacker. Finally, one more group of files in need of special protection are .config files. .config files store different kinds of configuration settings and if such a file is hacked, this could cause a lot of problems for you. This is why you need to make .config files read-only as well.
How to Make Files Read-only
The exact way in which you can change a file from Read and Write to Read-only varies depending on the operating system your website hosting provider uses. Basically, if your website hosting uses cpanel hosting, you need to log in first and then you can make any changes.
If the operating system of your hosting provider is UNIX, you can change permissions with the chmod command. You can change permissions only for files you are the owner of. 777 permissions are to be avoided for any file with important data.
If your website hosting provider uses Windows and IIS, then you can change permissions to Read-only from File Manager and Explorer. You need to know that when you set permissions for a folder with subfolders, the permissions are automatically inherited – i.e. all the subfolders and the files in them inherit the permissions for the parent folder but if you need to set specific permissions for an individual files, you can do it.
