Follow through this tutorial to learn how to access Samba share on Linux and Windows systems. In our previous guide, we learnt how to install and configure standalone Samba server Share on Ubuntu 20.04.
Easily Install and Configure Samba File Server on Ubuntu 20.04
Accessing Samba Share on Linux and Windows Systems
First off, verify that you can access the share locally from the Samba share server itself.
Verify access to the public share;
smbclient '\\192.168.59.14\publicshare'
When prompted for password, just press ENTER.
Enter WORKGROUP\root's password:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Tue Jun 8 17:50:10 2021
.. D 0 Mon Jun 7 19:09:46 2021
demofolder-pub D 0 Tue Jun 8 17:47:46 2021
demofile-pub N 0 Tue Jun 8 17:50:10 2021
24697168 blocks of size 1024. 15255920 blocks available
smb: \>
Verify access to the Private share;
smbclient '\\192.168.59.14\privateshare' -U demouser
When prompted for password, enter the user’s smb password created above;
Enter WORKGROUP\demouser's password:
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Tue Jun 8 17:50:10 2021
.. D 0 Mon Jun 7 19:09:46 2021
demofile1 N 0 Tue Jun 8 17:44:32 2021
demofolder-priv D 0 Tue Jun 8 17:47:39 2021
demofile-priv N 0 Tue Jun 8 17:50:10 2021
24697168 blocks of size 1024. 15255920 blocks available
smb: \>
Accessing Samba Share from Windows System
Login to Windows, we are using Windows 7, in this example and right on click Computer (This PC on others) > Map Network drive.
Enter the Shared folder path;
Enter the credentials.
Access the share
Accessing Samba Share on from Linux systems:
To access the share from the Linux systems, you need to install the Samba client utilities.
On Ubuntu;
sudo apt install smbclient cifs-utils
Listing available samba shares:
smbclient -L 192.168.59.14 -U demouser
Enter SAMBA\demouser's password:
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
publicshare Disk
privateshare Disk
IPC$ IPC IPC Service (ubuntu20 server (Samba, Ubuntu))
SMB1 disabled -- no workgroup available
Access the share;
smbclient '\\192.168.59.14\privateshare' -U demouser
Enter WORKGROUP\demouser's password:
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Tue Jun 8 22:00:04 2021
.. D 0 Mon Jun 7 22:09:46 2021
Windows Folder D 0 Tue Jun 8 21:59:54 2021
demofile1 N 0 Tue Jun 8 20:44:32 2021
demofolder-priv D 0 Tue Jun 8 20:47:39 2021
demofile-priv N 0 Tue Jun 8 20:50:10 2021
24697168 blocks of size 1024. 15253132 blocks available
smb: \>
You can also mount the share. For example, to mount the public share;
mount -t cifs -o vers=3.0,username=demouser '\192.168.59.14\privateshare' /mnt
Enter the password.
Verify mount points:
df -hT -P /mnt/
Filesystem Type Size Used Avail Use% Mounted on
\\192.168.59.14\privateshare cifs 24G 9.2G 15G 39% /mnt
ls -1 /mnt/
demofile1
demofile-priv
demofolder-priv
'Windows Folder'
On CentOS and Similar derivatives:
yum install samba-client samba-common cifs-utils -y
Access a share;
smbclient '\\192.168.59.14\publicshare'
Enter SAMBA\root's password:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Tue Jun 8 20:50:10 2021
.. D 0 Mon Jun 7 22:09:46 2021
demofolder-pub D 0 Tue Jun 8 20:47:46 2021
demofile-pub N 0 Tue Jun 8 20:50:10 2021
24697168 blocks of size 1024. 15135168 blocks available
smb: \>
Mounting the Shares;
mount -t cifs -o username=demouser //192.168.59.14/publicshare /media/
mount -t cifs -o username=demouser //192.168.59.14/privateshare /mnt/
Use the demouser
password when prompted.
df -hT -P /media/ /mnt/
Filesystem Type Size Used Avail Use% Mounted on
//192.168.59.14/publicshare cifs 24G 9.2G 15G 39% /media
//192.168.59.14/privateshare cifs 24G 9.2G 15G 39% /mnt
AutoMount Samba Shares on Reboot
If you want the share to be automatically available during a system reboot, you can:
- simply click Reconnect on Logon while mapping network drive on Windows
- update the Filesystem table on Linux as shown below
Update the /etc/ftab with an entry such as
vim /etc/fstab
//192.168.59.14/privateshare /mnt cifs username=demouser,password=password,_netdev 0 0
Be sure to replace the username and password.
If you dont want to use the credentials on the entry, you can use a credentials file:
vim /etc/.smb
username=demouser
password=password
Next, update the fstab entry such that it look like;
//192.168.59.14/privateshare /mnt cifs credentials=/etc/.smb,_netdev 0 0
Next, check the mounting by running;
mount -a
df -hT -P /mnt/
Filesystem Type Size Used Avail Use% Mounted on
//192.168.59.14/privateshare cifs 24G 9.7G 14G 41% /mnt
And there you go. You should now be able to auto-mount the Samba share on boot and be able to access your shared folders.
Other Tutorials
Setup Software RAID on Ubuntu 20.04