VIVEK PANDHARKAR Linux,Uncategorized,Web Server Basic Linux Commands Every Web Developer Must Know

Basic Linux Commands Every Web Developer Must Know

Web

Web Developer’s Basic Linux Commands

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.

#Permissionrwx Binary
7read, write and executerwx 111
6read and writerw- 110
5read and executer-x 101
4read onlyr– 100
3write and execute-wx 011
2write only-w- 010
1execute only–x 001
0none000
Permissions Table

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 to 755.
  • Standard Permissions for Files to be set to 644.
  • Use Write permissions for class users of the group or others only when you are using the file upload section.
    Ex.: For Image Folder Permission to be set to 766.
    CHMOD -R 766 /images
  • Try to avoid Execute permissions to the folders where the files are uploaded because hackers can upload their infected files and try to execute them and tamper your website and data.