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 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?
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.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by ppas
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.