Jump to content

How to Mount a Samba Share on Ubuntu and Debian


Recommended Posts

Samba is the standard Windows interoperability suite of programs for the Unix-based operating systems. It allows network administrators for file and print sharing between the computers running Microsoft Windows and Unix/Linux systems. Basically, Samba uses SMB/CIFS protocol for secure, stable, and file/printer sharing including multiple other protocols like NetBIOS over TCP/IP (NBT).

Samba sharing allows multiple systems to share single resources over a network, like sharing a printer reduces hardware cost. Also, share the directory server using samba and mount it on remote systems easily.

This tutorial will help you to mount remote samba share to Ubuntu, Debian, or Linux Mint systems.

Steps to Mount Samba Share on Ubuntu and Debian

This tutorial assumes that you have already shared a directory on the remote system. Now, we will mount that shared directory to our Ubuntu or Debian system.

Follow the step-by-step guide for the mounting of remote samba share on the Ubuntu and Debian systems. Also enables to automount shared drive even after system reboot.

Save your file and make it readable for the root account only. This will restrict access to all non-root accounts.

chmod 400 /root/.smbcredentials 
  • Step 1 – You need to install package cifs-utils on your system. Run the following command on the terminal for the installation.
    sudo apt install cifs-utils 
  • Step 2 – After that create a directory to mount the share drive.
    sudo mkdir /media/share 
  • Step 3 – Now create a credentials file to your system. Make this as a hidden file using dot (.) for security purposes. It’s good to create it in your home directory.
    nano /root/.smbcredentials 

    Set the samba username and password to the above file.

  • Step 4 – Use the following command to mount remote samba share on a Linux system.
    sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.smbcredentials // /media/share 

    But the manually mounted file system will not remain mounted after a system reboot. To mount samba share automatically after a system reboot, complete the next step.

  • Step 5 –You can make add the configuration to /etc/fstab file to auto mount remote share on system boot.

    Edit the below configuration file in your favorite text editor:

    sudo nano /etc/fstab 

    Add the line at end of the file as follows. Change values as per yours.

    // /media/share cifs vers=3.0,credentials=/root/.smbcredentials

    Save file and close it.


In this tutorial, you have learned to mount remote samba share on a Unix-like system. Also enabled to mount a remote share on system boot.


Guinness Beer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...