Skip to content

Chmod 777 & sudo su

chrisonside edited this page Jan 19, 2016 · 3 revisions

#Chmod 777 & sudo su

So Chmod 777 is effectively what we're doing when we type ./symfony project:permissions into the command line after checking out a new project. I came across it on the newsletter manager tool project, which required you to manually chmod the cache and logs directories (more notes on that project below).

http://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/

Unix systems (including Linux and Mac OS X) come with a file control mechanism to determine who can access a particular file or folder and what actions they can do to it. There are two parts to the file control mechanism, namely Classes and Permissions. Classes determines who can access the file while the Permissions determines the kind of action the user can do to the file.

#####There are three Classes – Owner, Group, Others.

  • The Owner is the usually the creator of the files/folders. In Linux, files or folders that you created in your Home directory are usually owned by you, unless you specifically change the ownership.
  • The Group contains a group of users who share the same permissions and user privilege.
  • Others means the general public.

#####Permissions

As for permissions, there are 3 type of actions that you can perform on a file/folder. You can either read, write or execute.

  • Read – You can only view the file, but cannot modify the content of the file. When applied on Folder, you can only view the files in the folder, but you can’t delete from or add files into the folder.
  • Write – You 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).

When you combine the Classes and the Permissions, you will be able to control who can access the file and what actions they are able to do with it.

With the basic understanding of the Classes and Permissions, let’s delve into it further and see how the “777” or “775” come about.

######In short:

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

What about the 3 digits ‘777’? Well, the first digit is assigned to the Owner, the second digit is assigned to the Group and the third digit is assigned to the Others. So for a file with ‘777’ permission, everyone can read, write and execute the file.

777 – Everyone can read write and execute. In a web server, it is not advisable to set ‘777’ permission for your files and folders as it allows anyone to add malicious code to your server. 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 WordPress)

####See more detailed notes stored securely for examples

Clone this wiki locally