Back to Blog
Lesson 16 of the Linux: Linux Command Line for Developers course
LinuxAugust 3, 20264 min read

File Permissions Fundamentals: Decoding Linux Access Controls

Learn to read Linux file permissions strings. Master the 'rwx' format for owners, groups, and others to secure your server and control file access effectively.

linuxpermissionssecuritycommand-linesystem-administration
Neatly arranged blue office binders labeled with dates and names for organized storage.

Previously in this course, we covered Understanding Users and Groups in Linux, where you learned how the system categorizes actors. This lesson builds on that foundation by teaching you how the system enforces rules on what those users can actually do with files.

The Anatomy of a Permission String

When you run ls -l (which we explored in Listing and Inspecting Files), you see a ten-character string at the beginning of each line. This is your primary window into Linux security.

A typical string looks like this: -rwxr-xr--

We break this down into four distinct parts:

  1. The File Type (Position 1): A - means a regular file. A d indicates a directory.
  2. Owner Permissions (Positions 2-4): What the person who owns the file can do.
  3. Group Permissions (Positions 5-7): What members of the file's assigned group can do.
  4. Others Permissions (Positions 8-10): What everyone else on the system can do.

Decoding the "rwx" Triad

Each of these groups (Owner, Group, Others) uses the same three-letter code:

CharacterMeaningImpact on FilesImpact on Directories
rReadCan open and view contentCan list files inside
wWriteCan modify or delete contentCan create or delete files inside
xExecuteCan run as a program/scriptCan "enter" (cd into) the directory

If a character is replaced by a hyphen (-), that specific permission is disabled. For example, r-- means read-only.

Concrete Example: Analyzing a Web Config

In our project, we have a configuration file for our web server. Let’s look at its permissions:

Bash
-rw-r----- 1 webadmin webgroup 1024 Jan 10 10:00 config.conf

Let's break this down:

  • -: It is a regular file.
  • rw- (Owner): The user webadmin can read and edit this file. They cannot execute it, which is correct for a config file.
  • r-- (Group): Any user in webgroup can read the file, but they cannot change it.
  • --- (Others): Everyone else has zero access. This is a secure configuration; we don't want unauthorized users snooping on our server settings.

Hands-on Exercise: Inspecting Your Project

You previously set up your project directories in Project Kickoff: Provisioning Web Server Directories. Let’s check the current state of those folders.

  1. Navigate to your project root.
  2. Run ls -ld logs/ to see the directory's permission string.
  3. Identify: Who is the owner? What are the permissions for "Others"?
  4. Consider this: If "Others" has r-x on your log directory, what does that imply about security? (Hint: It means anyone on the system can list your log files).

Common Pitfalls

  • Confusing r with x on Directories: A common mistake is thinking you only need r to access a directory. In Linux, you need x (execute) to "enter" or cd into a directory. You can have r (read) without x, which lets you see the list of files, but not actually access their metadata or content.
  • Assuming Owner = Root: Just because you are the owner of a file doesn't mean you have rwx. You can explicitly remove your own write permissions (e.g., chmod u-w file). However, as the owner, you can always change the permissions back to give yourself access again.
  • Ignoring the "Others" bucket: Beginners often focus on the owner and group but forget that others applies to every user on the system, including potentially malicious actors or automated service accounts. Always default to --- for others unless you have a specific reason to share.

FAQ

Q: Can I change these strings? A: Yes, we will cover the chmod command in the next lesson to modify these permissions.

Q: What if I see rws or rwt? A: Those represent special permissions like SUID or the sticky bit, which we discuss in Linux File Permissions: Mastering ACLs and Sticky Bits.

Q: Does changing permissions fix my "Permission Denied" errors? A: Usually, yes. If you get a "Permission Denied" error, it means your current user account doesn't have the required bits (r, w, or x) for the action you are attempting.

Recap

We've moved from simply seeing files to understanding the gatekeepers of the Linux filesystem. By parsing the rwx string, you can audit your server's security and determine exactly who has access to your application's data. Remember: ownership is about identity, while the permission string is about capability.

Up next: We will take these concepts and learn how to actually change permissions using the chmod command.

Similar Posts