How do I change permissions on one Linux file without affecting an entire application?
chmod changes a file’s permission bits. Limit it to the exact object that needs a change and choose the mode based on who must read or write it. Recursive changes can make scripts non-executable, expose secrets, or remove required directory traversal across a working application.
Before you start
- An authorised SSH session on the Linux server.
Instructions
1. Record the current access decision
Inspect the existing mode, ownership and file type. For the example, the file is a private note that should be accessible only to its owner.
stat -c "%F %a %U:%G %n" -- "$HOME/server-notes/private-note.txt"Confirm this is the intended regular file, not a directory or an unexpected symbolic link.
2. Apply the one-file mode
Use 600 only for a file whose owner alone needs read and write access. Do not apply this mode to a directory or a file that an application account must read.
chmod 600 -- "$HOME/server-notes/private-note.txt"
stat -c "%a %U:%G %n" -- "$HOME/server-notes/private-note.txt"The change affects the specified file only. It does not change ownership, parent directories or a service’s security policy.
Check the result
- The file reports mode 600 and its intended owner can still read and edit it. Verify required application access separately when applicable.
Troubleshooting
- chmod reports Operation not permitted
- The account may not own the file, or the filesystem or attributes may prevent changes. Resolve the actual ownership or policy issue before elevating.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
