LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 10-07-2012, 11:55 AM   #1
jmvidalvia
LQ Newbie
 
Registered: Mar 2011
Posts: 23

Rep: Reputation: 0
Question about permissions


Hi,
Still wondering how I could delete a directory if I had no writing permisions.
There's something I am missing: OK, I (as jmd user) have writing rights into the present directory, but what about those files/folders I don't own, like mnt/ in the attached case?
Code:
jmd@debian3:~$ ll
total 44K
4,0K drwxr-xr-x 3 jmd  jmd  4,0K oct  6 17:30 .
4,0K drwxr-xr-x 4 root root 4,0K oct  3 16:42 ..
4,0K -rw-r--r-- 1 jmd  jmd  3,3K oct  6 17:30 .bashrc
4,0K drwxr-xr-x 2 root root 4,0K oct  3 16:56 mnt
jmd@debian3:~$ rm mnt/ -r
rm: żborrar el directorio «mnt»  protegido contra escritura? (s/n) s
jmd@debian3:~$ ll
total 40K
4,0K drwxr-xr-x 2 jmd  jmd  4,0K oct  7 18:44 .
4,0K drwxr-xr-x 4 root root 4,0K oct  3 16:42 ..
4,0K -rw-r--r-- 1 jmd  jmd  3,3K oct  6 17:30 .bashrc
jmd@debian3:~$
Thanks!
 
Old 10-07-2012, 01:14 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I think you can remove a directory/file if you have execute permission AND execute and write permission in the parent directory.
 
Old 10-07-2012, 04:13 PM   #3
jmvidalvia
LQ Newbie
 
Registered: Mar 2011
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
I think you can remove a directory/file if you have execute permission AND execute and write permission in the parent directory.
Thanks!
 
Old 10-07-2012, 05:25 PM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
The answer you were given is correct but I just wanted to explain the reasoning behind this a little bit more so the reasoning behind it makes sense.

If you (joe) have a folder in your home directory (quux) owned by root, and you have no permissions to access this directory, you may be able to delete it.

A directory is really just a special file. It holds a list of files (and directories) in it. If you have write and execute permissions to a directory, you can make changes to its contents. This means you can delete any references to files or directories -- even if you don't own them or otherwise have access to them. You can't "change" them or even read them but you can change the "file" you do own (the directory) and remove the reference to it.

Now, there is an exception to this. The directory must be empty for you to delete it. If quux has nothing in it, you can remove it. If it has a file in it, you won't be able to remove it because you can't delete directories that are not empty and you don't have the sufficient permissions to edit the contents of that directory.

For files in a directory you have the above mentioned access in, you can override the permissions and delete them pretty much at will.

If you have write and execute permissions for a directory, you can make changes to the contents of that directory regardless of the permissions on the objects themselves (aside from directories that aren't empty).
 
1 members found this post helpful.
Old 10-10-2012, 05:03 PM   #5
jmvidalvia
LQ Newbie
 
Registered: Mar 2011
Posts: 23

Original Poster
Rep: Reputation: 0
Cristal clear. Thanks frob23 for your explanation.
 
  


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
[SOLVED] filesystem permissions question - making so user can't change permissions? c0pe Linux - Security 4 07-12-2010 09:06 AM
permissions question davidstvz Linux - Newbie 18 08-23-2008 01:33 PM
Question about permissions UnforgotteN Linux - Distributions 6 05-18-2005 08:51 PM
Another permissions question BajaNick Linux - Software 2 01-21-2004 11:40 AM
Permissions Question jkraeger Linux - General 1 02-25-2003 10:54 AM


All times are GMT -5. The time now is 02:50 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration