

How to solve delete file "Operation not permitted" on Linux | Computin...
source link: https://computingforgeeks.com/how-to-solve-delete-file-operation-not-permitted-on-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Sometimes it is necessary to prevent all users including root from deleting a file. This is often done by changing the file attributes on a Linux file system. The tool used to change file attributes in Linux and other Unix systems is chattr
The format of a symbolic mode is +-=[acdeijstuADST]
. The format of a symbolic mode is +-=[acdeijstuADST] and they select the new attributes for
the files.
- The operator ‘+’ causes the selected attributes to be added
to the existing attributes of the files - ‘-’ causes them to be removed
- ‘=’ causes them to be the only attributes that the files have.
See explanation of all letters used below:
a - append only c - compressed d - no dump e - extent format i - immutable j - data journalling s - secure deletion t - no tail-merging u - undeletable A - no atime updates D - synchronous directory updates S - synchronous updates T - top of directory hierarchy
When a directory or a file has immutable attribute set, you will get the error “Permission denied” while trying to delete the underlying files. If the attributei
(immutable bit) is set on a file, not even root will be able to modify it.
Simulate delete file “Operation not permitted” on Linux
Create a directory under /tmp
mkdir /tmp/testdir
Touch a file in the directory
touch /tmp/testdir/testfile
Set append-only attribute
sudo chattr +a /tmp/testdir/testfile
For a folder and its contents, use -R
option for recursive change
sudo chattr -R +a /tmp/testdir/
See file attributes
$ lsattr /tmp/testdir/testfile -----a---------- testdir/testfile
Try delete the folder
$ rm -f /tmp/testdir/testfile rm: cannot remove ‘testfile’: Operation not permitted
Remove append-only attribute
sudo chattr -a /tmp/testdir/testfile
You should now be able to delete the file
rm -f /tmp/testdir/testfile
This works same for the immutable attribute (i).
sudo chattr -i /tmp/testdir/testfile rm -f /tmp/testdir/testfile
Recommend
-
24
A year ago, Benjamin "Mako" Hill gave a groundbreaking lecture explaining how Big Tech companies had managed to monopolize all the benefits of free software licenses, using a combination of dirty tricks to ensure that the tools that were nominal...
-
7
macOS Operation Not Permitted?2021-08-15Mac197 words 1 min read 5 times readSome permission related issue on macOS.File lock issueFor so...
-
8
strace: operation not permitted, ptrace_scope incorrect
-
13
[解決済み] php:*-alpine のdocker buildで、`make: /bin/sh: Operation not permitted` エラーが発生する はじめに(何が問題か) 以下のようなDockerfileをビルドすると、 FROM php...
-
9
adb push error: remote couldn't create file: Operation not permitted January 02, 2022...
-
6
'Time crystals' work around laws of physics to offer new era of quantum computing By Keith Cooper published 1 day ago Form...
-
12
Micheal Mathews December 29, 2020 7 minute read...
-
5
Alibaba to invest $1 billion over the next 3 years to support its cloud computing customers Alibaba to invest $1 billion over the next 3 years to support its cloud computing customers 13 hours ago
-
6
Deepmind’s AlphaDev discovers sorting algorithms that can revolutionize computing foundations
-
5
VMware partners with Samsung, AMD and RISC-V to accelerate confidential computing
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK