Setup file sharing in Linux – SAMBA

Samba is open source implementation for SMB Protocol and CIFS protocol (definition SMB Protocol –  The Server Message Block Protocol (SMB protocol) is a client-server communication protocol used for sharing access to files, printers, serial ports and other resources on a network). Most modern Windows based systems use SMB2 or SMB3 while Linux uses Samba enables all network communication of Linux systems.

Installation of SAMBA

To install Samba use the dnf command ( Follow link for detailed article on DNF command usage – How to use DNF package manager command in Linux ).


dnf install samba samba-client

Enable SAMBA

By default SAMBA is not required for normal functioning of Linux systems. In case you require it you need to install it. Post installation if you want to start SAMBA at boot you need to enable it.


 sudo systemctl enable –now smb

Configure firewalld to allow SAMBA

To allow SAMBA to communicate from behind a firewall use the below command. In our system we are using firewalld as default firewall application.


sudo firewall-cmd –permanent –add-service=samba

For detailed guide on usage of firewalld refer our post 

How to configure Firewalld in Linux and top commands

Configure SAMBA serve

Samba server can be used to share directories as well as you can attach a printer to the linux system and use it for printing from the Windows system.

SAMBA configuration file 

Default samba configuration file is /etc/samba/smb.conf which can be used for sharing directories as well as printer.

For allowing your Linux system to join  the Windows workgroup, provide details of the Samba server by editing the following lines in your /etc/samba/smb.conf file



Now we will share a directory on the network. For this we will make below changes of our configuration file

Sample changes 


comment = Insert a comment here

path = /home/share/

valid users = allowed usernames

writable = yes

create mask = 0xxx



comment = This is internal share folder

path = /myfolder/

valid users = infojinx

writable = yes

create mask = 0765

Configure Printer Server on SAMBA server

In a big network where it’s required to manage print files, give selective rights for printing and Job prioritizing, one can you use print server

 Sample Configuration

comment = All Printers

path = /var/spool/samba

printer admin = provide username you want to make dmin

create mask = 0600

guest ok = Yes

printable = Yes

use client driver = Yes

browseable = Yes

Create spool folder

You will need to create a spool folder and give it required permission. Use the below commands for the same. 

mkdir -p /var/spool/samba/

chmod 1777 /var/spool/samba/

In global section add lines


printing = CUPS