I have a 3.2G file in /tmp
called phpvXcoZn
and I need to remove it.
Therefore I'd like to know if it is still in use but the commands I typed returned nothing :
/tmp$ bigfile=phpvXcoZn
/tmp$ ll -h $bigfile
-rw------- 1 www-data www-data 3.2G Aug 25 09:49 phpvXcoZn
/tmp$ cd
$ sudo lsof | grep $bigfile
$ sudo fuser -avm /tmp 2>&1 | grep $bigfile
$ sudo ls -l /proc/*/fd/* 2>/dev/null | grep $bigfile
$
EDIT0: As @MarcusMüller suggested, I can try to unlink the file and the space usage will we freed when the file is closed but I cannot unlink
that file belonging to www-data
with sudo su
:
$ sudo su www-data -c "unlink /tmp/phpvXcoZn"
This account is currently not available.
$ grep www-data /etc/passwd
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
This command worked :
sudo -u www-data bash -c "unlink /tmp/phpvXcoZn"
Do you other command to know if it is still in use ?
rm
ing a file that is still open somewhere else has no effect on the program that has it still opened. It just can't be opened through the file name anymore – and as soon as it is closed, its storage can be freed. Seeman 2 unlink
.unlink
the file as thewww-data
user although I didn't usesu -l
to avoid using a login shell. I don't understand ?sudo rm /tmp/phpvXcoZn
?www-data
cannot be used through su, probably a secure linux rule that blocks this, and it's a good thing.)sudo -u www-data bash -c "unlink /tmp/phpvXcoZn"
. Thanks. Can you please convert your first comment to an answer so I can accept it ?