A process running as root can bypass many ordinary file permission checks, yet it cannot automatically write through a read-only mount. The common claim that “root can modify any file” confuses file ownership checks with filesystem-wide write protection.
Consider a service trying to update /etc/app/config.json. The file may display permissive metadata:
-rw-rw-rw- 1 root root 2048 Nov 9 10:00 config.json
Despite those mode bits, an attempted write can still fail:
open: Read-only file system
The important clue is the error itself. “Permission denied” usually indicates an access-control decision involving mode bits, ownership, an ACL, or a security policy. “Read-only file system” means the kernel found the path through a mount that does not permit modification.
Linux evaluates these concerns at different layers. An inode carries familiar information such as owner, group, and permission bits. A mount describes how a filesystem is attached at a particular location in the directory tree. That mount can be marked read-only independently of the permissions stored on its files.
Root commonly has the CAP_DAC_OVERRIDE capability, which can bypass discretionary access-control checks. That capability may allow a process to ignore a missing write bit. It does not turn a read-only mount into a writable one. Operations that would modify the mounted filesystem—writing file contents, creating entries, renaming files, or deleting them—are rejected before permissive file modes can help.
This distinction is especially visible in containers. A container process may report user ID zero while still lacking the capabilities needed to alter mount configuration. Its root filesystem, a bind-mounted configuration directory, or an injected file may have been mounted read-only by the runtime. Running chmod 777 inside the container changes nothing when the mount itself forbids writes. The command may even fail for the same reason.
Making the path writable requires changing the mount arrangement, not loosening the file’s permissions. On a regular Linux host, that might mean remounting the filesystem read-write after verifying why it became read-only. Some filesystems switch to read-only mode after detecting serious errors, so immediately forcing a remount can hide an underlying storage problem. In a container, the appropriate change is usually made in the container configuration by replacing a read-only mount with a writable one. That action may be unavailable from inside the container by design.
The quickest diagnostic is to inspect the mount containing the failing path rather than stopping at ls -l. Tools such as findmnt -T /etc/app/config.json reveal the relevant mount and its options. The target path matters because the same underlying filesystem can appear at multiple locations with different mount attributes.
Root is powerful within Linux’s permission model, but it is not a universal override switch. A read-only mount is a property of the path’s mounted filesystem view, and file mode bits cannot cancel it.
Top comments (0)