Published March 12, 2018 by

Create Network Share File/Folder via Samba on Linux

Samba is an SMB/CIFS networking protocol is used for providing file and print services for Microsoft clients. Samba also can be used as part of Active Directory domain. Samba uses TCP/IP protocol for communication. Normally we can use samba for file sharing.
In this tutorial, we will learn how to install samba and file sharing in samba.

Install Samba

Install samba using the following command:

# sudo yum install samba                                   For CentOS/Redhat
# sudo dnf install samba                                    For Fedora
# sudo apt install samba                                    For Debian

Create User for Samba

Create a system account for authentication to access samba shares.

# sudo adduser subhash
# sudo passwd subhash

Here it will ask for a password for user 'subhash'.

Also, add this account in smbpasswd file to be used by samba authentication.

# smbpasswd -a subhash

Create share directory

Now, create which directory who wants to share.

# sudo mkdir /opt/shared

Add below configuration in Samba configuration file /etc/samba/smb.conf at the bottom of the file.


[shared]
comment = Public Stuff
path = /opt/shared
public = yes
writable = yes
valid users = subhash
write list = subhash

Restart Samba Services

Now, Restart smb and nmb services.

# systemctl restart smbd.service
# systemctl restart nmbd.service

Acess Share folder

To test your setup, you need to access shared location from windows system. Open run window on your Windows operating system and type IP address of samba system's IP.


If it will prompt for authentication, To authorize use account created in step 2.