View Full Version : [SOLVED] rm -f and permissions
new__buntu
July 14th, 2010, 07:40 PM
Hi,
I'm new to ubuntu, and I've come to love the fact that I can control the permissions granted to other users (I'm the only one who uses the computer but it makes me feel powerful :)). Anyways, my question is basically this - does the -f option of the rm command bypass permissions? I've done some tests and it seems like it does.
EDIT: after further testing it looks like rm bypasses permissions in general.
nothingspecial
July 14th, 2010, 07:50 PM
It`s the sudo that does that, not the -f
unless you are root
da burger
July 14th, 2010, 07:54 PM
You can delete any file in a directory where you have write permissions, even if you don't have write permissions to the file itself.
In fact it's write permissions on the directory that allows you to delete a file. Make a test dir, make it belong to root with 755 perms, now create a file in it, make it belong to you with 700 permissions. Even though the file is yours you won't be able to delete it.
new__buntu
July 14th, 2010, 07:54 PM
But I didn't append sudo to my remove statements. Here's exactly what I did in my test:
$gedit newFile
$sudo chown root newFile
$sudo chmod 700 newFile
$rm newFile
rm: remove write-protected regular empty file 'newFile'? y
and voila it's gone
EDIT: da burger, you're too fast. And completely right. Thanks.
nothingspecial
July 14th, 2010, 07:56 PM
I was guessing, the answer is above ;)
Penguin Guy
July 14th, 2010, 08:00 PM
-f simply suppresses error messages:
-f, --force
ignore nonexistent files, never prompt
sisco311
July 14th, 2010, 08:07 PM
You can delete any file in a directory where you have write permissions, even if you don't have write permissions to the file itself.
In fact it's write permissions on the directory that allows you to delete a file. Make a test dir, make it belong to root with 755 perms, now create a file in it, make it belong to you with 700 permissions. Even though the file is yours you won't be able to delete it.
Almost right. :)
You also need execute access to all parent directories back to the root.
http://www.dartmouth.edu/~rc/help/faq/permissions.html
da burger
July 14th, 2010, 08:12 PM
Almost right. :)
You also need execute access to all parent directories back to the root.
http://www.dartmouth.edu/~rc/help/faq/permissions.html
Drat, so close. My answer said what was needed at least.
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.