To view all Linux shares: shares=$(ls -l /var/lib/samba/usershares | awk '{print "/var/lib/samba/usershares/"$8}') for i in $shares do cat $i | grep path done To remove all Linux shares:
#!/bin/sh shares=$(ls -l /var/lib/samba/usershares | awk '{print $8}') for i in $shares do net usershare delete $i done