Setting up a shared network folder on a Linux device is an effective way to share data across devices and users. It ensures that your information is promptly accessible to those who need it. In this tutorial, we will discuss how to mount an SMB share on Linux.
SMB or Server Message Block is a protocol for sharing files, printers, serial ports, and other resources between computers. It’s commonly used on systems that run Windows, but can also be installed on Linux and other UNIX-based operating systems.
Before we start, ensure that you have the following:
- Access to a Linux server
- Basic knowledge of Linux commands
- Access to an SMB share
Step 1: Installing Necessary Packages
The first step is to install the necessary packages, namely cifs-utils. You can use the apt package manager to install this. Run the following command:
sudo apt-get install cifs-utils
Step 2: Creating a Mount Point
The next step is to create a directory where you would like your SMB share to be mounted. This can be any location, but for this example, we’ll create a directory in /mnt:
sudo mkdir /mnt/smbshare
Step 3: Mounting the SMB Share
Now that we have a location ready, we can mount our SMB share to it. We’ll use the mount -t cifs command for this:
sudo mount -t cifs //myserver/smbshare /mnt/smbshare -o username=myuser,password=mypassword
Replace myserver with the address of your SMB server, smbshare with the name of your SMB share, and myuser and mypassword with your SMB username and password respectively.
Step 4: Verifying the SMB Share
To verify that the share has been mounted successfully, use the df command:
This should display your share among the listed filesystems.
And there you have it! You’ve successfully mounted an SMB share on Linux. Remember that this mount point is temporary and will be unmounted when the system reboots. To make it permanent, you need to add it to your /etc/fstab file.