Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to mount SMB share on Linux

📅 2022-Sep-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ smb ⬩ 📚 Archive

The SMB/CIFS networking protocal can be used to share a directory on the local network with other computers. Such network share directories can be shared by Windows computers and devices like NVIDIA Shield. Any Linux computer can also share a directory using SMB/CIFS as described here.

To mount such a network share on a Ubuntu computer I used these steps:

$ sudo apt install smbclient cifs-utils
$ smbclient -L foobarserver -U joe

$ smbclient -L -U joe

Note the sharename that are listed, we will need to use those to mount later.

$ sudo mkdir /media/foobarshare
$ sudo mount -t cifs -o username=joe,password=supersecret // /media/foobarshare

I found that using the IP address worked, but using the server name foobarserver gave the error mount: bad usage. You should be able to see the contents of the share in /media/foobarshare now.

$ sudo umount /media/foobarshare
-o username=joe,password=supersecret,uid=$(id -u)
// /media/foobarshare cifs username=joe,password=supersecret 0 0

and mount with:

$ sudo mount -a

Reference: Ubuntu: Mount Windows share permanently

Tried with: Ubuntu 22.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 📧