0Pricing
Cyber Security Academy · Lesson

File Permissions and Ownership

Master chmod, chown, sticky bit, SUID/SGID, and how permissions prevent unauthorized access.

File Permissions and Ownership is a free Cyber Security Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cyber Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Permissions Matter

File permissions control who can read, write, or execute a file. Misconfigured permissions are one of the most common causes of privilege escalation and data breaches.

The Permission String Explained

When you run ls -la, each file shows a 10-character permission string like -rwxr-xr--. Break it into: file type, owner permissions, group permissions, others permissions.

$ ls -la /etc/passwd
-rw-r--r-- 1 root root 2847 Jan 10 10:00 /etc/passwd
# -  = regular file
# rw- = owner (root) can read+write
# r-- = group can read only
# r-- = others can read only

Numeric (Octal) Permissions

Permissions can also be expressed as octal numbers: read=4, write=2, execute=1. Add them up for each category.

# rwxr-xr-- = 754
# rw-rw-r-- = 664 (world-readable, group-writable)
# rwx------ = 700 (private executable)

Changing Permissions: chmod

Use chmod to modify permissions. You can use symbolic mode (u+x) or octal mode (755).

$ chmod 755 script.sh      # rwxr-xr-x
$ chmod u+x script.sh      # add execute for owner
$ chmod o-r secret.txt     # remove read for others
$ chmod 600 id_rsa         # SSH key: owner read/write only

Changing Ownership: chown

The chown command changes the owner and/or group of a file. Only root can change ownership to another user.

$ chown user:group file.txt
$ chown root:root /etc/shadow
$ chown -R www-data:www-data /var/www/html/

Special Permissions: SUID, SGID, Sticky Bit

SUID (Set User ID) makes a file run as the owner's privileges. SGID on directories means new files inherit the group. Sticky bit prevents deletion by non-owners.

$ ls -la /usr/bin/passwd
-rwsr-xr-x 1 root root 68208 /usr/bin/passwd
# The "s" in owner execute position = SUID
# This runs as root regardless of who calls it

Finding SUID Binaries (Privesc)

Attackers search for SUID binaries to escalate privileges. Any SUID binary with a known exploit or misuse can grant root access.

$ find / -perm -4000 -type f 2>/dev/null
/usr/bin/passwd
/usr/bin/sudo
/usr/bin/pkexec
/bin/mount

The /etc/shadow File

/etc/shadow stores hashed passwords and is readable only by root. If you can read it, you can attempt offline cracking with hashcat or john.

$ ls -la /etc/shadow
-rw-r----- 1 root shadow 1423 Jan 10 /etc/shadow
# Only root and the shadow group can read this

umask: Default Permission Mask

The umask value is subtracted from 666 (files) or 777 (dirs) to set default permissions for new files. A umask of 022 means new files are 644.

$ umask
0022
$ touch newfile
$ ls -la newfile
-rw-r--r-- 1 user user 0 newfile  # 666 - 022 = 644

Access Control Lists (ACLs)

ACLs extend the traditional Unix permission model to allow per-user permissions beyond the owner/group/other triad. Use getfacl and setfacl.

$ getfacl /var/www/html/
# file: var/www/html/
# owner: root
# group: www-data
user::rwx
group::r-x
other::r-x

Immutable Files: chattr

The chattr +i command makes a file immutable — even root cannot modify or delete it. Rootkits use this to protect their files. Check with lsattr.

$ chattr +i /etc/passwd   # make immutable
$ lsattr /etc/passwd
----i--------e-- /etc/passwd
$ chattr -i /etc/passwd   # remove immutability

Quick Check

What does SUID permission allow?

Summary: File Permissions

Master chmod, chown, and understanding SUID. In CTFs and real penetration tests, SUID misconfigurations are among the most common paths to root. Always check permissions on sensitive files.

Frequently asked questions

Is the “File Permissions and Ownership” lesson free?

Yes — the full text of “File Permissions and Ownership” is free to read here on the web, and the Cyber Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cyber Security Academy course, upgrade to CoddyKit PRO.

What will I learn in “File Permissions and Ownership”?

Master chmod, chown, sticky bit, SUID/SGID, and how permissions prevent unauthorized access. You practise Cyber Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cyber Security Academy?

No prior experience is required. Cyber Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “File Permissions and Ownership” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cyber Security Academy lesson?

Yes. Every Cyber Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. File Permissions and Ownership
  2. User and Group Management
  3. SSH Hardening and Key-Based Auth
  4. iptables and UFW Firewall Rules
← Back to Cyber Security Academy