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:

[bash light=”true”]smbstatus | grep -i FILENAME[/bash]

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.
[bash light=”true”]5095 1000 DENY_ALL 0x2019f RDWR NONE /shared/apps apps/files/doc.txt Fri Sep 26 10:08:07 2008[/bash]

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.

[bash light=”true”]smbstatus | grep -i 1000[/bash]

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

[bash light=”true”]kill 5095[/bash]

66 Responses to "Unlocking Locked Network Files"