Atlantic.Net Blog

How to Install and Configure Samba Server on Arch Linux

Hitesh Jethva
by Atlantic.Net (509 posts) under Dedicated Server Hosting, Tutorials
0 Comments

Samba, also known as “Server Message Block,” is a protocol that provides file and print services between clients across various operating systems. Samba allows us to access and use files, printers, and other commonly shared resources on a local intranet. It can be run on Unix/Linux-based platforms and is able to communicate with Windows clients.

In this tutorial, we will show you how to install and configure the Samba server on Arch Linux.

Prerequisites

  • A fresh Arch Linux server on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Arch Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Step 2 – Configure Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirrorlist configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.8, United States
Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.9, United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## Score: 1.5, United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
## Score: 6.6, United States
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
## Score: 6.7, United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
## Score: 6.8, United States
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
## Score: 7.1, India
Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
## Score: 10.1, United States
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch

Save and close the file then update all the package indexes with the following command:

pacman -Syu

Step 3 – Install Samba Server

By default, the Samba server package is included in the Arch Linux default repository. You can install it easily with the following command.

pacman -S samba smbclient

After installing the Samba server, you can verify the Samba version using the following command.

smbd --version

You should see the following output.

Version 4.17.4

Step 4 – Create a Public Share in Samba

In this section, we will show you how to create a public share in Samba. Anyone can access the public share without providing a user and password.

First, create some files and directories for the public share with the following command.

mkdir -p /samba/public
touch /samba/public/public1
touch /samba/public/public2

Next, set proper ownership to the public share directory.

chown -R nobody:nobody /samba

Next, create a Samba configuration file and define your public share:

nano /etc/samba/smb.conf

Add the following configuration:

[Public]
comment = public share
path = /samba/public
browseable = yes
writable = yes
guest ok = yes

Save and close the file, then restart both smb and nmb services to apply the changes.

systemctl start smb nmb

You can also verify the Samba configuration file using the following command.

testparm

You will get the following output.

# Global parameters
[global]
	idmap config * : backend = tdb


[Public]
	comment = public share
	guest ok = Yes
	path = /samba/public
	read only = No

Step 5 – Create a Private Share in Samba

In this section, we will show you how to create a private share in Samba. A private share is password protected, so the user will need to provide user name and password to access the private share.

First, create a directory and files for the private share.

mkdir -p /samba/private
touch /samba/private/private1
touch /samba/private/private2

Next, create a user for the private share with the following command:

useradd smbuser
smbpasswd -a smbuser

Set a password as shown below:

New SMB password:
Retype new SMB password:
Added user smbuser.

Next, edit the Samba configuration file and define your private share.

nano /etc/samba/smb.conf

Add the following configuration:

[Private]
comment = private share
path = /samba/private
browseable = yes
guest ok = no
writable = yes
valid users = smbuser

Save and close the file then restart both smb and nmb services to apply the changes.

systemctl restart smb nmb

Step 6 – Verify Public and Private Share

To verify the Samba share, you will need to install the Samba client package on the remote system. You can install it with the following command.

pacman -S smbclient

Next, verify all Samba shares using the following command.

smbclient -L samba-server-ip

You will be asked to provide the password:

Password for [WORKGROUP\root]:

Just press the Enter key. You should see both public and private shares in the following output.

Anonymous login successful

	Sharename       Type      Comment
	---------       ----      -------
	Public          Disk      public share
	Private         Disk      private share
	IPC$            IPC       IPC Service (Samba 4.17.4)
SMB1 disabled -- no workgroup available

To access the private share, run the following command.

smbclient //samba-ip-address/private -U smbuser

You will be asked to provide a password for smbuser:

Password for [WORKGROUP\smbuser]:

Provide your password then press the Enter key. You will get into the Samba shell:

Try "help" to get a list of possible commands.
smb: \>

Now, list your files and directories inside the private share with the following command.

smb: \> ls

Output.

  .                                   D        0  Wed Jan  4 10:47:34 2023
  ..                                  D        0  Wed Jan  4 10:47:24 2023
  private2                            N        0  Wed Jan  4 10:47:34 2023
  private1                            N        0  Wed Jan  4 10:47:29 2023

		51473020 blocks of size 1024. 46301492 blocks available

Now, exit from the Samba shell with the following command.

smb: \> exit

You can access the public share with the following command.

smbclient //samba-ip-address/public

You will be asked to provide a password.

Password for [WORKGROUP\root]:

Just press the Enter key to connect to Samba.

Anonymous login successful
Try "help" to get a list of possible commands.

Now, verify all files and directories inside the public share.

smb: \> ls

You will get the following output.

  .                                   D        0  Wed Jan  4 10:45:29 2023
  ..                                  D        0  Wed Jan  4 10:47:24 2023
  public2                             N        0  Wed Jan  4 10:45:29 2023
  public1                             N        0  Wed Jan  4 10:45:24 2023

		51473020 blocks of size 1024. 46301492 blocks available
smb: \> 

Conclusion

In this tutorial, we explained how to install the Samba server on Arch Linux. We also explained how to create a public and private share in Samba. You can now deploy the Samba server in your organization to share files and printers. You can try out a Samba server on dedicated server hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Install Netdata Monitoring Tool on Arch Linux
How to Install Vue.js on Arch Linux
How to install Monit Monitoring Tool on Arch Linux
Top 10 Best Cloud HR / HRMS Solutions in 2023
Install and Configure Network Time Protocol (NTP) on Arch Linux

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Garland, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources