Install Samba File Sharing Server on Ubuntu Server and Configure

This time I want to share how to configure Samba server on Ubuntu Server.
Samba is a program with a Client-Server protocol that bridges 
the process of providing services for sharing data, 
documents and resources between the UNIX Family operating system and the Microsoft Windows operating system. 
This application runs on the UNIX Family operating system platform.

With this method you can install on ubuntu server 16.04 18.04 20.04 22.04 and between versions.

You can also use this same method to install on Debian Linux.

01. Frstu instalasi paket samba.

sudo apt update
sudo apt install samba samba-common-bin

02. Create a directory that you will share.

sudo mkdir /hdd1

(It could be a disk in your server.)

03. Then give Read-Write access to the folder.

sudo chmod 777 -R /hdd1/

04. Create a new user that will be used for folder sharing.

sudo useradd nick

05. Give the password for the user that has been created.

sudo smbpasswd -a nick

Enter the password you want to use

06. Create the samba group.

sudo groupadd samba

07. And add this user to the samba group.

sudo gpasswd -a nick samba

08. The samba group needs to have read, write and execute permission on the shared folder. 
You can grant these permissions by executing the following command.

sudo chown -R nick:root /hdd1

09. After that configure the samba filea.

sudo nano /etc/samba/smb.conf

add:

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

# The name of your Samba server
   netbios name = nameofserver

# Samba min and max protokol
   server min protocol = NT1
   server max protocol = SMB3_11
   client lanman auth = yes
   ntlm auth = yes

# The specific set of interfaces / networks to bind t
    interfaces = 192.168.1.0/24

#Then on the bottom line add the following script

[hdd1]
path = /hdd1
browseable = yes
guest ok = no
writable = yes
valid users = @samba

10. Restart smbd and nmbd.

sudo systemctl restart smbd nmbd
sudo systemctl status smbd nmbd
sudo systemctl start smbd nmbd

11. Samba ports.

  • TCP 139: used for file and printer sharing and other operations.
  • TCP 445: the NetBIOS-less CIFS port.
  • UDP 137: used for NetBIOS network browsing.
  • UDP 138: used for NetBIOS name service.

If you have enabled the UFW firewall, then you need to open the above ports in the firewall with the following command.

sudo ufw allow samba

Or if your local interfaces for example 192.168.1.0/24

sudo ufw allow from 192.168.1.0/24 to any

In this way, you give local network access to all ports on your server

12. To check which ports are open on your server.

netstat -tnl

---