brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: smbstatus -L shows which files clients have open on your Samba server

Linux
~/tips/tip-samba-smbstatus-locks

smbstatus -L

Lists the files that Samba clients currently hold locks on.

A file refuses to be renamed or the share “is in use” and nobody admits to anything. Before I restart Samba on a busy server, I’d want to know who is still working in it. smbstatus answers that and it ships with Samba.

smbstatus -L

The manual says -L makes smbstatus list only the locks, which is the list of files that clients hold open. Run it on the server itself. The tool reports on current Samba connections, and a few options narrow the output down:

  • -S lists only the shares that clients are connected to.
  • -b gives brief output.
  • -u name shows only the information for one user.
  • -p prints the smbd processes and exits, which the manual calls useful for scripting.
  • -j prints more detailed output as JSON instead of text a human reads.

Use the JSON form if you want to feed the result to another tool, for example smbstatus -L -j.

One caveat: -f skips the check whether the processes in the status data still exist. That is faster on busy systems, but the manual warns it can show stale data for processes that died without cleaning up. Leave it off when you are deciding whether it is safe to restart something. Add -B if you also want byte-range locks in the list.

Further reading: smbstatus man page

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Linux tips notify-send -r "$id" "Backup" "Done" pgrep -af 'sleep 301' msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.example.com --port=587 smbclient //server/share -U user -Tc backup.tar "*" xz -T0 -k big.log All Linux tips (283) All topics

Link