Bird
Raised Fist0
Linux CLIscripting~5 mins

Numeric permission mode (755, 644) in Linux CLI - Commands & Configuration

Choose your learning style10 modes available
Introduction
Files and folders on Linux have permissions that control who can read, write, or run them. Numeric permission modes like 755 or 644 are a simple way to set these permissions quickly using numbers.
When you want to make a script executable by everyone but only editable by you.
When you want a file to be readable by everyone but only writable by the owner.
When setting permissions on a website folder so the server can read files but users cannot change them.
When you need to quickly fix permission issues on files or directories.
When automating permission settings in scripts or deployment processes.
Commands
This command sets the permissions of 'myscript.sh' so the owner can read, write, and execute it, while others can read and execute it. This is common for executable scripts.
Terminal
chmod 755 myscript.sh
Expected OutputExpected
No output (command runs silently)
This command lists the details of 'myscript.sh' including its permissions, so you can verify the changes made by chmod.
Terminal
ls -l myscript.sh
Expected OutputExpected
-rwxr-xr-x 1 user user 0 Apr 27 12:00 myscript.sh
→
-l - Shows detailed information including permissions, owner, size, and modification date.
This command sets the permissions of 'document.txt' so the owner can read and write it, but others can only read it. This is typical for text files.
Terminal
chmod 644 document.txt
Expected OutputExpected
No output (command runs silently)
This command shows the permissions and details of 'document.txt' to confirm the permission changes.
Terminal
ls -l document.txt
Expected OutputExpected
-rw-r--r-- 1 user user 0 Apr 27 12:01 document.txt
→
-l - Displays detailed file information including permissions.
Key Concept

If you remember nothing else from this pattern, remember: numeric modes like 755 and 644 are shorthand to quickly set who can read, write, or execute files.

Common Mistakes
Using chmod 755 on a file that should not be executable.
This makes the file executable by everyone, which can be a security risk or cause errors if the file is not a script or program.
Use chmod 644 for files that only need to be read and written by the owner, not executed.
Forgetting to check permissions after using chmod.
You might think permissions changed correctly but they did not, leading to access problems.
Always run ls -l to verify permissions after changing them.
Summary
chmod 755 sets a file to be executable by the owner and readable/executable by others.
chmod 644 sets a file to be readable and writable by the owner, readable by others, but not executable.
Use ls -l to check and confirm file permissions after changes.

Practice

(1/5)
1. What does the numeric permission mode 755 mean for a file in Linux?
easy
A. User can read, write, execute; group and others can read and execute
B. User can read and write; group and others can only read
C. User, group, and others can read, write, and execute
D. User can read and execute; group and others have no permissions

Solution

  1. Step 1: Understand numeric permission digits

    Each digit represents permissions for user, group, and others respectively. 7 means read(4)+write(2)+execute(1)=7, 5 means read(4)+execute(1)=5.
  2. Step 2: Decode 755

    User (7) has read, write, execute; group (5) and others (5) have read and execute only.
  3. Final Answer:

    User can read, write, execute; group and others can read and execute -> Option A
  4. Quick Check:

    755 = rwx r-x r-x [OK]
Hint: 7 means full rights; 5 means read+execute only [OK]
Common Mistakes:
  • Confusing 5 with write permission
  • Thinking 7 means read+write only
  • Mixing group and others permissions
2. Which of the following is the correct command to set a file named script.sh to permission mode 755?
easy
A. chmod 644 script.sh
B. chmod 700 script.sh
C. chmod 777 script.sh
D. chmod 755 script.sh

Solution

  1. Step 1: Identify the command to change permissions

    The command to change file permissions is chmod followed by the numeric mode and filename.
  2. Step 2: Match the mode 755 with the command

    To set mode 755, use chmod 755 script.sh.
  3. Final Answer:

    chmod 755 script.sh -> Option D
  4. Quick Check:

    chmod + numeric mode + filename = chmod 755 script.sh [OK]
Hint: chmod + mode + filename sets permissions [OK]
Common Mistakes:
  • Using wrong numeric mode
  • Swapping filename and mode
  • Using chmod without mode
3. If a file has permissions set to 644, what will be the output of ls -l filename showing the permission part?
medium
A. -rw-r--r--
B. -rwxrwxrwx
C. -rwxr-xr-x
D. -rw-rw-r--

Solution

  1. Step 1: Decode numeric mode 644

    6 = read(4)+write(2), 4 = read only, so user has read/write, group and others have read only.
  2. Step 2: Translate to symbolic permissions

    Permissions are -rw-r--r-- where '-' means regular file, 'rw-' user, 'r--' group, 'r--' others.
  3. Final Answer:

    -rw-r--r-- -> Option A
  4. Quick Check:

    644 = rw- r-- r-- [OK]
Hint: 6 = rw-, 4 = r-- in permissions [OK]
Common Mistakes:
  • Confusing 4 with execute permission
  • Mixing user and group permissions
  • Assuming 644 includes execute
4. You ran chmod 755 myfile but ls -l myfile shows -rw-r--r--. What is the likely problem?
medium
A. The chmod command syntax is incorrect
B. You forgot to specify the filename
C. You do not have permission to change the file mode
D. The file is a directory, not a regular file

Solution

  1. Step 1: Understand chmod effect and output

    chmod 755 should set execute permission, but output shows no execute bits.
  2. Step 2: Identify permission issue

    If permissions did not change, likely user lacks rights to modify file mode (not owner or no sudo).
  3. Final Answer:

    You do not have permission to change the file mode -> Option C
  4. Quick Check:

    chmod no effect = permission denied [OK]
Hint: No change after chmod? Check your ownership rights [OK]
Common Mistakes:
  • Assuming syntax error
  • Thinking file type blocks chmod
  • Ignoring user permissions
5. You want to make a script file executable only by the owner and readable by everyone else. Which numeric mode should you use?
hard
A. 644
B. 744
C. 700
D. 755

Solution

  1. Step 1: Define required permissions

    Owner: executable + read + write (7), group and others: read only (4 each).
  2. Step 2: Construct numeric mode

    Owner = 7 (rwx), group = 4 (r--), others = 4 (r--), so mode is 744.
  3. Final Answer:

    744 -> Option B
  4. Quick Check:

    744 = rwx r-- r-- [OK]
Hint: Owner full, others read only = 744 [OK]
Common Mistakes:
  • Choosing 755 which allows execute for others
  • Using 700 which denies read for others
  • Confusing 644 with execute permission
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard