Code I/O

A topnotch WordPress.com site


Leave a comment

5 Minutes on Linux: Unable to remove user shares

Problem: Sharing directories in Linux using samba is common.  However, there are instances, when users who shared them are no longer on the system (probably removed).  The share names they used stay in the system as zombie entries.  When some one wants to share a directory using a name that was zombied, it is not possible.  The SMB protocol uses unique share names.

Challenge: for GUI users, one does not have a facility to unshare or manage the orphan shares.

Solution 1 (to unshare): use the command line:

net usershare list
net usershare delete sharename

Solution 2 (to remove orphan shares):

ls -l /var/lib/samba/usershares
sudo rm /var/lib/samba/usershares/sharename

Once this is done, users will be able to reuse the share name again.  Better approach is to automate removal of share entries from /var/lib/samba/usershares (owned by users) when the user is removed.