Menu
Coddy logo textTech

Chmod With Numbers

Part of the Fundamentals section of Coddy's Terminal journey — lesson 55 of 82.

The chmod command lets you change file permissions. One way to use it is with numeric mode, where each permission is represented by a number.

Each permission has a value: read is 4, write is 2, and execute is 1. You add these values together to create a single digit for each user category. For example, read + write + execute = 4 + 2 + 1 = 7.

NumberPermissionMeaning
7rwxread + write + execute
6rw-read + write
5r-xread + execute
4r--read only
0---no permissions

You combine three digits to set permissions for owner, group, and others. For example:

chmod 755 script.sh

This sets rwx (7) for the owner, r-x (5) for the group, and r-x (5) for others. A common permission like 644 gives the owner read and write access, while everyone else can only read the file.

challenge icon

Challenge

Easy

You have a script file deploy.sh that needs to be executable by the owner, but only readable by the group and others.

Use chmod with numeric mode to set the permissions on deploy.sh to:

  • Owner: read, write, and execute (7)
  • Group: read only (4)
  • Others: read only (4)

After setting the permissions, use ls -l deploy.sh to verify the change.

Your output should show the permission string -rwxr--r-- for the file.

Hint: The three digits you need are 744. Run chmod 744 deploy.sh followed by ls -l deploy.sh to display the updated permissions.

Cheat sheet

The chmod command changes file permissions using numeric mode, where each permission has a numeric value:

  • read = 4
  • write = 2
  • execute = 1

Add these values together to create permissions for owner, group, and others:

NumberPermissionMeaning
7rwxread + write + execute
6rw-read + write
5r-xread + execute
4r--read only
0---no permissions

Use three digits to set permissions for owner, group, and others:

chmod 755 script.sh

This sets rwx for owner, r-x for group, and r-x for others.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals