Mathan Kumar

Solution Engineer

System Engineer

DevOps ENgineer

Ethical Hacker

Cyber Security

Mathan Kumar

Solution Engineer

System Engineer

DevOps ENgineer

Ethical Hacker

Cyber Security

Blog Post

Ubuntu: Setting Up SAMBA for File Sharing

December 1, 2023 Linux, Network

1.Introduction

A Samba file server enables file sharing across different operating systems over a network. It lets you access your desktop files from a laptop and share files with Windows and macOS users.

1.1What you’ll learn

  • How to set up a Samba file server
  • How to share files across a local network

1.2What you’ll need

  • Ubuntu 16.04 LTS
  • A Local Area Network (LAN) to share files over

If you have everything ready, let’s dive straight into the installation process on the next step!

2.Installing Samba

To install Samba, we run:

sudo apt update
sudo apt install samba

3.Setting up Samba

With Samba successfully installed, the next step involves creating a directory for sharing purposes:

mkdir /home/{username}/sambashare/

The aforementioned command generates a new folder named ‘sambashare‘ in our home directory, intended for future sharing purposes.

The configuration file for Samba is located at /etc/samba/smb.conf. To add the new
directory as a share, we edit the file by running:

sudo gedit /etc/samba/smb.conf

After adding the following lines at the bottom of the file, proceed to save and close the gedit text editor.

[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes

3.1What we’ve just added

  • [sambashare]: The name inside the brackets is the name of our share.
  • comment: A brief description of the share.
  • path: The directory of our share.
  • read only: Permission to modify the contents of the share folder is only granted when the value of this directive is no.
  • browsable: When set to yes, file managers such as Ubuntu’s default file manager will list this share under “Network” (it could also appear as browsable).

Now that we have our new share configured, save it and restart Samba for it to take effect:

sudo service smbd restart

4.Setting up User Accounts and Connecting to Share

Given that Samba doesn’t rely on the system account password, the next step involves setting up a Samba password for our user account:

sudo smbpasswd -a username

Note:Username used must belong to a system account, else it won’t save.

Related Posts
Write a comment