Featured image of post Samba

Samba

My way to install and configure samba

Samba

Depends on which linux you are, use your package manager, in this post I’ll use apt for Debian or derivates. For arch you can use pacman/yay/paru or whatever.

Install samba

1
2
sudo apt update
sudo apt install samba 

Check if it was installed

1
whereis samba

the output must to be something like samba: /usr/lib/samba

Config

Make a dir

Make the folder to share, u can put it where you want and with the name that u want, if you want to have a folder on your home

1
mkdir ~/smbshare

Samba config

Edit samba config on /etc/samba/smb.conf

1
sudo nvim /etc/samba/smb.conf

At the end of file add your share

1
2
3
4
5
[sambashare]
    comment = Samba Share
    path = /home/username/sambashare
    read only = no
    browsable = yes

Save and exit with :wq

Restart samba service

1
sudo systemctl restart smbd

Setup an user for samba

1
sudo smbpasswd -a username

Accessing Network Shares

Prerequisites

First, install the necessary utilities:

1
sudo apt-get install cifs-utils smbclient

Temporary Mount (Manual Method)

  1. Create a local directory where you’ll mount the network share:
1
sudo mkdir /media/share_name
  1. Mount the network share using this command:
1
sudo mount -t cifs //server/share_name /media/share_name -o username=samba_user,password=your_password

Where:

  • server is the hostname or IP of the computer sharing the folder
  • share_name is the name of the shared resource
  • samba_user is the user (local or domain) with access permissions

Example:

1
sudo mount -t cifs //192.168.0.20/smbshare /home/user/Documents/share -o username=user123,password=pass123

Permanent Mount (via fstab)

To make the mount persistent across reboots, edit /etc/fstab:

1
sudo nvim /etc/fstab

Add this line:

1
//server/share_name  /media/share_name  cifs  username=samba_user,password=your_password,noexec,user,rw,nounix,uid=1000,iocharset=utf8  0  0

For a more robust configuration that handles network delays and systemd integration:

1
//server/share_name  /local/mount_point  cifs  username=samba_user,password=your_password,iocharset=utf8,uid=local_user,gid=local_group,forceuid,forcegid,cifsacl,noauto,x-systemd.automount,_netdev  0  0

Key additional options:

  • noauto,x-systemd.automount: Delays mounting until first access
  • _netdev: Ensures network is available before mounting

Extras

For more detailed information, consult these Arch Linux wiki pages (which are excellent resources even for non-Arch users):