In Linux, you can easily change the file permissions by right-clicking the file or folder and select “Properties”. There will be a Permission tab where you can change the file permissions. In the terminal, the command to use to change file permission is “chmod“. In short, “chmod 777” means making the file readable, writable and executable by everyone.
chmod 775 /path/to/file
Hopefully, this article can help you understand better about the file permissions in Unix system and the origin of the magical number “777”.
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. Here are some of the commonly used permissions:
755 – This set of permission is commonly used in web server. The owner has all the permissions to read, write and execute. Everyone else can only read and execute, but cannot make changes to 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)
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.