Permissions with a purpose
Read permission bits and restrict a private directory without using root.
By the end of this lesson
- Read owner, group and other permission bits
- Explain why directories need execute permission
- Set private access without granting everyone full control
Your environment: Bash and the named tools in a Linux lab. Minimal distributions may require extra packages. Setup help
Permissions answer who can do what
A long listing shows the owner and group, followed by access bits for owner, group and others. For an ordinary file, read lets you read its data and write lets you modify it. Execute permits execution when the file is a suitable program or script. Ownership and permissions are separate: changing a mode does not change who owns the file.
Directories interpret these bits differently. Read lists names; execute allows searching or traversing the directory; write usually allows creating or removing directory entries when combined with execute. Deleting a file is therefore primarily controlled by its parent directory, not just the file’s write bit.
Grant the access you actually need
Mode 600 means owner read/write and no access for group or others. Mode 700 adds owner execute, useful for a private directory. Numeric bits use read=4, write=2 and execute=1. Symbolic modes such as u=rw,go= can express the same intended file access.
Do not treat chmod 777 as a general fix. It changes the security model and may not solve ownership, ACL or SELinux problems. A restrictive umask influences permissions requested when new files are created; it does not repair files that already exist. In this exercise, work only with files you own.
See it in context
Worked example
Restrict a directory and a file separately.
mkdir -p "$HOME/training4linux/permissions-demo"
chmod 700 "$HOME/training4linux/permissions-demo"
printf "%s\n" "Practice only" > "$HOME/training4linux/permissions-demo/private.txt"
chmod 600 "$HOME/training4linux/permissions-demo/private.txt"
ls -ld "$HOME/training4linux/permissions-demo"
ls -l "$HOME/training4linux/permissions-demo/private.txt"The directory should start drwx------ and the file -rw-------. A trailing + can indicate additional ACL information.
Your turn
Practical lab
Prepare a private notes directory that your account can use.
Run commands in your own lab. This website displays instructions; the practice terminal below helps you rehearse the syntax.
1. Prepare your workspace
mkdir -p "$HOME/training4linux/access-lab"
printf "%s\n" "Not a real secret" > "$HOME/training4linux/access-lab/notes.txt"2. Complete the task
- Set the directory to owner-only read/write/execute.
- Set notes.txt to owner-only read/write.
- List both modes and explain why the directory has an x bit but the text file does not.
3. Check your result
- The directory is mode 700; notes.txt is mode 600.
- You can read your file and explain the three permission groups.
Need a hint?
Use ls -ld to inspect a directory itself instead of listing its children.
Reveal a worked solution
Compare this with your approach after trying the task. More than one valid solution may exist.
chmod 700 "$HOME/training4linux/access-lab"
chmod 600 "$HOME/training4linux/access-lab/notes.txt"
ls -ld "$HOME/training4linux/access-lab"
ls -l "$HOME/training4linux/access-lab/notes.txt"After the lab: The directory can remain private. These changes affect only your practice files.
Common mistakes to avoid
- On a Windows-mounted WSL filesystem, permission behaviour can differ. Use the Linux home filesystem for this lab.
- A mode listing alone does not describe ACLs or mandatory access controls.
Check your understanding
Knowledge check
Answer all 3 questions correctly to pass. Retry as often as you need; your best score is kept.
Your lesson progress
Not started · Best score: 0% · Attempts: 0
Practical completion is self-reported. Progress is linked to a private cookie in this browser and stored on the site. Clearing that cookie loses access to it. Manage or erase progress.