I generate a file in the tmp directory of my root server.
touch "sync.txt"
chmod 777 "sync.txt"
and I try to delete it with python like this
os.remove('/tmp/sync.txt')
but I always get this error
exceptions.OSError: [Errno 1] Operation not permitted: '/tmp/sync.txt'
I thought this would be solved by settings the file permission to 777 but I still have this problem.
When I make
chmod 777 /tmp
instead I get another error:
exceptions.OSError: [Errno 2] No such file or directory: '/tmp/sync.txt'
However the file is deleted.
Any idea whats wrong? How can I fix that exception?
If
/tmpis marked sticky (chmod a+t) then only the superuser or the owner of the directory or file within it will be able to delete it, regardless of what permissions the file has.