Linux File Permissions for DevOps: From chmod to Kubernetes

Linux access control doesn't disappear when infrastructure moves to containers.
A process still has an identity. A file still has ownership. A mounted volume still has access restrictions.
Understanding this relationship is essential for engineers working with modern infrastructure.
Start with the process identity
When troubleshooting a permission problem, begin by identifying the account performing the operation.
id
whoami
Next, inspect the resource:
ls -ld /path/to/directory
ls -l /path/to/file
The current shell identity may differ from the application or service identity. Make sure you investigate the actual failing process.
Decode the access policy
A mode of 640 describes the following ordinary permission bits:
| Identity | Access |
|---|---|
| Owner | Read and write |
| Group | Read |
| Others | None |
This can be appropriate for configuration files that an application must read but should not modify.
It is not enough to inspect the number alone. The correct owner and group are equally important.
Directory traversal matters
A common mistake is inspecting only the final file.
Linux also checks whether the process can traverse the directories leading to it.
Use:
namei -l /path/to/configuration
This can reveal a restrictive parent directory that would otherwise be overlooked.
SGID for collaboration
Shared deployment directories often need consistent group ownership.
An SGID directory can make newly created entries inherit the directory's group.
A mode such as 2770 is useful in an appropriately configured private team directory.
However, group inheritance doesn't automatically guarantee group write access. The creation mode, umask and applicable ACLs still matter.
Default permissions and umask
A process's umask removes permission bits during object creation.
A umask of 027 commonly produces:
- Regular files: 640
- Directories: 750
Applications can request more restrictive modes, and default ACLs can also influence the result.
The Kubernetes connection
Imagine a non-root container that starts successfully but cannot write to its persistent volume.
Changing the application to run as root might hide the immediate symptom while weakening isolation.
A Pod-level security context may help:
spec:
securityContext:
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
fsGroupChangePolicy: OnRootMismatch
This is a Pod specification fragment, not a complete deployment manifest.
The effectiveness of fsGroup depends on the volume type and CSI driver. Some drivers handle ownership themselves, and some storage configurations require separate server-side permission management.
A practical troubleshooting workflow
- Identify the failing operation.
- Determine the application's UID and groups.
- Inspect the target file and parent directories.
- Verify filesystem and mount restrictions.
- Change only the permissions or ownership required.
- Retest using the actual service identity.
Avoid broad recursive changes until you understand their impact.
Conclusion
The same Linux fundamentals that protect an SSH key also influence access to application configuration and persistent storage.
Tools change. The access-control principles remain relevant.
Explore octal permission calculations, SUID, SGID, sticky bits, interactive exercises and additional examples in the original Linux file permissions guide.
References:
About the author
- Senior DevOps, Cloud & Site Reliability Engineer at DigitalOcean. I write about modern container orchestration, Linux systems, and cloud-native architecture. Explore my guides, architectures, and portfolio: • Website: https://naveedkumbhar.com • Resume: https://cv.naveedkumbhar.com • Blog: https://blog.naveedkumbhar.com • Newsletter: https://news.naveedkumbhar.com
Comments
Join the discussionNo comments yet. Be the first to comment.





