Unlocking Locked Network Files

Whenever exclusive access is needed to certain open files you can clear that lock.

First you need to find the PID of the connection using that file. You need to run this command:

smbstatus | grep -i FILENAME

Replacing FILENAME with the file or directory that’s locked, the -i option tells to ignore case. After running that command the output will look like this.

5095       1000       DENY_ALL      0x2019f      RDWR   NONE     /shared/apps    apps/files/doc.txt        Fri Sep 26 10:08:07 2008

The columns headings won’t be displayed but the important columns are the first two. The 1st is the most important it’s the PID of the connection that has the file locked. The second is the UID or user ID of the connection. Using this number the user that has that file locked can also be found out. For this run this command replacing 1000 with the actual UID obtained from the first output.

smbstatus | grep -i 1000

After you’ve found the PID of the connection that has the file locked you can then just run a simple kill command.

kill 5095

One Response to "Unlocking Locked Network Files"

Leave a replyLeave a Reply to John