5

I've been trying to figure out why this issue is occurring every single time. I've tried searching for solution for this issue but have come up with nought. Can you help me identify and fix the error:

My issue initially started out with trying to share with Samba Shares. I am booting an old Levovo laptop (E420) using an Ubuntu live USB. The laptop boots up fine, it is connected to the Internet (I am posting this question from the laptop). The laptop is connected to my LAN through an Ethernet cable. I am trying to share the local HDD of the Laptop on the network to transfer all the files out of the laptop to another device. However, when I mount the local HDD in fIles and then try to share it (Right Click -> Network Share), I get the following error. How do I fix it and share the folder on the network?

Share error screenshot

There are two errors that I can see:

  1. An attempt to create a log.net file for which the user does not seem to have permission. I'm not sure why that is. I have even created an empty file with the log.net and given all permissions to everyone for it (i.e. chmod 777)
  2. The error says that I'm using an invalid character in the share name. But I'm not. I've even tried a different "name" but this error persists.

For reference, the error text is also pasted below:

'net usershare' returned error 255: [2023/04/05 09:28:20, 0] ../../lib/util/debug.c:1100(reopen_one_log) reopen_one_log: Unable to open new log file 'AJ/log.net': No such file or directory net usershare add: share name /media/ubuntu/e42804db2804af1c/aj contains invalid characters (any of %<>*?|/+=;:",)

AJ.
  • 151
  • 1
  • 3
  • Most likely it is trying to make the log file on the USB and of course it can not. – David Apr 05 '23 at 09:52
  • Hi David, The path that it's trying to create the file in is in the folder I'm trying to share: 'AJ/log.net'. Does this exist on the USB drive? And why is the USB drive not writable for this file? – AJ. Apr 05 '23 at 12:06
  • If it is a Live Media boot USB it is not available to write any files. It is closed to write. – David Apr 05 '23 at 12:32

3 Answers3

3

Hey I was having the same problem when using the graphic interface in Nautilus and turns out it was a bug in nautilus-share https://bugs.launchpad.net/ubuntu/+source/nautilus-share/+bug/1967245.

I understand that the problem is the use of the -l parameter called by the nautilus extension that sets up the folder to be shared, with --long parameter it works fine. So, you can do it from the terminal:

net usershare add --long share <full_path> "comment" "Everyone:R" guest_ok=n

(Change R to F for read-write permissions) Notice that the way this is set up you still need to create a user and pass to access the samba server: sudo smbpasswd -a <some_user_name> and restart the service: sudo systemctl restart smbd .

The original source was: https://forum.manjaro.org/t/samba-nautilus-share-funktioniert-nicht-mehr/85428/20

  • sudo smbpasswd -a nihal New SMB password: Retype new SMB password: Failed to add entry for user nihal.

    getting this error

    – Nihal Sharma Aug 05 '23 at 15:39
2

You have a problem with the log file path and share name, here is how to fix that, first we fix the log file path here, open this file /etc/samba/smb.conf then search for a line that start with log file and change it so that it look like that log file = /var/log/samba/log.%m then check that the path specified by your system for the log file exist and have the proper permission

sudo mkdir -p /var/log/samba
sudo chown root:adm /var/log/samba
sudo chmod 750 /var/log/samba

for the share name it should not contain any of those character % < > * ? | / + = ; : , " and there is / in /media/ubuntu/e42804db2804af1c/aj just use something like aj or test if is temporary, then restart properly and it should work. sudo systemctl restart smbd nmbd

edit: following your comment the problem might be related to the way the GUI is creating the share name, here what you can do, first check the permission for example for /media/ubuntu/e42804db2804af1c/aj we do ( replace your_username with yours )

sudo chown -R your_username:your_username /media/ubuntu/e42804db2804af1c/aj
sudo chmod -R 755 /media/ubuntu/e42804db2804af1c/aj

then in /etc/samba/smb.conf add those ( replace your_username and path with yours )

[aj]
   path = /media/ubuntu/e42804db2804af1c/aj
   browseable = yes
   read only = no
   guest ok = yes
   create mask = 0644
   directory mask = 0755
   force user = your_username

save and restart sudo systemctl restart smbd nmbd

Saxtheowl
  • 1,739
  • 2
  • 10
  • 20
  • 1
    Thank you. I have followed the steps you have outlined. The folder /var/log/samba already exists and it also has a few files such as log.smbd, log.nmbd etc.

    For the share name, I am only entering aj or something similar. I'm not sure where the slash is coming from. I'm using the GUI to create a share and am entering the share name exactly as it is in the screenshot. How do I prevent the errant / from coming in (I don't know why or how it is even coming in)

    – AJ. Apr 06 '23 at 06:14
  • You welcome, I updated my answer. – Saxtheowl Apr 06 '23 at 06:43
1

Please see the following installation guideline. It can effectively solve the outstanding issue of 'net usershare' returned error 255..."

Install & Configure Samba

0.Remove your previously-installed samba

$ sudo apt-get purge samba samba-common
$ cd /home/username/Documents
$ sudo rm -rf share

1.Install samba

$ sudo apt update
$ sudo apt install samba samba-common 

2.Check both version & path

1).Check version

$ samba -V

Version 4.15.13-Ubuntu

2).Installation path

$ whereis samba

3.Create share and authorize share

1).Show user's username (not host name)

$ whoami

The command reminds User to input the correct name for the next procedure.

2).Create share and authorize it

$ sudo mkdir /home/username/Documents/share 
$ sudo chmod 777 /home/username/Documents/share

4.Write the following lines in smb.conf

1).Open smb.conf

$ sudo gedit /etc/samba/smb.conf

2).Write the command lines in smb.conf

[share]
    comment = Samba on Ubuntu
    path = /home/username/Documents/share
    read only = no
    browsable = yes
    available = yes
    writable = yes
    public = yes

The above commands enable other Operation Systems such as Mac or Windows can access to Ubuntu 20.04. Please note the last three commands are essential to enable the Samba visible to Mac OS or Windows.

3).Save smb.conf

4).Close smb.conf

5.Restart Samba

$ sudo service smbd restart

6.Update the firewall rules to allow Samba traffic

$ sudo ufw allow samba

7.Set up user account

Please note the username and host name(or computer name) (username@hostname)

$ whoami

Show your username again in order to write a wrong name(such as host name)

$ sudo smbpasswd -a username

8.Connecting to Share

Please go to Files (of Ubuntu 20.04) on the left hand side

1).Open New Windows 2).click Other Locations 3).click share 4).Input Password twice for confirmation

9.Write Save a sample document

Write a sample text and save it into share

or

Copy an existing text into share

10.Set Mac OS

1).Go to Finder

2).Open Network

User can see the above written or saved sample text.

Notes:

  1. User can use the command of ifconfig to get your_ip_addres and then input samba://your_ip_address to connect the sever(Ubuntu). But the method has a little complex.
Mike Chen
  • 141