Bird
Raised Fist0
Linux CLIscripting~10 mins

Permission types (read, write, execute) in Linux CLI - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Permission types (read, write, execute)
Start
↓
Check Permission Type
↓
Read?
Yes→Allow reading file
↓
Check Write
↓
Write?
Yes→Allow writing file
↓
Check Execute
↓
Execute?
Yes→Allow execute
↓
Deny Access
↓
End
The system checks if a user has read, write, or execute permission on a file and allows or denies access accordingly.
Execution Sample
Linux CLI
ls -l example.txt
# Output: -rwxr--r-- 1 user group 0 Apr 27 12:00 example.txt
Shows the permission types for the file example.txt
Execution Table
StepPermission StringCheckResultAction
1-rwxr--r--Read permission (r) for owner?YesAllow reading
2-rwxr--r--Write permission (w) for owner?YesAllow writing
3-rwxr--r--Execute permission (x) for owner?YesAllow execute
4-rwxr--r--Read permission for group?YesAllow reading
5-rwxr--r--Write permission for group?NoDeny writing
6-rwxr--r--Execute permission for group?NoDeny execute
7-rwxr--r--Read permission for others?YesAllow reading
8-rwxr--r--Write permission for others?NoDeny writing
9-rwxr--r--Execute permission for others?NoDeny execute
10-All checks done-End
💡 All permission checks completed for owner, group, and others.
Variable Tracker
Permission TypeStartOwnerGroupOthers
Read?YesYesYes
Write?YesNoNo
Execute?YesNoNo
Key Moments - 3 Insights
Why does the group have read permission but no write or execute?
Because in the permission string '-rwxr--r--', the group section 'r--' means read only, no write (w) or execute (x). See execution_table rows 4,5,6.
What does the first character '-' mean in the permission string?
It indicates the file type; '-' means a regular file. This is important but separate from permission bits. See execution_sample.
Why can others read but not write or execute?
Because the last three characters 'r--' in the permission string show read permission only for others. See execution_table rows 7,8,9.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, does the owner have execute permission?
AYes, owner can execute
BNo, owner cannot execute
COnly group can execute
DOnly others can execute
💡 Hint
Check the 'Result' column at step 3 in execution_table
At which step does the group fail to have write permission?
AStep 4
BStep 5
CStep 6
DStep 7
💡 Hint
Look at the 'Check' and 'Result' columns for group write permission in execution_table
If the permission string changed to '-rwxrwxr-x', what would be true?
AOwner has no read permission
BGroup has no write permission
COthers have execute permission
DOthers have write permission
💡 Hint
Compare the permission string pattern with the original in variable_tracker
Concept Snapshot
Permission types control file access:
- Read (r): allows viewing file contents
- Write (w): allows modifying file
- Execute (x): allows running file
Permissions shown as rwx for owner, group, others
Check permissions with 'ls -l' command
Full Transcript
This lesson shows how Linux file permissions work using read, write, and execute types. The system checks each permission type for owner, group, and others. The permission string like '-rwxr--r--' shows which permissions are granted. For example, owner has read, write, execute; group has read only; others have read only. We traced each permission check step by step. Key points include understanding the permission string layout and what each letter means. The visual quiz tests your understanding of permission checks and changes.

Practice

(1/5)
1. Which permission allows you to open and view the contents of a file in Linux?
easy
A. Read permission
B. Write permission
C. Execute permission
D. Delete permission

Solution

  1. Step 1: Understand the meaning of read permission

    Read permission allows a user to open and view the contents of a file without changing it.
  2. Step 2: Compare with other permissions

    Write permission allows changing the file, execute permission allows running the file as a program, and delete is not a standard permission type.
  3. Final Answer:

    Read permission -> Option A
  4. Quick Check:

    Read = open/view file [OK]
Hint: Read means open and see file contents [OK]
Common Mistakes:
  • Confusing write with read permission
  • Thinking execute lets you open files
  • Assuming delete is a permission type
2. Which of the following is the correct symbolic representation for write permission in Linux file permissions?
easy
A. w
B. e
C. x
D. r

Solution

  1. Step 1: Recall symbolic letters for permissions

    In Linux, 'r' stands for read, 'w' for write, and 'x' for execute permission.
  2. Step 2: Identify the write permission symbol

    The letter 'w' is used to represent write permission.
  3. Final Answer:

    w -> Option A
  4. Quick Check:

    Write permission symbol = w [OK]
Hint: Write permission is always 'w' in Linux [OK]
Common Mistakes:
  • Mixing 'r' and 'w' symbols
  • Using 'e' which is not a permission symbol
  • Confusing execute 'x' with write
3. What will be the output of the command ls -l script.sh if the permissions shown are -rwxr--r--?
medium
A. Owner can read only; group can write only; others can execute only
B. Owner can read and write only; group can execute only; others can write only
C. Owner can execute only; group can read and write; others can execute only
D. Owner can read, write, execute; group can read only; others can read only

Solution

  1. Step 1: Break down the permission string

    The string '-rwxr--r--' means: owner has read (r), write (w), execute (x); group has read (r) only; others have read (r) only.
  2. Step 2: Match permissions to options

    Owner can read, write, execute; group can read only; others can read only correctly describes these permissions. Other options incorrectly assign write or execute permissions to group or others.
  3. Final Answer:

    Owner can read, write, execute; group can read only; others can read only -> Option D
  4. Quick Check:

    rwx r-- r-- = Owner rwx, group r, others r [OK]
Hint: r = read, w = write, x = execute in order [OK]
Common Mistakes:
  • Misreading group or others permissions
  • Confusing execute with write
  • Ignoring the first dash meaning file type
4. You run chmod u+x file.txt but still cannot execute the file. What is the most likely reason?
medium
A. The file is not owned by you
B. The file does not have execute permission for others
C. The file is not a script or executable program
D. You forgot to add read permission

Solution

  1. Step 1: Understand what chmod u+x does

    This command adds execute permission for the file owner (user).
  2. Step 2: Consider why execution might still fail

    If the file is not a script or executable program, adding execute permission won't let you run it.
  3. Final Answer:

    The file is not a script or executable program -> Option C
  4. Quick Check:

    Execute permission needs executable content [OK]
Hint: Execute permission needs executable content, not just flag [OK]
Common Mistakes:
  • Assuming ownership blocks execution
  • Thinking others' execute permission is needed
  • Confusing read permission with execute
5. You want to allow a group to modify a file but not execute it. Which chmod command sets read and write permissions for the group only, leaving others unchanged?
hard
A. chmod o=rw file.txt
B. chmod g=rw file.txt
C. chmod g+rwx file.txt
D. chmod u=rw file.txt

Solution

  1. Step 1: Understand chmod symbolic mode

    "g=rw" sets group permissions to read and write only, removing execute if present.
  2. Step 2: Check other options

    chmod g+rwx file.txt adds execute permission, which is not wanted. chmod o=rw file.txt changes others' permissions, and chmod u=rw file.txt changes user permissions.
  3. Final Answer:

    chmod g=rw file.txt -> Option B
  4. Quick Check:

    g=rw sets group read/write only [OK]
Hint: Use g=rw to set group read/write without execute [OK]
Common Mistakes:
  • Using g+rwx adds execute permission
  • Changing user or others instead of group
  • Using + instead of = to overwrite permissions
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