[SOLVED] cannot remove 'test.bz2': Operation not permitted
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I created this "test.bz2" last time when i was learning to use tar..
After sometime i saw it and want to delete it , because i no longer need it.
But i can't.
Code:
$ rm *
rm: cannot remove 'test.bz2': Operation not permitted
Code:
$ ls -l
-rw-r--r-- 1 user user 22356381 Feb 27 14:17 test.bz2
Code:
$ chmod a+x *
chmod: changing permissions of 'test.bz2': Operation not permitted
What's wrong ? I can't think of any other reason why.
If the file happens to be in a directory where you do not have execute permissions you cannot delete a file. You also cannot delete a file within a directory where your user does not have write permissions, even if you own and have write permissions on the file itself
Try doing
Code:
ls -l ..
while in that directory. Also, walk the directory tree from the root directory to that one and make certain that at every level "ls -l" shows that either you are the owner or that the permissions are at minimum rwxr-xr-x. Without permissions at every level you cannot do things with files that you expect to be normal actions.
Finally, and this is a last ditch effort because an error can break your system, you can use sudo like
You also cannot delete a file within a directory where your user does not have write permissions, even if you own and have write permissions on the file itself
This is not true, only some GUI file managers may behave like this, and this must be considered a bug.
This is not true, only some GUI file managers may behave like this, and this must be considered a bug.
Code:
[user@eagle temp3]$ ls -l ../
dr-xr-xr-x. 2 user user 4096 Mar 18 18:28 temp3
$ ls -l
-rw-rw-r--. 1 user user 2753 Mar 18 18:28 testit
$ rm testit
rm: cannot remove 'testit': Permission denied
$ cd ..
$ rm -r temp3
rm: descend into write-protected directory 'temp3'? y
rm: cannot remove 'temp3/testit': Permission denied
That is in the bash shell, not a file manager, in a subdirectory of my $HOME, where I deliberately tried to remove the file where I owned the directory and the file, the file was writable, the directory is both read and execute but currently not writable.
Notice that even though I moved up one level (to my home directory) I still was unable to remove the directory and its content because the directory was not writable by my user and I could not remove the file inside it.
I stand by my last statement. If the user does not have write permission in the directory he cannot delete a file even if he owns it.
To delete the file he would have to write to the inodes within that directory which is not allowed.
"extended attributes" is the clue, at this point you are supposed to say ahaa! and look it up.
Ahaa! I have read about it.. maybe i did something like that in the past as i was learning this and that.. I can faintly recalled somewhat of that sort of thing.
OK, you were learning it in past but now you want us to tell what it is. Methinks it is time for you to go over it again, then your time spent on learning won't be wasted.
If the file happens to be in a directory where you do not have execute permissions you cannot delete a file. You also cannot delete a file within a directory where your user does not have write permissions, even if you own and have write permissions on the file itself
Try doing
Code:
ls -l ..
while in that directory. Also, walk the directory tree from the root directory to that one and make certain that at every level "ls -l" shows that either you are the owner or that the permissions are at minimum rwxr-xr-x. Without permissions at every level you cannot do things with files that you expect to be normal actions.
Code:
$ ls -l ..
total 4
drwxrwxrwx 2 user user 4096 Mar 17 20:58 test
I have total right to the folder, so with everyone (bcos i have use chmod 777 before this)
Code:
$ sudo rm *.*
[sudo] password for user:
rm: cannot remove 'user.bz2': Operation not permitted
OK, you were learning it in past but now you want us to tell what it is. Methinks it is time for you to go over it again, then your time spent on learning won't be wasted.
No, pls guide me first.
I have not went thru the whole command last time, just briefly knew this command. I will surely go thru later .. Thx.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.