Categories
Productivity Tech

How To Mount SMB With Command Line In Ubuntu And Debian

I need to mount an SMB to one of my local machines. After a few tries and errors, I found a perfect solution.

Step 1 – Install the cifs-utils package.

sudo apt install cifs-utils

If you missed this step, you’ll end up with the following error:

mount -t cifs results in 'cannot mount readonly' error

Step 2 – Create a local mount directory

There is no absolute right or wrong directory to mount. I prefer the /mnt for most of my mounting directories. mysmb is an arbitrary folder name. You can name it whatever you want.

sudo mkdir /mnt/mysmb

Step 3 – Mount SMB

Mount the SMB to the /mnt/mysmb directory in step 2.

sudo mount -t cifs -o username=user //smb-server-address/share-name /mnt/mysmb
  • user: the user name of your SMB
  • smb-server-address: the IP address of your SMB
  • share-name: if you have a folder and you only want to mount that folder, you can specify it here

For example:

sudo mount -t cifs -o username=mysmbuser //10.0.1.123/myFolder /mnt/mysmb

Then you’ll get a prompt to enter the password for your user. Viola! Now you can access your SMB folder from your local at /mnt/mysmb (or whatever the local path you specified in step 2).

Leave me a message if you have a question.

If my note helped, please consider buying me a coffee😁.

Cheers,
Lok