The /tmp
directory is conventionally marked with the restricted deletion flag, which appears as a permission letter t
or T
in ls
output.
Restricted deletion implies several things. In the general case, it implies that only the owner of the file, or the owner of /tmp
itself, can delete a file/directory in /tmp
.
You can not delete the file, because you are not the owner, which is root
. Try running rm
with sudo
which you probably forgot.
sudo rm /tmp/test
More specifically to Linux alone, the restricted deletion flag (on a world-writable directory such as /tmp
) also enables the protected_symlinks
, protected_hardlinks
, protected_regular
, and protected_fifos
restrictions, which in such directories respectively prevent users from following symbolic links that they do not own, prevent users making hard links to files that they do not own, prevents users opening FIFOs that they do not own, and prevents users from open existing files that they do not own when they expected to create them.
This will surprise you with permissions errors when doing various further things as root
when you do use sudo
.
More on these at question like "Hard link permissions behavior different between CentOS 6 and CentOS 7" , "Symbolic link not working as expected when changes user", and "Group permissions for root not working in /tmp".