I have installed the ubuntu-server 16.04 and VBoxLinuxadditions and Samba

I am trying to share a folder from this server to my windows host machine. Now I can see this virtual server on my network but there are no shared folders on the server.

enter image description here

How do I make one through the command line?

  • This answer has a very easy to follow step by step command line setup. – L. D. James Apr 8 '17 at 15:14
  • TNX i will check that out now – lewis4u Apr 8 '17 at 15:19
  • Extremely easy if you manually install samba and ?-share if the system fails to install them automatically. See my answer below. – Papou May 30 '18 at 20:51
  • I am using above commands to share folders from ubuntu to windows. It works gracefully. But there is a problem, It times out after a while. Is there any way to add shared folders to samba configuration permanently. – user2046230 Mar 7 '19 at 6:37

So i have figured this on my own and this is the easiest solution:

just install samba with

sudo apt install samba

and go to this file:


and just at the bottom add these lines:


comment = Ubuntu File Server Share
path = /path/to/the/folder  #for example /home/user_name/public <- this comment needs to be deleted!
browsable = yes
guest ok = yes
read only = no
create mask = 0755

restart the samba service

sudo service smbd restart
sudo service nmbd restart

and that's it, easy peasy :)

|improve this answer|||||
  • What to do next? Where to find the shared folder from the client machine? – Mohammed Joraid Jul 19 '17 at 9:35
  • Just browse the network in Windows and it should be there after restart. – lewis4u Aug 21 '17 at 20:58
  • didn't work... using Ubuntu 16 LTS – Mohammed Sufian Oct 17 '17 at 15:18
  • 1
    I question the use of "easy peasy" to describe Samba. – nobar Mar 10 '18 at 17:56
  • 1
    See also force user: askubuntu.com/a/206064/11522 – nobar Mar 10 '18 at 18:00

All you have to do to share folders with SMB is
depending on the file manager you use, make sure nautilus-share or caja-share or ?-share is installed to enable next step
right-click on the folder and select the [Properties ->] Share tab that the file manager should provide
if that step doesn't propose to do it, install samba manually
choose the right sharing options and click Share
see https://help.ubuntu.com/community/Samba/SambaServerGuide#Ubuntu_Server

|improve this answer|||||

To add a share that is accessible by all users.

Create the directory for sharing the files and change the owner to the users group.

sudo mkdir -p /srv/samba/
sudo chown -R root:users /srv/samba/  [brusgroup][financial]
sudo chmod -R ug+rwx,o+rx-w /srv/samba/

Adding and managing users

eg. for group users and user mattu:

useradd mattu -m -G users
passwd mattu
sudo usermod -aG users mattu

Set a password for mattu

passwd mattu

Enter the password for the new user

Now add the user to the Samba user database.

sudo smbpasswd -a mattu

Enter the password for the new user

Edit the /etc/samba/smb.conf file

sudo vi /etc/samba/smb.conf

add the following lines and save the file

 comment = All Users
 path = /srv/samba/allusers/
 valid users = @users
 force group = users
 create mask = 0660
 directory mask = 0771
 writable = yes

If all users shall be able to read and write to their home directories via Samba, edit the /etc/samba/smb.conf file and remove all lines. In vim:

  1. Type gg to move the cursor to the first line of the file, if it is not already there.
  2. Type dG to delete all the lines.

Now you should be able to log in from your Windows workstation with the file explorer using username ruchi and the chosen password and store files on the ubuntu server either in ruchi's home directory or in the public shared directory.

workgroup = WORKGROUP
#netbios name = [FRODO] 
passdb backend = tdbsam 
printcap name = cups 

add user script = /usr/sbin/useradd -m %u 
delete user script = /usr/sbin/userdel -r %u 
add group script = /usr/sbin/groupadd %g 
delete group script = /usr/sbin/groupdel %g 
add user to group script = /usr/sbin/groupmod -A %u %g 
delete user from group script = /usr/sbin/groupmod -R %u %g 
add machine script = /usr/sbin/useradd -s /bin/false -d /var/lib/nobody %u 

# Note: The following specifies the default logon script. 
# Per user logon scripts can be specified in the user account using pdbedit  
logon script = scripts\logon.bat 
# This sets the default profile path. Set per user paths with pdbedit 
logon path = \\%L\Profiles\%U 
logon drive = H: 
logon home = \\%L\%U 
domain logons = Yes 
os level = 35 
preferred master = Yes 
domain master = Yes 

#[deprecated thus change
#idmap uid = 15000-20000 
#idmap gid = 15000-20000 
idmap config * : backend = tdb
idmap config * : range = 10001-20000
idmap config DOMAIN : backend = rid
idmap config DOMAIN : range = 10000-20000
idmap config DOMAIN : base_rid = 0 
printing = cups 

Example 2.8. Engineering Office smb.conf (shares and services)

comment = Home Directories 
valid users = %S 
read only = No 
browseable = No 
# Printing auto-share (makes printers available thru CUPS) 

comment = All Printers 
path = /var/spool/samba 
printer admin = root, maryo 
create mask = 0600 
guest ok = Yes 
printable = Yes 
browseable = No 

comment = Printer Drivers Share 
path = /var/lib/samba/drivers 
write list = maryo, root 
printer admin = maryo, root 
# Needed to support domain logons 

comment = Network Logon Service 
path = /var/lib/samba/netlogon 
admin users = root, maryo 
guest ok = Yes 
browseable = No 
# For profiles to work, create a user directory under the path 
# shown. i.e., mkdir -p /var/lib/samba/profiles/maryo 

comment = Roaming Profile Share 
path = /var/lib/samba/profiles 
read only = No 
profile acls = Yes 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.