LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-18-2021, 02:37 PM   #1
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Rep: Reputation: Disabled
Question cannot remove 'test.bz2': Operation not permitted


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.
 
Old 03-18-2021, 03:04 PM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Is this user:user your actual user? Did you set any extended attributes on this file?
 
Old 03-18-2021, 03:21 PM   #3
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
Is this user:user your actual user? Did you set any extended attributes on this file?
Yes, that user is my account.

I don't get your question.
Code:
Did you set any extended attributes on this file?
 
Old 03-18-2021, 03:29 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
"extended attributes" is the clue, at this point you are supposed to say ahaa! and look it up.
 
Old 03-18-2021, 03:49 PM   #5
redd9
Member
 
Registered: Nov 2013
Location: Canada
Distribution: RHEL, Ubuntu
Posts: 212
Blog Entries: 1

Rep: Reputation: 82
Code:
lsattr test.bz2
 
Old 03-18-2021, 06:34 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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
Code:
sudo rm /path/to/test.bz2
 
Old 03-18-2021, 06:44 PM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
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.
 
Old 03-18-2021, 07:58 PM   #8
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by Emerson View Post
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.
 
Old 03-18-2021, 09:04 PM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
I did similar test, but now I realize I got the write permission via group which my user belongs to. My bad.
 
Old 03-18-2021, 11:03 PM   #10
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Wouldn't hurt to run e2fsck -f on the file system from Linux Live or another Linux on the same system if permissions appear to be in order.
 
Old 03-19-2021, 02:26 PM   #11
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
"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.
 
Old 03-19-2021, 02:27 PM   #12
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by redd9 View Post
Code:
lsattr test.bz2
Code:
lsattr test.bz2
----i---------e------- test.bz2
Currently i have not master extended attribute stuff.. hence show you the output first to analyze.
 
Old 03-19-2021, 02:32 PM   #13
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
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.
 
Old 03-19-2021, 02:37 PM   #14
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
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

Last edited by andrewysk; 03-19-2021 at 02:54 PM.
 
Old 03-19-2021, 02:57 PM   #15
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
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.
 
  


Reply

Tags
terminal



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rmdir:failed to remove 'aaa':Operation not permitted mcmxciv Linux - Newbie 3 12-04-2017 06:25 AM
SIOCSIFFLAGS: Operation not permitted SIOCSIFFLAGS: Operation not permitted sushan1982 Linux - Wireless Networking 1 01-01-2012 08:04 PM
[SOLVED] Cannot remove file - "Operation not permitted" ffallateuf Linux - Server 6 10-04-2010 03:19 PM
OpenVPN: Cannot ioctl TUNSETIFF tun: Operation not permitted? licht Linux - Networking 3 07-29-2007 07:38 AM
rm: cannot remove 'filename.extension' Operation not permitted shinystuffrox Linux - Software 8 03-07-2007 05:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration