Internet Security Blog - Hackology

What is CHMOD 777

If you are webmaster managing your own website on a Linux Server ,You must have faced this error message  “You do not have permission to upload or create files here” . After some googling, the solution is “CHMOD to 777″ or CHMOD to 775” . You might be wondering what  “777” mean? And why must it be ‘7’, and why not ‘8’ or ‘9’?

What is CHMOD

On Linux, there is a set of rules for each file which defines who can access a particular file and how they can access it. These rules are known as “File Permissions” or “File Modes”. The word CHMOD stands for “Change Mode“. Its a syntax with which users can change file permissions which i will explain below.

Linux / Unix come with a file control mechanism to allow who can access a particular file or folder and what actions that user can perform. There are two parts to the file control mechanism : Classes and Permissions. Classes tell who can access the file while the Permissions determine the kind of action the user can perform on the said file.

There are three type of Classes – Owner, Group, Others.

  • Owner is the creator of the files/folders. In Linux, files or folders that you created  owned by you, unless you specifically change the ownership.
  • Group contains a group of users who share the same permissions and user privilege, these are generally the server roles aswell
  • Others means the public.

Permissions are also of three types – Read , Write , Execute.

  • Read – Only view files but cannot modify the content of the file. When this is applied on a Folder, you can only view the files inside the folder but can’t delete or add files into the folder.
  • Write – Can edit and modify the file. For Folders you can delete and add files into the folder.
  • Execute – Execute is mainly used when you need to run the file (commonly used when you need to run a script). Mostly required with Upload scripts etc

With Classes and Permissions combined we are able to control who can access the file and what actions they can perform on those files / folders

What is CHMOD 777

lets talk about “777”, “775”  and what this means as now you must be clear about the Classes and Permissions.

Every file and folder contain a 8-bit data that control the permissions. At its basic binary form, it will be “000”, which means no permissions of any form is granted. When you set a “Read” permission, it will add 4-bit to the data, making it “100” (in binary format) or a “4” in the usual decimal format. Applying a “Write” permission will add 2-bit to the data, making it “010” and “2” in decimal form. Lastly, setting an “Execute” permission adds 1-bit to the data, which will result in “001”, or “1” in decimal form. When we sum it up :

  • Read is equivalent to ‘4’.
  • Write is equivalent to ‘2’.
  • Execute is equivalent to ‘1’

Lets set some Permissions by adding up the numbers. For instance, to set the permissions to read and write, we will use ‘6’ (4 + 2) for the permission. For read, write and execute, we will use ‘7’ (4 + 2 + 1) for the permission. Here’s the detailed breakdown:

0 – no permission
1 – execute
2 – write
3 – write and execute
4 – read
5 – read and execute
6 – read and write
7 – read, write, and execute

You set the number as per the permissions you want to allocate a file or folder.

So What about three digits i.e. 777 ? First digit is assigned to the Owner, Second digit is assigned to the Group and third digit is assigned to the Others. So for a file with ‘777’ permission, everyone can read, write and execute the file. Some commonly used CHMOD permissions in Linux :

  • 755 – This permission is mostly used in web server. Owner has all the permissions to read, write and execute. Everyone else can only read and execute, but cannot write to the file (make changes).
  • 777 – Everyone can read write and execute. It is not advisable to set ‘777’ permission in a web server for your files and folders as it allows anyone to add bad code to your server (Hackers love such misconfigured permissions). However, in some cases, you will need to set the 777 permissions before you can upload any file to the server (For example, uploading images in your website)
  • 644 – Only the owner can read and write. Everyone else can only read. No one can execute the file.
  • 655 – Only the owner can read and write, but not execute the file. Everyone else can read and execute, but cannot modify the file.

How to CHMOD permissions in Linux

You can easily change the file permissions in Linux by just right-clicking the file or folder and select “Properties”. There will be a Permission tab where you can change the file permissions. You might not get a desktop interface if you have hosting , but you can achieve the same in your Hosting File Manager. You can also set permissions using a terminal, Command to use to change file permission is “chmod". Basically setting a “chmod 777” means making the file readable, writable and executable by everyone.

chmod 777 /path/to/your/file

Hopefully after reading all this you have a better understanding about CHMOD and what CHMOD 777 is and how they work in Linux environment.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Wise

Subscribe to my newsletter to get latest InfoSec / Hacking News (1 Email/week)
Utopia p2p Ecosystem

Discover more from Internet Security Blog - Hackology

Subscribe now to keep reading and get access to the full archive.

Continue reading