Install Samba Server Ubuntu 16.04 (Xenial Xerus) server

Sponsored Link
Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients." Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

Install Samba Server in Ubuntu

Use the following command to install samba packages

sudo apt-get install samba samba-common

This will complete the samba installation.

Samba Configuration

First you need to Edit the smb.conf file using the following command

sudo vi /etc/samba/smb.conf

In the global section, remove the ";" at the front of the line security = user so it looks like this

security = user

to enable Linux system users to log in to the Samba server.

Close the file and restart Samba server using the following command.

sudo /etc/init.d/samba restart

Adding Samba Shares

Now you need 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 /home/shares/allusers

sudo chown -R root:users /home/shares/allusers/

sudo chmod -R ug+rwx,o+rx-w /home/shares/allusers/

Edit the /etc/samba/smb.conf file

sudo vi /etc/samba/smb.conf

add the following lines and save the file

[allusers]
comment = All Users
path = /home/shares/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 use these

Edit the /etc/samba/smb.conf file

sudo vi /etc/samba/smb.conf

add the following lines and save the file

[homes]
comment = Home Directories
browseable = no
valid users = %S
writable = yes
create mask = 0700
directory mask = 0700

Now you need to restart the samba server using the following command

sudo /etc/init.d/samba restart

Adding and managing users

In this example, I will add a user called ruchi. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.

sudo useradd ruchi -m -G users

Set a password for ruchi in the ubuntu system user database. If the user ruchi shall not be able to login to the ubuntu system, skip this step.

sudo passwd ruchi

-> Enter the password for the new user

Now add the user to the Samba user database.

sudo smbpasswd -a ruchi

-> Enter the password for the new user

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.

Sponsored Link

You may also like...

2 Responses

  1. sam says:

    Excellent article ruchi. Found it extremely useful. Though editing in vi is so much more difficult for newbies like me. I used nano instead of vi.
    Thanks a lot 🙂

  2. helloworld says:

    Thx
    maybe samba DC?

Leave a Reply

Your email address will not be published. Required fields are marked *