Install Samba Client to Access Shared Directories by Server

We have already installed Samba Server to share directories from our PC. Lets install a sambaclient to access those shared directories.

Install samba client

$ sudo pacman -S smbclient

Configure the samba client, you can create an empty conf file.

$ sudo touch /etc/samba/smb.conf

Ok all done, lets explore the server

$ smbtree -b -N

The above will show all shared hosts

To query specific one, my server name is TECNOTCH

$ smbclient -L TECNOTCH -U%

Lets mount the shared directory to our file system so we can access it through terminal or file manager
Create a directory where the shared directory will be mounted

$ sudo mkdir /mnt/TECNOTCH

mount shared folder on server TECNOTCH to /mnt/TECNOTCH

I have my shared directory entry as follow in SAMBA server configuration when installing SAMBA on server.

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

So my share name is shared, the name of section [shared]

//TECNOTCH/shared represents //ServerName//section-name-of-shared-directory

$ sudo mount -t cifs //TECNOTCH/shared /mnt/TECNOTCH -o username=tofeeq,password=mypassword,workgroup=DEVTEAM,iocharset=utf8,uid=1000,gid=users,vers=3.1.1,nodfs --verbose

If you don’t see any error that means shared directory on server is mounted on my local directory

You can start accessing shared folders.

You can add that mount entry to /etc/fstab so it would be auto-mount on access

$ sudo vi /etc/fstab

Append following line at the end

//TECNOTCH/shared 	/mnt/TECNOTCH cifs 	x-systemd.automount,username=tofeeq,password=mypassword,workgroup=DEVTEAM,iocharset=utf8,uid=1000,gid=users,vers=3.1.1 0 0

To automount shared directories on boot start systemd-networkd-wait-online.service

$ sudo systemctl enable systemd-networkd-wait-online.service
$ sudo systemctl start systemd-networkd-wait-online.service

One thought on “Install Samba Client to Access Shared Directories by Server

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s