Ubuntu

How does Chmod 777 Work in Linux/Ubuntu

How does Chmod 777 Work in Linux Ubuntu

Chmod (Change Mode) command enables the user to modify the access permissions of folders/directories and files in Unix-based systems such as Linux and macOS. Chmod 777 enables all permissions, i.e., read, write, and execute to everyone, i.e., user/owner, group, and others (all users).

This article will demonstrate how to change the permissions of a file and a directory by using chmod 777 command in Linux/Ubuntu 22.04 LTS:

  • What is Chmod 777 in Linux/Ubuntu?
  • How to Change File Permission Using chmod 777 in Linux/Ubuntu?
  • How to Change Directory Permission Using chmod 777 in Linux/Ubuntu?

What is Chmod 777 in Linux/Ubuntu?

Chmod 777 enables read, write, and execute permissions to everyone, i.e., owner, group, and others. More details of Linux/Ubuntu file permissions can be checked from How to Change File Permissions and Ownership in Linux/Ubuntu? The general syntax of chmod 777 command is:

$ chmod 777 <file/directory>

Where,

  • Chmod: Chmod command
  • 777: Read, Write, and Execute permission for all (user, group, and others)
  • <file/directory>: File or Directory

Additionally, 777 is calculated by:

  • The first digit 7 is the sum of 4, 2, and 1 for read, write, and execute permission for the user/owner.
  • The second digit 7 is the sum of 4, 2, and 1 for read, write, and execute permission for the users of the group.
  • The third digit 7 is the sum of 4, 2, and 1 for read, write, and execute permission for others.

How to Change File Permission Using chmod 777 in Linux/Ubuntu?

Consider we have to change the file permission of a “SampleFile.txt”. We can first view the file permissions of it by executing the “ls” command as follows:

$ ls -l

In the above image, we can see that the permission of “SampleFile.txt” is “-rw-rw-r–”, i.e., this file has read, and write permission for user(u); read, write permission for group (g) and read permission for others(o). We can change permission by running chmod 777 command:

$ chmod 777 SampleFile.txt

From the above image, we can see that the file permissions are changed to read, write, and execute for user(u), group(g), and others(o).

How to Change Directory Permission Using chmod 777 in Linux/Ubuntu?

Consider we have to change the permission of a directory “Files1”. We can first view the permissions associated to it by using the ls command as follows:

$ ls -l

In the above image, we can see that the permission of “Files1” is “drwxr-xr-x”, i.e., this directory has read, write, and execution permission for the user(u); read and execution permission for the group (g) and read and execution permission for others(o). We can change permission by running chmod 777 command:

$ chmod 777 Files1

From the above image, we can see that the file permissions are changed to read, write, and execute for user(u), group(g), and others(o).

Conclusion

File/Directory read, write, and execute permissions to owner, group, and other classes are enabled using “chmod 777 <file/directory>”. This article has demonstrated how to change file and directory permissions by using the chmod 777 command in Linux/Ubuntu 22.04 LTS. Additionally, Chmod 777 is advised to be used with care as all permissions of read, write, and execute are even to everyone, user, group, and others.

Similar Posts