rohan-ZoXCoH7tja0-unsplash

How to Mount SMB Shares on Ubuntu

SMB is a client-server, document-sharing protocol that stands for Server Message Block which became invented through IBM in 1984 for the motive of permitting computer systems to get right of entry to documents for analyzing or writing on a far flung host the usage of the LAN (Local location community). The SMB protocol that makes to be had the documents or directories which can be accessed at the far flung host are known as shares. This way that we will mount a shared document or listing to our device the usage of the nearby location community. SMB became formerly called CIFS and is the antique model or dialect of SMB which stands for Common Internet File System which became created through Microsoft and is a specific implementation of the Server Message Block protocol. In this text, we can offer you with every and each little step on the way to mount SMB stocks on Ubuntu the usage of the Samba document server. Samba makes use of the SMB protocol and has the equal characteristic as SMB i-e permitting document sharing on Local location networks with different structures. But earlier than going ahead let me spotlight a factor that this article assumes which you have already shared a listing on a far flung device and you’ll get right of entry to that directory in this article.

Step1: Updating and upgrading apt-cache repository

The first step is to update our apt applications through the usage of the update command in our Ubuntu 20.04 terminal:

sudo apt update

All our applications are updated but if our applications aren’t updated then we need to run the subsequent command to upgrade:

$ sudo apt upgrade

Step2: Cifs-utils Package installation

$ sudo apt install cifs-utils

Step3: Creating Directory

$ sudo mkdir /media/share

Step4: Creating Credentials document

This step entails developing the credentials document in our domestic listing and with the use of .(dot) which is wanted for safety motives with the intention to make our document hidden. For this motive execute the underneath command a good way to open the document withinside the nano editor:

$ sudo nano /root/.examplecredentials

You can replace the name of the document with anything you need the document call to be:

Now that the document is opened kind the subsequent strains withinside the document a good way to be our samba username and password:

username=example_username
password=example_password

Next, we can make the /root/.examplecredentials document readable best and best for the foundation account for this reason will put restrict on all non-root money owed through executing the subsequent command in our Ubuntu 20.04 terminal:

$ sudo chmod 400 /root/.examplecredentials

Step5: Mount samba share

In this step we will execute the command which will mount the remote samba shared directory on our Ubuntu system:

$ sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.examplecredentials
//192.168.18.112/sharedDir /media/share

Replace the IP Address in the above command where you have already shared a directory or folder on the remote system and if that is Ubuntu system then you can find the IP address with ip a command:

ip a

The IP address of the remote Ubuntu system from where sharedDir was shared is “192.168.18.112” which was provided in the above mount command.

Step6: Automount on system reboot

The manually mounted file system in the above step will not be mounted once our Ubuntu/system reboots, hence to solve this problem first we will open the /etc/fstab file in nano editor and then add some configuration to that file. To open the /etc/fstab file in the nano editor execute the following command:

sudo nano /etc/fstab

The above command will open /etc/fstab file and you will see something like shown below on your system screen:

Now add the following line in the file that was opened with the nano editor:

//192.168.18.112/share /media/share cifs vers=3.0,credentials=/.examplecredentials

Remember that you need to update the IP Address together along with your IP Address and then press CTRL+S to save the above document after which press CTRL+X to close the document.

Conclusion

SMB is a document-sharing protocol created for the motive of permitting computer systems to get right of entry to far flung structures documents over a LAN community and CIFS is a specific dialect of SMB having nearly the equal functionality. In this text, we confirmed you the way to mount SMB proportion on Ubuntu 20.04 the usage of the samba document server; but, the instructions used have been accepted and may be implemented on any Linux distribution.

Tags:

samba linux, linuxserver samba, samba unix, smbclient example, smbclient linux, ubuntu smb client, ubuntu 20.04 samba client

One Response

Add a Comment

Your email address will not be published. Required fields are marked *