Linux Configuration
About Lesson

Samba is an open-source software suite that runs on Unix/Linux based platforms but is able to communicate with Windows clients like a native application. So Samba is able to provide this service by employing the Common Internet File System (CIFS).

Samba can be run on many different platforms including Linux, Unix, OpenVMS and operating systems other than Windows and allows the user to interact with a Windows client or server natively. It can basically be described as the Standard Windows interoperability suite of programs for Linux and Unix.


How to setup Samba Server on Ubuntu?

Let’s take a look at setting up a Samba Server on Ubuntu to share files with Windows clients. Note that we will create two forms of Samba server, one setup won’t require a password to share files with any client on the network which is the anonymous share and another setup will require setting up users and permissions.

Server Side Configuration:

1. Installation Of Samba

We install the samba package from the terminal in Ubuntu with the following code –

  1. sudo apt-get update
  2. sudo apt-get install samba

2. Configure File Server – Anonymous Share

a. Create a shared folder called “shared folder”.

sudo mkdir -p /srv/samba/sharedfolder

b. ​Allow anyone to access and store files in folder.

sudo chown nobody:nogroup /srv/samba/sharedfolder/

c. Edit configuration file to enable sharing.​

Make a backup of the configuration file before editing

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

Open the conf file and make the following changes –

sudo vi /etc/samba/smb.conf

Add the following at the end of the file to enable sharing – d. Restart smbd service –

sudo systemctl restart smbd.service nmbd.service

3. Configure File Server – Secured Share

a. ​Create shared folder called “securedfolder”.

sudo mkdir -p /srv/samba/securedfolder

b. ​Create a new user group named “selected”.


sudo addgroup selected

c. ​Modify permission and ownership for the folder.

sudo chown root:selected /srv/samba/securedfolder/
sudo chmod 770 /srv/samba/securedfolder/

d. Edit configuration file to allow sharing

​Make a backup of the configuration file before editing.

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

Open the conf file and make the following changes –

sudo vi /etc/samba/smb.conf

Add the following at the end of the file to enable sharing –

comment = secured shared folder
path = /srv/samba/securedfolder
Valid users = @selected
guest ok = no
writable = yes
browsable = yes

e. Restart smbd service –

sudo systemctl restart smbd.service nmbd.service

f. ​Once Samba has restarted, use this command to check your smb.conf for any syntax errors. testparm g. Add new users

​We are going to create and add a user “hackonology” to the user group “selected” with restricted shell access. sudo useradd hackonology -s /usr/sbin/nologin -G selected To add a password for the user –

sudo smbpasswd -a hackonology

h. Add existing user Jane to the group to the group “selected”.

sudo usermod hackonology -G selected

The Samba and NetBios Nameservice or NMB services have to be enabled and then started for them to take effect:

systemctl enable smb.servicesystemctl start smb.servicesystemctl enable nmb.servicesystemctl start nmb.service


In case the services were already running, you may have to restart them again:

systemctl restart smb.servicesystemctl restart nmb.service


If you are not using systemctl command, you can alternatively start the Samba using a more classic way:

hackonology@linux~:service smb start
Starting SMB services:  [OK]

Client Configuration:

First you need to install the samba software:

$ yum -y install samba samba-client cifs-utils

Note: It’s recommended to install the samba server software on all samba clients.

Then we create our mount point:

$ mkdir -p /mnt/backups

Then we create a group that mirrors the same group that existing on the samba server:

$ groupadd --gid 2000 sambagroup

Now we need to add members to that group, in our case we’ll add the root user:

$ usermod -aG sambagroup root

Next we need check if we can connect to the samba server, and if we can to also check what shares are available:

$ smbclient -L //samba-storage.local -U samba_user1
Enter SAMBA\samba_user1's password:
Domain=[SAMBA-STORAGE] OS=[Windows 6.1] Server=[Samba 4.6.2]

	Sharename       Type      Comment
	---------       ----      -------
	print$          Disk      Printer Drivers
	bckp_storage    Disk      Folder for storing backups
	IPC$            IPC       IPC Service (Samba server samba-storage)
	samba_user1     Disk      Home Directories
Domain=[SAMBA-STORAGE] OS=[Windows 6.1] Server=[Samba 4.6.2]

	Server               Comment
	---------            -------

	Workgroup            Master
	---------            -------

Now we can test this by manually mounting this share like this:

$ mount -t cifs -o user=samba_user1,password=password123 //samba-storage.local/export_rw /mnt/export/

You can check if this command has worked using the mount or df -h commands.

To unmount this, do:

$ umount /mnt/backups

If you has, then you automount this samba share at boot time by adding the following entry to the /etc/fstab file:

//samba-storage.local/bckp_storage /mnt/backups  cifs  username=samba_user1,password=password123,soft,rw  0 0

To test this line, just run:

$ mount -a

Then check again if this has mounted successfully using mount or df -h commands. If all is well try creating dummy content in the mountpoint and see if the content also shows up on the samba server.

Let’s Join our Hacking Team

We Are Indian We Are Great

Hope this article helpful for you. Thank You

Indian Cyber Army | Make IT Secure

Enjoy…Stay Happy…Stay Secure…

Hope this article helpful for you. Thank You

If You Appreciate What We Do Here On Hackonology, You Should Consider:

Hackonology is the fastest growing and most trusted community site where you can find lots of courses, articles about Technology/Hacking/Cracking. Millions of people visit Hackonology! to search or browse the thousands of published articles available FREELY to all.

Let's be a part of Hacker's Community! Join our Hacking Team

We Are Indian We Are Great