Samba smb share files

Full details can be found at:

Installing Samba using Ubuntu’s package

sudo apt-get update
sudo apt-get install samba -y

Add users to Samba

Users logging into a Samba share must either have accounts on the server or log in as a guest.

# Create a tux user if if not existed
sudo adduser -g staff --create-home tux
# Set a password for tux
passwd tux

Create Samba password for tux. It's managed by Samba own database of users and passwords, not above server password. It's recommended to set the Samba password same as server password so user don't need to remember more passwords.

# First time enter Samaba password
sudo smbpasswd -a tux

# Update Samba password
sudo smbpasswd tux

# Restart smbd
sudo systemctl restart smbd.service

Configuring the Samba Shares in /etc/samba/smb.conf

Share all user's home directories to their owner

#=== Share Definitions ====
comment = Home Directories
browseable = no
read only = no
create mask = 0755
directory mask = 0755
valid users = %S

Mounting Samba shares


sudo apt install cifs-utils -y

sudo mkdir /media/my_mount_path

# Put this into /etc/fstab
//SAMBA_SERVER_IP_OR_DOMAIN/SHARED_PATH /media/my_mount_path cifs rw,iocharset=utf8,username=MY_USER,password=MY_PASSWORD,iocharset=utf8,vers=2.0,file_mode=0775,dir_mode=0775,nodfs,actimeo=60 0 0

# Consider to remove actimeo=60 to check if it's faster or not


# Or we can put username and password into a root file

sudo vi /root/.smbcredentials


sudo chmod 550 /root/.smbcredentials

# Put this into /etc/fstab
//SAMBA_SERVER_IP_OR_DOMAIN/SHARED_PATH /media/my_mount_path cifs rw,iocharset=utf8,credentials=/root/.smbcredentials,iocharset=utf8,vers=2.0,file_mode=0775,dir_mode=0775,nodfs,actimeo=60 0 0

# Mount it
sudo mount -v /media/my_mount_path

# Unmount
sudo umount /media/my_mount_path
# Unmount forced
sudo umount -l /media/my_mount_path


On GUI, just open \\SAMBA_SERVER_IP_OR_DOMAIN and input username & password

On cmd or powershell

net use X: /delete