SMB is a client-server, file-sharing protocol that stands for Server Message Block which was invented by IBM in 1984 for the purpose of allowing computers to access files for reading or writing on a remote host using the LAN (Local area network). The SMB protocol that makes available the files or directories that are accessed on the remote host are called shares. This means that we can mount a shared file or directory to our system using the local area network.
SMB was previously known as CIFS and is the old version or dialect of SMB which stands for Common Internet File System which was created by Microsoft and is a particular implementation of the Server Message Block protocol.
In this article, we will provide you with each and every little step on how to mount SMB shares on Ubuntu using the Samba file server. Samba uses the SMB protocol and has the same function as SMB i-e enabling file sharing on Local area networks with other systems. But before going forward let me highlight a point that this article assumes that you have already shared a directory on a remote system and you will access that directory in this article.
The first step is to update our apt packages by using the update command in our Ubuntu 20.04 terminal:
All our packages are up to date however if our packages are not up to date then we have to run the following command to upgrade:
Execute the command that is given below to install the cifs-utils package on Ubuntu system:
Let us now create a directory where we will mount the shared drive:
This step involves creating the credentials file in our home directory and with the use of .(dot) which is needed for security reasons that will make our file hidden. For this purpose execute the below command which will open the file in the nano editor:
You can replace the name of the file with whatever you want the file name to be:
Now that the file is opened type the following two lines in the file which will be our samba username and password:
You can replace the username and password to your preferred username and password and then press CTRL+S to save the file and CTRL+X to exit the file.
Next, we will make the /root/.examplecredentials file readable only and only for the root account hence will put restriction on all non-root accounts by executing the following command in our Ubuntu 20.04 terminal:
In this step we will execute the command which will mount the remote samba shared directory on our Ubuntu system:
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:
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.
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:
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:
Remember that you have to replace the IP Address with your IP Address after which press CTRL+S to save the above file and then press CTRL+X to close the file.
SMB is a file-sharing protocol created for the purpose of allowing computers to access remote systems files over a LAN network and CIFS is a particular dialect of SMB having almost the same functionality.
In this article, we showed you how to mount SMB share on Ubuntu 20.04 using the samba file server; however, the commands used were generic and can be applied on any Linux distribution.
One of the most critical gaps in traditional Large Language Models (LLMs) is that they…
Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…
What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…
Wouldn’t it be wonderful to wake up one day with a desire to explore AI…
Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…
Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…