Create a Network Share in Linux using Samba via CLI and access using Samba Client

Setting up the share on Linux

Install Samba:

For creating a secured share, make a system account for authentication to access samba shares, here I named the user “shareuser” in an obvious way you can, of course, pick any name:

Check if the user has been added successfully:

Add this account in smbpasswd file to be used by samba authentication:

Configure the “shared” directory (or whatever you choose to name your directory that is to be shared):

Make a safe backup copy of the original smb.conf file to your home folder, in case you make an error:

Edit Samba configuration file “/etc/samba/smb.conf” and add the following at the very end of the file:

Restart smb and nmb services of the system:

Use testparm command to check your smb.conf for any syntax errors:

Thus, we created a shared folder named “shared” with “shareuser” as the username to be used for accessing this folder on another machine.

Access the SMB network share on Linux:

Installing Samba client will give you a CLI to work with your SMB share:

List all shares available on the host using the IP address or hostname:

Here <user> is the user we created in the host machine. Connect to the shared folder using:

Note: The default user group of samba is "WORKGROUP".

You can type ‘h’ to get help with smbclient. For instance ‘ls’ would show the contents of the shared folder:

Troubleshoot Option- If you’re getting permission denied error when trying to modify the content of the shared folder, modify ownership and permission for the folder:

Full Stack Web Developer | Graduate student of MS in Computer Science at The University of Texas at Rio Grande Valley

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store