Understanding chmod Without Memorizing Numbers

2026年8月17日2 次浏览来源:Dev.to阅读原文

How Linux file permissions actually work under the hood, why symbolic mode is your best friend, and how to stop blindly typing chmod

777.

Every Linux engineer has been there.

You write a brand-new bash script, try to run it from your terminal, and hit an immediate roadblock: You open your search engine or ask a chat assistant for help.

Within seconds, you find an answer that tells you to run: You run the command, hit enter, and the script runs.

Problem solved, right?

Not quite.

In fact, you just opened the digital front door of that file to every single user and background service on the entire operating system.

When I started managing Linux servers years ago, permissions felt like a strange puzzle of three-digit math problems.

People kept throwing numbers around: for scripts, for web pages, for SSH keys, and whenever something broke and nobody knew why.

I memorized those numbers like cheat codes in a video game.

But whenever I had to handle a real permission problem, like giving a development team write access to a shared log folder without letting them delete each other's files, memorized numbers fell apart.

Here is the secret: you do not need to do binary math or memorize three-digit codes to master Linux permissions.

Linux has a built-in, human-readable permission syntax called symbolic mode.

Once you understand how Linux looks at files, who owns them, and what actions each permission controls, becomes one of the most intuitive tools in your terminal.

Let's break down how it all works step by step.

1.

What chmod Actually Does The name stands for change mode.

In Unix and Linux systems, every single file and directory has a "mode".

That mode determines who is allowed to read it, write to it, or run it.

When you run , you are simply updating those access bits inside the Linux filesystem inode.

To see the current mode of your files, open any terminal and run : Look at that strange 10-character string on the far left, like .

That single string tells you everything you need to know about the file.

Let's dissect it.

2.

Breaking Down the 10-Character Permission String The 10 characters at the start of an line look intimidating at first.

But when you split them into four distinct parts, they make total sense.

Here is how the string is organized: Position 1 (File Type): Positions 2, 3, 4 (User / Owner): Positions 5, 6, 7 (Group): Positions 8, 9, 10 (Others / World): Let's inspect each of these four parts.

The First Character: File Type The very first character tells you what kind of item you are looking at: = A regular file (a text document, an image, a binary program, or a shell script). = A directory (a folder). = A symbolic link (a shortcut pointing to another file or path). = A character device file (like a terminal tty or ). = A block device file (like a hard disk partition under ). = A local Unix domain socket. = A named pipe (FIFO).

Most of the time, you will see for files and for directories.

The Three Permission Roles (The "Who") The remaining 9 characters are divided into three equal triplets of 3 characters each.

They answer the question: Who gets access?

User (): The individual user account that owns the file.

This is usually the person or service account that created it.

Group (): The group of users assigned to the file.

Anyone who belongs to this group shares these permissions.

Others (): Everyone else.

Any user account on the machine that is neither the owner nor a member of the file's group.

The Three Basic Permissions (The "What") Inside each triplet, you will see three letters, or a dash () if that permission is turned off: = Read permission.

Allows reading the file or listing directory contents. = Write permission.

Allows modifying the file or creating/deleting items in a directory. = Execute permission.

Allows running the file as a program or entering a directory. = Permission denied.

That specific action is turned off.

Now look back at : The owner () has : can read, write, and execute.

The group () has : can rea

分享