Install Samba Server in Ubuntu
Use the following command to install samba packages
sudo apt-get install libcupsys2 samba samba-common
This will complete the samba installation.
Configuring Samba in Ubuntu
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
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.
mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
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
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
/etc/init.d/samba restart
Adding and managing users
In this example, I will add a user called nyc. 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.
useradd nyc -m -G users
Set a password for nyc in the ubuntu system user database. If the user nyc shall not be able to
login to the ubuntu system, skip this step.
passwd nyc
-> Enter the password for the new user
Now add the user to the Samba user database.
smbpasswd -a nyc
-> 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 nyc and the chosen password and store files on the ubuntu server either in nyc’s home
directory or in the public shared directory.