Short answer: Operation not permitted is error EPERM (errno 1): the kernel refused the call for a reason the read, write and execute bits do not cover. You are not the file's owner or not privileged, the file carries an immutable or append-only attribute, the file system cannot store the change, or a container or sandbox took the right away. If you are already root on a Linux server, check the file's attributes first.
lsattr FILE # an i (immutable) or a (append-only) blocks changes, even for root
sudo chattr -i FILE # clear immutable; use chattr -a for append-only
id -u # 0 means root; any other number: try the command with sudo
findmnt -T FILE # which file system holds the file, and its mount optionsEPERM versus EACCES
Permission denied is EACCES (errno 13), a different error. Both numbers come from the kernel headers; on our Debian 12 server:
$ grep -E 'define\s+(EPERM|EACCES)\s' /usr/include/asm-generic/errno-base.h
#define EPERM 1 /* Operation not permitted */
#define EACCES 13 /* Permission denied */The errno(3) man page lists both as POSIX.1-2001 errors but does not explain the split; the system call pages do. In chmod(2), EACCES means search permission was denied on a directory in the path, while EPERM means the caller is not the owner and lacks CAP_FOWNER, or the file is marked immutable or append-only. In short: EACCES is about permission bits, EPERM is about ownership, privilege or a rule above the bits.
Programs show the same error under other names. Node.js sets code: 'EPERM' on the error object, and its documentation describes EPERM as an operation that requires elevated privileges. Python raises PermissionError for both EPERM and EACCES, so check e.errno (1 or 13) to tell them apart.
Causes by platform
| What you see | Where | Cause | Fix |
|---|---|---|---|
| rm, mv, chmod, touch or a redirect fail, as root | Linux, ext4 and others | Immutable (i) or append-only (a) attribute | lsattr, then chattr -i or -a |
chown: changing ownership of 'f': Operation not permitted | Linux, normal user | Only a process with CAP_CHOWN may change the owner | sudo chown |
chmod: changing permissions of 'f': Operation not permitted | Linux, not the owner | Not the owner and no CAP_FOWNER | sudo, or ask the owner |
| chown or chmod as root fails on a network share | NFS client | root_squash maps root to the anonymous user | Change it on the NFS server |
| chown or chmod fails on a USB disk or EFI partition | FAT32, exFAT | No Unix owners; the mount options decide | Mount with uid=, gid=, umask= |
RTNETLINK answers: Operation not permitted | ip as a normal user, or in a container | Missing CAP_NET_ADMIN | sudo, or --cap-add=NET_ADMIN |
ping: socket: Operation not permitted | Container, copied ping binary | Missing CAP_NET_RAW | ping socket fix |
ulimit: open files: cannot modify limit: Operation not permitted | bash | Raising the hard limit without root | Shell limits |
ls: .: Operation not permitted | macOS Terminal | Privacy settings block Desktop, Documents or Downloads | Files & Folders or Full Disk Access |
Immutable and append-only files
This is the classic case of root getting EPERM. Per chattr(1), a file with the i attribute cannot be deleted, renamed, linked or opened for writing, and most of its metadata cannot change. A file with a can only be opened in append mode. Only root or a process with CAP_LINUX_IMMUTABLE can set or clear either flag. We ran this as root on a throwaway file in a scratch folder on our Debian 12 server (ext4, e2fsprogs 1.47.0, coreutils 9.1):
# lsattr demo.txt
--------------e------- demo.txt
# chattr +i demo.txt
# lsattr demo.txt
----i---------e------- demo.txt
# echo more >> demo.txt
bash: demo.txt: Operation not permitted
# rm -f demo.txt
rm: cannot remove 'demo.txt': Operation not permitted
# chmod 600 demo.txt
chmod: changing permissions of 'demo.txt': Operation not permitted
# chown nobody demo.txt
chown: changing ownership of 'demo.txt': Operation not permitted
# mv demo.txt x.txt
mv: cannot move 'demo.txt' to 'x.txt': Operation not permitted
# touch demo.txt
touch: cannot touch 'demo.txt': Operation not permittedThe e in the flags means the file uses extents; it is normal on ext4 and chattr cannot remove it. Append-only behaves as documented: appending works, overwriting and deleting do not.
# chattr -i demo.txt
# chattr +a demo.txt
# lsattr demo.txt
-----a--------e------- demo.txt
# echo appended >> demo.txt # exit status 0
# echo over > demo.txt
bash: demo.txt: Operation not permitted
# rm demo.txt
rm: cannot remove 'demo.txt': Operation not permitted
# chattr -a demo.txt
# rm demo.txt # works nowTo find every file with either flag below a directory, list attributes recursively and keep the lines whose flag field contains i or a (the first test skips the directory headings that lsattr -R prints between blocks):
sudo lsattr -Ra /etc 2>/dev/null | awk '$1 ~ /^[-a-zA-Z]+$/ && $1 ~ /[ia]/'chown, chmod and ownership rules
Per chown(2), only a privileged process (CAP_CHOWN) may change a file's owner. The owner may move the file to any group they belong to, nothing more. So chown to another user fails for a normal user even on their own files; prefix it with sudo. The chown command guide covers the syntax. chmod needs ownership or CAP_FOWNER; the group write bit does not let you change another user's mode bits.
The same idea explains a few neighbours. Per kill(2), signalling another user's process needs CAP_KILL, so kill on it fails with EPERM. Per unlink(2), deleting another user's file in a sticky directory such as /tmp can fail with EPERM or EACCES.
NFS with root_squash
By default an NFS server maps requests from root to an anonymous user. Per exports(5), root_squash maps uid and gid 0 to the anonymous IDs, which exportfs sets to 65534 unless anonuid and anongid say otherwise. Root on the client then has no right to change owners on the share, and chown fails. Change ownership on the server itself. no_root_squash on that export also works, but it gives root on every client root on the share, so use it only for hosts you fully trust.
FAT32 and exFAT
These file systems store no Unix owners. In the Linux kernel's vfat and exfat drivers, a chown to any user or group other than the one the volume was mounted with returns EPERM, and so does a chmod that sets setuid, setgid or sticky bits; other mode changes the driver cannot store are dropped without an error. The owner is chosen when you mount: uid=, gid= and umask= per mount(8). The FAT option quiet only hides the error; the change still does not happen. Mounting such a drive is covered in how to mount a disk on Linux.
Containers, capabilities and user namespaces
Inside a container, root usually holds only part of root's power. Docker's run reference lists the capabilities a container keeps by default: NET_RAW is among them, NET_ADMIN is not. Per capabilities(7), CAP_NET_ADMIN covers interface configuration, firewall rules and routing tables, so ip fails without it. This example is from Docker's documentation (we did not run Docker for this page):
$ docker run -it --rm ubuntu:24.04 ip link add dummy0 type dummy
RTNETLINK answers: Operation not permitted
$ docker run -it --rm --cap-add=NET_ADMIN ubuntu:24.04 ip link add dummy0 type dummyAdd only the capability you need. Docker's page says --privileged gives the container all capabilities and asks you to use it with caution. A few more container sources of EPERM:
- ping: raw sockets need
CAP_NET_RAW. When a runtime drops it (--cap-drop NET_RAW), ping fails; the details are in ping: socket: Operation not permitted. - Blocked system calls: Docker's default seccomp profile is an allowlist. Its
default.jsonin the moby/profiles repository setsdefaultErrnoRetto 1, so a call outside the list fails with EPERM. The documentation namesmount,unshareandkeyctlamong the blocked calls. - Rootless containers and user namespaces: per user_namespaces(7), a capability inside a user namespace only works on resources that namespace governs. Setting the clock, loading kernel modules or mounting a block device needs privilege in the initial namespace, so root in the container is refused. Files owned by IDs outside the mapping show up as 65534, and
CAP_CHOWNinside the namespace only works on files whose user ID and group ID both have a mapping.
macOS: ls: .: Operation not permitted
On a Mac the usual trigger is Terminal reading a protected folder. Apple's Mac User Guide (the current edition is for macOS 27, the newest release on Apple's version list as of 13 November 2026) lets you choose which apps may open the Desktop, Downloads and Documents folders. When Terminal is not allowed, ls inside ~/Desktop answers ls: .: Operation not permitted. Two ways to allow it:
- Files & Folders (narrow): Apple menu, System Settings, Privacy & Security, Files & Folders, then turn on the folders listed under Terminal.
- Full Disk Access (broad): same pane, Full Disk Access, click the add button, select Terminal and click Open. Apple describes it as access to all files, including other apps' data, Time Machine backups and some administrative settings for all users, so prefer Files & Folders when that is enough.
The other macOS source is System Integrity Protection. Apple's SIP article says it restricts the root user and protects /System, /usr, /bin, /sbin, /var and preinstalled apps, while /Applications, /Library and /usr/local stay writable. So sudo cannot write into /usr/bin. Since macOS 10.15 the system files also sit on a read-only system volume, so there the message can read Read-only file system instead. Install your own tools under /usr/local/bin instead of switching SIP off.
On a VPS or dedicated server
On your own Linux server you usually work as root, so "you need sudo" is rarely the answer. EPERM as root nearly always comes from one of three places, and they are quick to check in order:
- An attribute:
lsattr FILE. A file you never touched can still carry one, set by a script or by another admin. - A mount:
findmnt -T FILEshows NFS, FAT or exFAT and their options. A read-only mount gives a different error, Read-only file system. - A container:
systemd-detect-virt -cprints the container type, ornone. Inside one, the fix belongs in the container's run options, not in the image.
When you work as a normal user, the plain answer is still sudo; if the account has no sudo rights yet, create a sudo user from a root session.
Frequently asked
What is the difference between Operation not permitted and Permission denied?
Operation not permitted is EPERM (errno 1), Permission denied is EACCES (errno 13). EACCES usually means the permission bits or a directory on the path said no. EPERM means a rule beyond those bits: you are not the owner or lack a capability, the file is immutable or append-only, or the file system or a sandbox refuses the change.
Why does root get Operation not permitted on Linux?
Most often the file has the immutable (i) or append-only (a) attribute, which blocks changes even for root. Check with lsattr FILE and clear it with chattr -i or chattr -a. Otherwise the file sits on an NFS share with root_squash or a FAT or exFAT volume, or you are root inside a container that lacks the needed capability.
How do I fix ls: .: Operation not permitted in the macOS Terminal?
Terminal has no permission for the protected folder you are in, such as Desktop, Documents or Downloads. Open System Settings, Privacy & Security, Files & Folders and turn on the folders under Terminal. Full Disk Access also works but gives Terminal access to all files, so use it only if the narrower setting is not enough.
What does RTNETLINK answers: Operation not permitted mean?
The ip command asked the kernel to change network settings without the CAP_NET_ADMIN capability. As a normal user, run it with sudo. In a Docker container, which does not get NET_ADMIN by default, start the container with --cap-add=NET_ADMIN instead of --privileged.