Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
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:~$
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.