23 C
Texas

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let’s discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows Systems, CIFS or SMB is the way to go. The CIFS protocol is a server-client model. The system that host file to share, need to run Samba server as well.CIFS is an extension of SMB or server message block, a protocol developed by Microsoft. In Linux, we can use Samba software to connect CIFS-SMB shares. Also, in a basic set of default samba configurations, there is a list of shares or locations. By default, these locations with few restrictions are available too for the remote client to access.

Samba services how work with Ubuntu 20.04 LTS, this is what we will learn today. Let’s begin.

What you will learn:

  1. Installing the package, with examples.
  2. How to configure services.
  3. Finally, how to mount and use samba shares.

Pre Requisites:

  1. An Ubuntu 20.04 LTS Machine.
  2. Also, MS Windows Desktop.
  3. Samba packages, of course for Ubuntu.
  4. Good internet connectivity.
- Advertisement -

Get Samba File share services ready:

Let’s get the Server ready first. Go and download Ubuntu OS. Second, install all required software as well.

Make required file changes

Update system

apt update
Update Ubuntu System
Update Ubuntu System

Install samba packages

#apt install samba
Install samba packages
Install samba packages

Let’s have a look is samba services are running proper or not?

# systemctl status smbd
check if samba service working fine
check if samba service working fine

Let’s see which files are visible in Samba default directory, will look something like below:

#cd /etc/samba/ && ls
gdbcommands smb.conf tls

Edit smb.conf file, it is recommended to take a backup of original file first.

Create a shred directory which you would be using to get accessed from MS Windows client, in our example we created folder named as “sambashare”.

# mkdir /home/ubnt/sambashare

Let’s edit /etc/samba/smb.conf file, Make required changed as per below, add changes at bottom of the .conf file:

# nano /etc/samba/smb.conf  
[Samba-Windows-Share]  
comment = for windows share
path = /home/ubnt/sambashare
read only = no
browsable = yes

Press ctrl+o followed by ctrl+x to save and exit from file.

make changes in smaba.conf file
make changes in smaba.conf file

Allow samba on firewall and start service.

#ufw allow samba
Rules updated
Rules updated (v6)

#service smbd restart

Setup Samba password and access shared folder

As, samba do not use default user’s password. Let’s defile samba password for existing user, in our case user is ubnt.

# sudo smbpasswd -a ubnt
assign password to samba user
assign password to samba user

Change file permissions for shared folder, so that end user can add or remove files, defile permissions as per your need.

# chmod 777 /home/ubnt/sambashare/

Now, Samba server is ready, lets switch to MS Windows and see. Open Run and provide Samba server IP Address. In our scenario that IP address was 192.168.1.239.

open run to browse shared folder
open run to browse shared folder

press enter, shared folder creds which we have created in previous step is visible:

You can see shared folder for samba
You can see shared folder for samba

Give user id and password created recently with smbpasswd command, in my scenario first attempt login didn’t work, but don’t worry, give another try. it will work.

give user id and password
give user id and password

Lets try to create folder or file and see, whether that file is visible in Linux Machine or not. I have created Test_Folder and Test_File.

try to create folder and files
try to create folder and files

Lets have a look in Ubuntu Samba server, if these files are visible or not.

let's have a look in samba server
let’s have a look in samba server

Bingo! we have created and tested samba server successfully. Give a try!!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

4 COMMENTS

  1. How to troubleshoot? My linux server is pingable from my windows laptop. The ss -pant | sort -k 6 command clearly shows that smbd is listening on ports TCP 445 and 139 on both IPv4 and IPv6. I have nmbd running as well, but it’s listening on UDP ports. 137 and 138. I looked at iptables and I see:
    root@jeffs-desktop:/etc/samba# iptables -L -n | fgrep -i udp
    ufw-skip-to-policy-input udp — 0.0.0.0/0 0.0.0.0/0 udp dpt:137
    ufw-skip-to-policy-input udp — 0.0.0.0/0 0.0.0.0/0 udp dpt:138
    ufw-skip-to-policy-input udp — 0.0.0.0/0 0.0.0.0/0 udp dpt:67
    ufw-skip-to-policy-input udp — 0.0.0.0/0 0.0.0.0/0 udp dpt:68
    ACCEPT udp — 0.0.0.0/0 0.0.0.0/0 udp spt:67 dpt:68
    ACCEPT udp — 0.0.0.0/0 224.0.0.251 udp dpt:5353
    ACCEPT udp — 0.0.0.0/0 239.255.255.250 udp dpt:1900
    ACCEPT udp — 0.0.0.0/0 0.0.0.0/0 ctstate NEW
    ACCEPT udp — 0.0.0.0/0 0.0.0.0/0 multiport dports 137,138 /* ‘dapp_Samba’ */
    root@jeffs-desktop:/etc/samba#

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article