I have to write a script that runs at startup (this is a part that I don't know how to do yet) that erases the temporary files of the current user and I have the "Permission denied" error. The errors look like this:
'/tmp/systemd-private-long number-colord.service-LTsv8G' : permission denied ;
'/tmp/systemd-private-long number-systemd-timesyncd.service-PxhNq0' : permission denied ;
'/tmp/systemd-private-long number-rtkit-daemon.service-KQN6zN' : permission denied
This is my code so far:
TMPFILE=$(mktemp)|| exit 1
find /tmp -type f -user $USER -exec rm -f {} \;
if i run ls -l
after i've created TMPFILE I get:
total 4
-rwxrwxrwx 1 bristena bristena 530 may 25 10:51 sh.01
if i do cd /tmp
and then I run ls -l
I get
total 12
drwx------ 3 root root 4096 may 25 10:14 systemd-private-long number-colord.service-LTsv8G
drwx------ 3 root root 4096 may 25 10:14 systemd-private-long number-rtkit-daemon.service-KQN6zN
drwx------ 3 root root 4096 may 25 10:14 systemd-private-long number-systemd-timesyncd.service-PxhNq0
-rw------- 1 bristena bristena 0 may 25 10:51 tmp.j0rvQtmz7G
from what I've seen online I can also use trap "rm -f TMPFILE; exit"
, but I don't know how to integrate the current user requirenment
All of your help would be deeply appreciated