Thursday, January 15, 2009

who is accessing this File

as long as a file or directory is accessed by a user or a process, that directory or file cannot be deleted, nor can the volume it is stored on be un mounted. so one question often asked by system administrators is, "who is using this file or directory at this moment". most *NIX systems provide
the command fuser to answer this question. it allows you to identify the number of the process accessing the file or the directory at the moment. if the number of the locking process is known, then using a command like ps reveals the user account running said process.


ex:-

fuser /home/user
/home/user: 6012c 6126c 6146c 6154c 6224c 6225c 6228c 6235c 6240c 6244c 6246c 6284c 6285c 6287c 6338c 7179c 8828c 12565c 12582c 14292c 14296c


user@ubuntu:~$ ps -ef | grep 6012 | grep -v grep
user 6012 5772 0 09:53 ? 00:00:01 x-session-manager
user 6121 6012 0 09:53 ? 00:00:00 /usr/bin/seahorse-agent --execute x-session-manager
user 6126 6012 0 09:53 ? 00:00:10 gnome-settings-daemon
user 6146 6012 0 09:53 ? 00:00:00 /bin/sh /usr/bin/compiz --sm-client-id default0
user 6148 6012 0 09:53 ? 00:00:47 gnome-panel --sm-client-id default1
user 6154 6012 0 09:53 ? 00:00:26 nautilus --no-default-window --sm-client-id default2
user 6225 6012 0 09:53 ? 00:00:00 bluetooth-applet --singleton
user 6228 6012 0 09:53 ? 00:00:09 update-notifier
user 6235 6012 0 09:53 ? 00:00:00 tracker-applet
user 6240 6012 0 09:53 ? 00:00:00 trackerd
user 6244 6012 0 09:53 ? 00:00:00 python /usr/share/system-config-printer/applet.py
user 6246 6012 0 09:53 ? 00:00:13 nm-applet --sm-disable

source:- Erik M Keller

No comments:

Post a Comment