๐Ÿง How to Use Linux chmod Command (Octal Permissions) | ๐Ÿš€ Includes Practice Questions

Information Processing EngineerLinuxchmodLinux Master
Read in about 2 min read
Published: 2025-07-13
Last modified: 2025-07-13
View count: 32

Summary

Learn how to set file and directory access permissions using the octal notation of the Linux chmod command, a common topic in the Information Processing Engineer exam.

๐Ÿ’ก What is the chmod command?

chmod, short for 'change mode', is a command in Linux and Unix-like operating systems used to change the access permissions of files or directories. In the Information Processing Engineer practical exam, you are often asked to grant specific permissions and construct the command using octal notation.

๐Ÿ”‘ Types and Targets of Access Permissions

To understand chmod, you first need to know the types of permissions and to whom they apply.

1. Types of Permissions

PermissionSymbolDescriptionOctal Value
ReadrRead file content or view directory listings4
WritewModify/delete file content, or create/delete files in a directory2
ExecutexExecute a file or access a directory (cd)1

2. Permission Targets

TargetSymbolDescription
UseruThe user who owns the file
GroupgThe group the file belongs to
OthersoAll other users

๐Ÿ”ข Setting Permissions with Octal Notation

The core of the chmod command is its octal notation. You create a permission combination by adding the numeric values assigned to each permission (r, w, x).

  • r (Read) = 4
  • w (Write) = 2
  • x (Execute) = 1

For example, read and write permissions (rw-) are 4 + 2 = 6.

OctalPermission Combination (rwx)Description
7rwxFull read, write, and execute
6rw-Read and write
5r-xRead and execute
4r--Read-only
3-wxWrite and execute
2-w-Write-only
1--xExecute-only
0---No permissions

The command is structured as chmod [user][group][others] [filename]. For example, chmod 754 file.txt means:

  • User (7): rwx (read+write+execute)
  • Group (5): r-x (read+execute)
  • Others (4): r-- (read-only)

๐Ÿ“ Practice Problems for the Information Processing Engineer Exam

Problem 1

ProblemOn a Linux system, you need to change the access permissions for `report.txt` as follows. Complete the `chmod` command using octal notation. - User: Read and write permissions - Group: Read permission - Others: No permissions
Your Answer
Correct AnswerReveal Answer
Problem Solution

Convert the permissions for each target into octal numbers.

  1. User: Read(4) + Write(2) = 6
  2. Group: Read(4) = 4
  3. Others: No permissions = 0

Combining these numbers gives 640. Therefore, the full command is:

bash
chmod 640 report.txt

Problem 2

ProblemThere is a shell script file named `script.sh`. The file's owner should have all permissions, while the group and others should only have read and execute permissions. Write the `chmod` command to set these permissions.
Your Answer
Correct AnswerReveal Answer
Problem Solution

Convert the permissions for each target into octal numbers.

  1. User: Read(4) + Write(2) + Execute(1) = 7
  2. Group: Read(4) + Execute(1) = 5
  3. Others: Read(4) + Execute(1) = 5

Combining these numbers gives 755. Therefore, the full command is:

bash
chmod 755 script.sh

โžก๏ธ Recommended Next Post