LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-30-2020, 01:11 PM   #1
ppas
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Rep: Reputation: Disabled
Can't delete protected directory/file


I have a directory that seems impossible to delete, but I need to free space as it occupies over 1GB. Using command rm -r it says in the end 'cannot remove...: Permission denied'. Even the command rm -rf doesn't do it. How can I delete such a file or directory?

Last edited by ppas; 06-30-2020 at 01:16 PM.
 
Old 06-30-2020, 01:16 PM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: Slackware
Posts: 1,845

Rep: Reputation: 790Reputation: 790Reputation: 790Reputation: 790Reputation: 790Reputation: 790Reputation: 790
Need more info - what is the directory and who owns it?

EDIT: know what directory would be nice in case you are trying to delete /proc, /bin, etcetera...

Last edited by sevendogsbsd; 06-30-2020 at 01:26 PM.
 
2 members found this post helpful.
Old 06-30-2020, 01:21 PM   #3
captain_sensible
Member
 
Registered: Apr 2010
Posts: 238

Rep: Reputation: 68
are you trying as root ?

info of output and your distro would be handy

but lets guess ?

you tried:

sudo rm -r <dir>
 
2 members found this post helpful.
Old 06-30-2020, 01:26 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,706
Blog Entries: 13

Rep: Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922Reputation: 3922
Correct as pointed out by sevendogsbsd.

Suggest you perform an "ls -l" of the directory file name to see who owns it, what group it is in, and what the privileges are. Examining that and paying attention to what username you are will help solve this.

And note that if your first reply is "But I'm root", that still can be blocked if the permissions disallow the owner from deleting the directory. Either as root or using sudo you can delete, or modify the permissions and other things like group membership and ownership of the directory to allow it to be deleted. (I forget whether or not the sticky bit has any bearing here, but that also will be shown by the extended listing of the file)

EDIT: And also updated by sevendogbsd. Yeah, .... don't delete system trees. If it's truly some data directory, then use su or sudo, just be cautious.

Last edited by rtmistler; 06-30-2020 at 01:28 PM.
 
1 members found this post helpful.
Old 06-30-2020, 01:29 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: Currently: openSUSE, Raspbian, Slackware. Formerly: CentOS, MacOS, Red Hat. Other: Solaris, Tru64
Posts: 1,927

Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
Quote:
Originally Posted by ppas View Post
I have a directory that seems impossible to delete, but I need to free space as it occupies over 1GB. Using command rm -r it says in the end 'cannot remove...: Permission denied'. How can I delete such a file or directory?
Go to the parent directory of the one you want to remove and issue:
Code:
$ ls -ld directory-name
and post the results in a reply.

The permissions are obviously set to prohibit its removal by you.

You would be able to delete the directory and its contents, by either using the 'root' account or giving yourself temporary privileges using 'sudo', but you'll want to be very careful. Questions to ask yourself:
  • If you don't own the directory, do you really want to delete it?
  • Are the contents of that subdirectory critical data?
  • Are you sure there aren't other files that you own that can't be compressed to recover some free space?
  • You are aware of the serious damage that can result from the "rm -r" command, right?

HTH...
 
2 members found this post helpful.
Old 06-30-2020, 02:35 PM   #6
ppas
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
All right, I did it now, using sudo before the command. The file or directory was an iso that I mounted. It was in the downloads directory. Thank you.
 
1 members found this post helpful.
Old 06-30-2020, 03:08 PM   #7
shruggy
Member
 
Registered: Mar 2020
Posts: 949

Rep: Reputation: Disabled
You did unmounted it before removing, didn't you?
 
Old 06-30-2020, 03:24 PM   #8
ppas
LQ Newbie
 
Registered: Sep 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
I mounted the iso but can't remember what I did afterwards, it was a long time ago. But the resulting file was there in the folder for nothing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
i am not able to delete a Directory from my Pen Drive. when i trying to delete, it showing Error. Shahbaz_Mansuri Ubuntu 6 02-28-2018 05:01 PM
delete protected directory in samba fareedreg Linux - Newbie 2 12-20-2010 11:18 PM
[SOLVED] Displaying the contents of buffers in a protected and non-protected critical section mashhype Programming 5 11-22-2010 09:41 PM
How to delete protected Windows executable files via Linux? keithrennie Linux - General 2 10-29-2009 07:24 PM
Need to write a file in delete protected mode shiv.singh Linux - Newbie 7 05-17-2009 12:59 AM

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

All times are GMT -5. The time now is 03:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration