What is the meaning of "chmod 666"?

47

25

I am using Linux. What is the meaning of chmod 666?

Seno

Posted 2011-06-10T19:47:14.500

Reputation: 605

useless command, since the third argument is not given ^^ – kokbira – 2019-02-04T15:15:34.587

also it can produce security flaws (all users can write the file/folder) or useless file/folder permissions – kokbira – 2019-02-04T15:17:35.103

28aka, the Satan command. – Moab – 2011-06-10T21:29:24.723

6If that bothers you (or if you can't be bothered to remember those numbers) you can also write it as chmod a=rw. – starblue – 2011-06-11T06:48:51.763

Answers

114

chmod command change attributes from a file/folder:

  • chmod 666 file/folder means that all users can read and write but cannot execute the file/folder;
  • chmod 777 file/folder allows all actions for all users;
  • chmod 744 file/folder allows only user (owner) to do all actions; group and other users are allowed only to read.

    permission to:  user(u)   group(g)   other(o)     
                    /¯¯¯\      /¯¯¯\      /¯¯¯\
    octal:            6          6          6
    binary:         1 1 0      1 1 0      1 1 0
    what to permit: r w x      r w x      r w x
    
    binary         - 1: enabled, 0: disabled
    
    what to permit - r: read, w: write, x: execute
    
    permission to  - user: the owner that create the file/folder
                     group: the users from group that owner is member
                     other: all other users
    

Alternatively, you can execute the command with a more intuitive syntax, without needing to think in binary or octal (but the knowledge of numeric syntax is so important): chmod u=rw, g=rw, o=rw file/folder

Remember that the permission changes with chmod command requires at least 3 arguments, so chmod 666 does nothing without explicit file/folder to change permissions.

Also be sure to criticize if is does not produce insecure issues or simply if it is an useless permission change, because chmod 666 will allow file/folder write to all and the execution to none.

kokbira

Posted 2011-06-10T19:47:14.500

Reputation: 4 883

What's the difference between an owner and a group? – Kyle Vassella – 2017-11-22T17:02:05.403

1@KyleVassella, owner is the owner of file or folder, generally the one that created it. group is the group of users associated with that file or folder, generally the group that owner is in. So imagine that I am rootbira and my groop is rootusers and you are on that group too, and all other SU forum members are in other group. If I create a file and do a with chmod 750, I would read, write and execute it, you would only read and execute and SU users won't do anything - it is our secret ¬¬ – kokbira – 2017-11-22T19:53:32.547

5Only it's "octal", not "decimal". +1 anyway. – Ben Voigt – 2011-06-11T14:15:33.033

3It only goes to 7 anyway, so there's no difference between octal and decimal in this case. :/ – Rob – 2012-08-29T16:49:49.280

1The third point mentioned in the first post is incorrect - chmod 711 allows only owner to do all actions, group and other are allowed only to read ![enter image description here][1] This is the table for rwx for octal rwx 000 001 010 011 100 101 110 111 Octal 001, or 1 denotes execute permission Octal 7, 111 denotes read write and execute permission hence 711 denotes, rwx for owner, and x for groups and others. – None – 2012-08-29T16:04:47.793

yeah, @Yash, and after 1 year, 2 months and 18 days after the original post someone saw that error :) I'll correct it to 744 on example. – kokbira – 2012-08-29T20:58:30.147

@Rob, you are right, but I do it to explicit that is a number from 0 to 7 :) as suggested by ben – kokbira – 2012-08-29T21:00:37.087

http://en.wikipedia.org/wiki/Chmod – kokbira – 2012-08-29T21:01:25.320

7

In really plain speak: it makes a file read- and write-able by the file owner, the file owner's group and every one else using the machine (all). Applied against a directory it lets everyone read (get file contents lists) of a directory and write (create, edit files in the directory) but not execute files from the directory.

For more detailed information how chmod works check out this handy tutorial.

Ian C.

Posted 2011-06-10T19:47:14.500

Reputation: 5 383

2...Don't you mean lets everyone read/write files but not execute, and let's everyone read/write files in a directory, but not list all of the files? – Earlz – 2011-06-10T20:44:32.510

2what @earlz says, plus write on a dir does not mean you can edit files there (write perms on a file does) but solely means you can create new entries (dirs, files, symlinks, etc.). Also, its nice of you to mention dirs for completeness, but 666 doesn't make sense for a dir; you'd never eliminate x for owner. – Rich Homolka – 2011-06-10T21:01:30.400

1@Earlz: thanks for that. I always forget what 666 does for dirs because, well, I never set rw- for a user on a dir. :) – Ian C. – 2011-06-10T21:04:51.277

7

As mentioned in other answers, chmod means change mode. It affects the read, write and executable permissions for the owner, group and other categories of users. The numbers that follow the command (in this case 666), indicate how those permissions are modified for the file the command is run on (for 666, it means that owner, group and other have read and write permissions, but no executable permissions).

By changing the numbers to different values you effectively change the permissions for the file. The link I've referenced above has a little tool for figuring out what values you need to put in to get the permissions scheme you're after. It also goes over the switch options available for the command and some examples to help you understand better how it works.

MaQleod

Posted 2011-06-10T19:47:14.500

Reputation: 12 560

1That is a great site. It's going in my bookmarks. Thanks! – Kirk – 2011-06-10T21:12:58.003

5

The chmod command (abbreviated from change mode) is a Unix command that lets an operator tell the system how much (or little) access it should permit to a file. Command chmod 666 means that all users will have read and write permissions.

Seno

Posted 2011-06-10T19:47:14.500

Reputation: 605

2

If your questions is more about the 666 part than the chmod part, I would refer you to The Linux Documentation Project where is a decent explanation of how file permissions work in Linux.

Kirk

Posted 2011-06-10T19:47:14.500

Reputation: 2 182