Minimum file permissions to rename file

11,161

Generally, if you have write permission to a directory you can rename any file in that directory. Specifically, you do not have to own the file to be able to rename it:

ls -la
total 8
drwxr-xr-x  2 roaima roaima 4096 Mar 25 23:42 .
drwxr-xr-x 39 roaima roaima 4096 Mar 25 23:42 ..
-rw-------  1 root   root      0 Mar 25 23:42 file

mv file sandpaper
ls -l
total 0
-rw------- 1 root root 0 Mar 25 23:42 sandpaper

The exception is when an ACL has been applied that denies the operation, or when the sticky bit t is also present in that directory's permissions. In this second case you must also own the file to be renamed.

Note that in all cases you need access to the directory in question, so the appropriate execute bit x is required (user/group/others).

This means that the minimum set of permissions on a directory to rename any file in it is -wx for the appropriate membership set (user/group/others).

Share:
11,161

Related videos on Youtube

Agatella
Author by

Agatella

Updated on September 18, 2022

Comments

  • Agatella
    Agatella almost 2 years

    I put a 64-bit ELF file in my unprivileged user's home directory. I wonder which permissions do I need to have only possiblity to rename this file being logged in as unprivileged user. From what I understand I only need execute permission for user to whom file belongs to, set for parent's directory. Is that right?

    So if path to my file is /home/Simon_dir/zip and I wrote chmod 0100 /home/Simon_dir and file permissions are set to 0000, should I have rights to rename the zip file being logged in as unprivileged user?