FortiClient

Systems

Microsoft

Linux

How to Setup Samba File Shares in Linux – Quick and Easy

 


First of all if you didn't install the Samba, please use the below command to install it.

sudo apt update

sudo apt install samba

And you can check it whether it install or not using the below command.

whereis samba

If it successfully install you can get the some output related to the Samba, if not there is no output to visible.


Before config the Samba in your Linux environment, please backup your previous Samba configuration file if you already have the some Samba sharing settings. if not you can start it as the fresh configuration.


Please use the below command to backup the already having Samba configuration file.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

As a second step please create the folder you want share using the Samba,

mkdir /<path>/<FolderName>/

Now we can assign the permission for folder.

sudo chmod -R 0775 /<path>/<FolderName>

If you want you can check the permission using below command.

sudo chown -R nobody:nogroup /<path>/<FolderName>

Finally we need to configure the directory as a share using Samba configuration file.

sudo nano /etc/samba/smb.conf

It is locate the above path and you can open it using the above command.

Please add the below settings to the configuration file.

[FolderName]

comment = FolderName

path = /<path>/<FolderName>

public = yes

writable = yes

guest ok = yes

browsable = yes

read only = no

force user = nobody

Then press "Ctrl-O" to save it and "Ctrl-X" to exit from the nano text editor.

After that we need to restart the Samba and please use the below command to restart it.

sudo systemctl restart smbd

or

sudo service smbd restart

Now you can access it from your Windows or Linux environment using the below commands.

Windows,

\\ip-address\<FolderName>

Linux,

smb://ip-address/<FolderName>