Web

Hello All!
This article is inspired by our day-to-day usage of Linux commands to tackle basic issues in website deployment on web servers. The following Linux commands, we suggest, are must know for every web developer.
CHMOD
In Linux operating systems, CHMOD command is used to change the access permissions of the file/directory of your file system. The CHMOD is an abbreviation for change mode. The Linux file system has different file permission to the various classes of users like the owner, group, and others(world). There are different Read, Write and Execute permissions for each user class of the owner, group, and others.
Syntax: chmod [options] mode[,mode] file1 [file2 ...]
Usage: [Options]:
-R
Recursive, i.e. include objects in subdirectories.-v
verbose, show objects changed (unchanged objects are not shown).
[mode]:
Mode is the main part of the CHMOD permissions. It is the octal number representation of its respective binary number permission defined in the following table for all the 3 user classes i.e., owner, group and others.
# | Permission | rwx | Binary |
---|---|---|---|
7 | read, write and execute | rwx | 111 |
6 | read and write | rw- | 110 |
5 | read and execute | r-x | 101 |
4 | read only | r– | 100 |
3 | write and execute | -wx | 011 |
2 | write only | -w- | 010 |
1 | execute only | –x | 001 |
0 | none | — | 000 |
Now, if you have to give read and execute permission to file for the owner and read-only permission for group and others then the mode will be 544.
One more example, if you have to give read, write and execute permission to the owner, read and write permission to group and read and execute for others then the mode will be 765.
[file]: File is the path to file or directory to which we have to apply for permissions.
CHMOD Settings for Web Developers:
- Standard Permissions for
Directories
to be set to755
. - Standard Permissions for
Files
to be set to644
. - Use
Write
permissions for class users of thegroup
orothers
only when you are using the file upload section.
Ex.: For Image Folder Permission to be set to766
.CHMOD -R 766 /images
- Try to avoid
Execute
permissions to thefolders
where thefiles
are uploaded because hackers can upload their infected files and try to execute them and tamper your website and data.