• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

Mount Samba share on Ubuntu and Debian

Written by Rahul, Updated on September 28, 2020

Samba is the standard Windows interoperability suite of programs for the Unix and Linux operating systems. Samba server uses SMB/CIFS protocol for the secure, stable and file/printer sharing.

This tutorial will help you to mount remote samba share to your Linux system.

Mounting Samba Share on Unix and Linux

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

  • 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 purpose. It’s good to create it in your home directory.
    nano /root/.smbcredentials 
    

    Set the samba username and password to above file.

    username=smb_username
    password=smb_password
    
  • 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 //192.168.1.10/share /media/share 
    

    But the manually mounted file system will not remain mounted after a system reboot. To mount samba share automatically after system reboot, complete 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.

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

Conclusion

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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

7 Comments

  1. Avatar Ludovic Kuty Reply
    April 27, 2020 at 6:55 am

    Note that the option “vers=2.0” (or another version number) might be mandatory to choose the right protocol version to match the one of the server.

  2. Avatar Krishnakumar Masimalai Reply
    August 4, 2019 at 6:11 pm

    @ANDY D

    I too faced the same problem.

    Solution found is,

    sudo nano /.smbcredentials

    username=machine
    password=machine

    Save

    sudo nano /etc/fstab

    Add following line:

    //192.168.159.133/share_host/ /share_mount/ cifs vers=3.0,credentials=/.smbcredentials

    Save & Reboot

  3. Avatar Kim Aku Reply
    June 26, 2019 at 9:40 pm

    I haven’t tried this, but surely there’s a typo in the instructions.
    He says: “sudo mkdir /media/Share” (with uppercase “S”)
    Later in the fstab example given, the directory is addressed as “…/media/share…” with lowercase “s”
    My understanding is that Liunx, unlike Windows, distinguishes between upper and lower case, in which case the address in the fstab example would fail to find the previously created address because of the case discrepancy.

  4. Avatar Dave Reply
    April 19, 2019 at 2:50 am

    Guess they don’t teach how to secure a credential file at Red Hat Certified Engineer courses so it is not readable by everyone on the computer?

  5. Avatar Dave Reply
    April 1, 2019 at 5:32 pm

    I had to remove “sec=ntlm” from the options to get this to work, also on Ubuntu.

  6. Avatar Andy D Reply
    February 25, 2019 at 1:56 pm

    Hi, I have tried following these instructions, but I am getting the following error:

    mount error(22): Invalid argument
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    I am using gifs-utils version (2:6.8-1) running on Ubuntu 18.04.2 LTS.

    Can you please advise on what I am doing wrong?

  7. Avatar Jacob Reply
    June 7, 2018 at 12:20 pm

    I wonder how much different it is for CentOS?

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy