Site icon Sudhanshu's Blog

What does chmod 777 mean in Linux?

chmod stands for change mode and it is used for changing the mode of access where as 777 is the ‘Octal Value’ of the file or directory permission. Here we discuss how to set read-write permissions for the web server.

// USING OCTAL VALUE

// chmod [option] mode file
$ chmod -R 754 /path/to/your/directory
$ chmod 777 /path/to/your/file

// USING SYMBOLIC VALUE

// chmod [option] {u,g,o}{+,-,=}{r,w,x} /path/to/file
$ chmod -v u+rw /path/to/file
$ chmod -cR g+w /path/to/directory

The digits 7, 5, and 4 each individually represent the permissions for the user, group, and others. Each digit is a combination of the numbers 421, and 0:

So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).

Each digit of the permissions number is a sum of 4, 2, 1 and 0:

In the example below we have ‘Sybmolic Value’ where File, as denoted by the leading “-” within it’s symbolic value -rwxrwxrwx and Directory, as denoted by the leading “d” within it’s symbolic value drwxrwxrwx

$ ls -l
-rw-rw-rw-   1 sudhanshubajaj  admin    1370 Oct 30  2019 index.php
drwxrwxrwx   5 sudhanshubajaj  admin     160 Oct 30  2019 lib
-rw-rw-rw-   1 sudhanshubajaj  admin    5742 Oct 30  2019 nginx.conf.sample
-rw-rw-rw-   1 sudhanshubajaj  admin    1416 Oct 30  2019 package.json.sample
drwxrwxrwx   5 sudhanshubajaj  admin     160 Oct 30  2019 phpserver
drwxrwxrwx  14 sudhanshubajaj  admin     448 Jan  6 11:33 pub

r stands for read, w stands for write and x stands for execute.

Magento File system permission.

$ cd <magento_root>
$ find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} +
$ find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} +
$ chmod u+x bin/magento

where permission MODE to apply(+), remove (-) or match (=)

Exit mobile version