Arch Linux / Linux / Sharing · August 10, 2018 5

Setting up Samba Sharing Server on Arch Linux

Samba facilitates file and printer sharing among Linux and Windows systems. To share contents of linux server there should be a sharing server running, mostly Samba is used as sharing server on linux machines.

Follow the steps below to install Samba on PC where you need to share files.

Install Samba

# pacman -S samba

Create configuration file for Samba, it is required but not automatically created when installing samba so have to manually create it.

# vi /etc/samba/smb.conf

Copy the content from Sample Configuration from Samba Git Repo and paste in above file.

Lets modify configuration to get it working.

For better security provide min protocol and max protocol versions, add protocols in global section.

[global]
server min protocol = NT1
server max protocol = SMB3

Set workgroup, you can set your own workgroup name, I set it DEVTEAM

workgroup = DEVTEAM

Set server description, this is visible when querying server from samba client, my PC host name is TECNOTCH

server string = Samba Server on TECNOTCH

Change the default log file path as it is not writable, set it to

log file = /var/log/samba/%m.log

Restrict home directories being shared, add ; before every line in [homes] section

;[homes]
;comment = Home Directories
;browseable = no
;writable = yes

At the end of file uncomment [myshare] section and change as required, this is the share name that appears on client, I changed [myshare] to [shared]

[shared]
comment = TECNOTCH Shared Files
path = /mnt/data/shared
valid users = tofeeq anyotheruser1 anyotheruser2
public = no
writable = yes
printable = no
create mask = 0765

We have done configurations, Great. Now save the file using :wq and add users to samba server

Samba server requires user to access user shared directories if those are not public, Samba shares the linux system user name but maintains its own password.
So we don’t have to actually add the user but we are going to add a password in Samba list.

# smbpasswd -a tofeeq

Type your password and enter

You can change password later by using

# smbpasswd tofeeq

Create the shareable directory
Remember we have created a [shared] section in smb.conf file? There we have configured path for shareable directory

[shared]
comment = TECNOTCH Shared Files
path = /mnt/data/shared

Create a directory shared in /mnt/data location

# mkdir -p /mnt/data/shared

Change ownership of file to the user that was added in samba, in my case it was tofeeq, assign ownership to tofeeq for /mnt/data/shared directory

#chown -R tofeeq:users /mnt/data/shared

Cool, all setup now start the samba server

# systemctl start smb.service
# systemctl start nmb.service

You can set them autostart on system boot

# systemctl enable smb.service
# systemctl enable nmb.service

Congratulations, your samba server is up and running, now you can access your linux server’s shared folders from any other pc including windows. To access them on linux you need to have samba client and mount network directory.