Tags

, , ,

Who else is using my file?

Ever got curious to know who else would be using a file/socket?

If i invoke tail polling on a file in two different sessions:

$tail -f logs.txt
$tail -f logs.txt

$ps -fu my
my 11449 11322  0 10:14 pts/0    00:00:00 tail -f logs.txt
my 11508 11450  0 10:14 pts/1    00:00:00 tail -f logs.txt

And now i want to see who all are user of the file /home/my/logs.txt:

my@ubuntu:~$ fuser /home/my/logs.txt
/home/my/logs.txt: 11449 11508

Say if you want to disassociate your file from other user, use “fuser” to find the culprit and kill them one-by-one 🙂

my@ubuntu:~$ fuser -k ./logs.txt
./repl-proto-logs.txt: 11449 11508
my@ubuntu:~$ fuser  ./logs.txt

This is very useful command to know about shared files and forceful release it from unwanted access.

(key inputs: Srikanth Samana)

A very crude trick to save Firefox sessions

To save time, i use a crude method of saving all my Firefox tabs. This helps me getting all the opened websites back, when I restart the Firefox after a shutdown.

  • In Windows: go to task manager, kill the Firefox process
  • Linux: Find the PID of Firefox, and send kill -9

simple!

When Firefox restarts, it asks you to “restore” the old session; just say yes!

Advertisements