41

When I run Nautilus from command line, it starts successfully but this appears in the terminal:

Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: mkdir failed on directory /var/run/samba/msg.lock: Permission denied
net usershare: cannot open usershare directory /var/lib/samba/usershares. Error No such file or directory
Please ask your system administrator to enable user sharing.

Should I really ask my system administrator to enable user sharing?
My administrator is myself, and I don't use Samba.

Is this message the sign of bigger problems with my Ubuntu?
If not, how can I prevent it from appearing? (Nautilus is launched by a program I am beta-testing but can't modify, and the present problem makes this program's errors less visible in the terminal)

Nicolas Raoul
  • 11,603

7 Answers7

29

Nautilus uses the net usershare info command to get information about non-root user defined Samba shares. See the net manpage for more about this command.

If that command fails Nautilus assumes there are no such shares and displays the error message it got just in case you want it.

Creating the folder /var/lib/samba/usershares/ should prevent the message from appearing:

sudo mkdir -p /var/lib/samba/usershares/
  • 3
    Mar 2019: Ths didn't work, but sudo apt install samba did work. – Manohar Reddy Poreddy Mar 21 '19 at 01:59
  • Executing in the following order worked for me:
    1. sudo apt install samba
    2. sudo mkdir -p /var/lib/samba/usershares/
    – Mohsin Oct 09 '19 at 06:42
  • Worked fine on a machine here running Mint 19, based on Ubuntu 18.04 – without installing samba (dpkg -l samba showed it was uninstalled) and without any chmod. So before installing Samba (or executing the chmod suggested by Grégory's answer), make sure to check first ;) – Izzy Mar 06 '21 at 18:54
8

I've done these two things to correct this:

sudo mkdir -p /var/lib/samba/usershares/

and

sudo chmod go+rwx /var/lib/samba/usershares/
Fabby
  • 34,259
  • 1
    This actually worked for me. First of all, I did not have samba installed. And after I did install samba I got a permission denied error. Doing the chmod trick worked. – Delali Jun 30 '19 at 13:07
  • @grégory-mc This method also didn't work for me. Here is the proof: https://pastebin.com/WfLkri4b – Pranav Nov 16 '19 at 05:03
  • This can create a security risk. Just check which group has access to the folder and add the user to this group as in @Kamrul Hasan's answer (search for usermod) – Aaron Digulla Feb 05 '20 at 09:43
  • There's no reason (at least within the context of this question) for all users to have write access to this directory. chmod go+rx should be sufficient (and is probably already done by default in the mkdir, unless umask settings have been changed from defaults). – lindes Feb 15 '21 at 19:56
  • It worked for me also on ubuntu 20.04, no need to install samba. Also I removed the folder after issue resolved, and still I didn't get any errors – N1gthm4r3 Oct 29 '21 at 13:41
4

Another easier solution - Add your user into the group sambashare:

sudo usermod -aG sambashare $USER
2

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
1

In my case, didn't have samba installed so I had to install samba and then create the folder.

sudo apt install samba
sudo mkdir -p /var/lib/samba/usershares/

Prior to this had to install tracker because nautilus wasn't even running

(nautilus:26810): Tracker-ERROR **: 12:23:35.259: Unable to find default domain ontology rule /usr/share/tracker/domain-ontologies/default.rule
sudo apt install tracker
1

This is sad. Just to ignore that message, look at what method we need to use.

For me, I had to install samba in Ubuntu 19.10. Tried all method to ignore samba installation but none of them worked. Poor us for using nautilus. And its conflicting Desktop icons not showing in Desktop.

Pranav
  • 1,200
0
sudo mkdir -p /var/lib/samba/usershares/ &
sudo chmod go+rwx /var/lib/samba/usershares/

weren't enough, while

sudo apt-get install smbclient 

seems to solved my issue... ty @cbaconnier

abu_bua
  • 10,783
semdoc
  • 11