Linux mount Windows shared directory via cifs and samba

1 minute read


  • 2013-08-08: Added sec=ntlm
  • 2014-09-04: Added domain=mydomain parameter in order to connect to Active Directory domain

Today I wanted to mount a Windows shared directory on my Ubuntu Linux machine. Note that the Windows machine is connected to an Active directory domain. After some searching in the web and trying various solutions, I stumbled upon an answer in Ubuntu forums. I finally managed to mount the Windows directory using mount command and having installed Linux cifs utilities.

Important note: Verify that your Windows shared directory has read access or write access for the user you are connecting with.

So in order to get your job done follow these steps:

  1. Determine your Windows share directory information In my case they are:
    • Active Directory machine name: manios.mycompany.local
    • IP:
    • Shared Directory: books
    • Active Directory username: manios
    • Active Directory password: maniospassword
  2. Install Linux cifs utils
    sudo apt-get install  cifs-utils
  3. Create a mount directory
    mkdir /media/bobos
  4. Mount Windows shared directory to your local directory Mount the directory with read / write permissions. You can use either your domain as an address or you IP:
    sudo mount -t cifs //manios.mycompany.local/books /media/bobos/ -o username=manios,rw,password=maniospassword,domain=mydomain

    OR mount the directory with read only permissions:

    sudo mount -t cifs //manios.mycompany.local/books /media/bobos/ -o username=manios,password=maniospassword,domain=mydomain

    If the Windows host is not connected in an active directory domain and you log in with your local account, so you have to add sec=ntlm into -o parameter (according to this StackOverflow answer. So the command looks like this:

    sudo mount -t cifs //manios.mycompany.local/books /media/bobos/ -o username=manios,password=maniospassword,sec=ntlm

Congratulations! You are complete! Now if you want to unmount the directory:

  • Run umount command:

     umount /media/bobos/
  • Remove local directory

     rm -f /media/bobos/

I hope you find this guide useful!