10

I am getting the following error while running net usershare command.

'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

How to fix this? Thanks, :)

MeSo2
  • 421
  • 1
  • 9
  • 24

2 Answers2

17

The directory /var/lib/samba/usershares is set up so only root or members of the sambashare group can read or write to it.

drwxrwx--T  2 root sambashare  4096 Mar 25  2012 usershares

That you can't access it (try it by cding to it) suggests to me that you're not in the sambashare group. You can test this with id $USER and assuming usershares is not in the output, you can fix all this just by running:

sudo usermod -a -G sambashare $USER

If you still get error 255 after adding the particular user to the group you might need to reboot.

Oli
  • 293,335
  • Found that the directory is present there with a cross mark onto the folder. though i am being able access other folders in the LAN through SAMBA but not able to share my files to others. – Ashis Sanpui Feb 19 '13 at 06:26
  • this is the error while trying to "Create Share" 'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share. – Ashis Sanpui Feb 19 '13 at 06:51
0

I had a similar error on Ubuntu 20.04 and this was the way to solve it:

Remove all samba related files and configuration files

sudo apt purge python3-samba samba-common samba-common-bin samba-dsdb-modules samba samba-vfs-modules smbclient

Optionally you can remove the packages and maintain the configuration files, but this could left wrong files in the middle. It's better to do a backup of your configuration files. Anyway, if you want to try it, use remove instead of purge.

Reboot

Not sure if it's completely necessary, but I do it this way.

Share files

Open Nautilus and share a file or directory. A warning is showed indicating the sharing service is not installed and allowing you to click to install it. Click, install and you're done!

The nautilus-share package creates the /var/lib/samba/usershares/ directory with the right permissions and added your user to sambashare group, and it's ready to be used by other users too.

PabloRQ
  • 179
  • Thankyou this solution worked for me. (I think I had a prior manual Samba installation). After your command I ran apt install nautilus-share – Mtl Dev Feb 20 '24 at 19:27