How to Mount a CIFS/SMB Share on Ubuntu VPS

Sometimes I want to share files between my Ubuntu computer and a Windows machine. Or maybe I need to access a folder on my home server that’s using Windows-style sharing. That’s where CIFS and SMB come in.

CIFS stands for Common Internet File System. SMB means Server Message Block. These are just fancy names for the same thing: a way to share folders over a network, mostly used by Windows. Think of it like a shared drive in a school computer lab. Anyone with permission can open it and use the files inside.

Ubuntu doesn’t connect to these shares by default, but it’s easy to set up. I’ll walk you through it. You won’t need to be a pro. If I can do it, so can you.


What Are CIFS and SMB?

Let me break it down in simple terms.

  • SMB is the original protocol that lets computers share files and printers on a network.
  • CIFS is an older version of SMB used in Windows systems.

Even though the names are different, people often use them to mean the same thing. In Ubuntu, we use a tool called cifs-utils to connect to SMB/CIFS shares.

Imagine a public library. SMB is the system that lets people check out books (files). CIFS is like an older card catalog—still useful, but kind of old-school.


When Would You Want to Use It?

I use CIFS/SMB when:

  • I want to connect my Ubuntu machine to a shared Windows folder.
  • I need to back up files to my home server.
  • I want to open and save files directly on another computer.

This is really helpful in homes, small offices, or even classrooms where Linux and Windows machines live side by side.


What You’ll Need

Before we start, make sure you have these things:

  • An Ubuntu machine (I’m using Ubuntu 22.04)
  • A working network
  • The IP address or hostname of the Windows or SMB server
  • A shared folder on that server
  • A username and password (if required)

If you’re setting this up at home, your Windows PC or NAS (Network Attached Storage) might already have a shared folder ready.


Step 1: Install the CIFS Tools

Let’s start with the basics. First, open your terminal. Then type:

sudo apt update
sudo apt install cifs-utils

This installs the tools you need to mount a CIFS share.

Without this package, Ubuntu won’t understand how to talk to the shared folder.


Step 2: Create a Mount Point

Now you need a place on your Ubuntu system where the shared folder will appear. I made a folder called share inside /mnt, like this:

sudo mkdir -p /mnt/share

You can name this folder whatever you want, but I like to keep things simple and tidy.

Think of the mount point as a window. When you open it, you see the shared folder on the other computer.


Step 3: Mount the Share Temporarily

Let’s try mounting the shared folder. Replace the parts in brackets with your actual info:

sudo mount -t cifs //192.168.1.100/sharedfolder /mnt/share -o username=youruser,password=yourpassword

Let’s break this down:

  • //192.168.1.100/sharedfolder – the network path to the shared folder
  • /mnt/share – the mount point on your machine
  • -o username=youruser,password=yourpassword – your login details

If it works, the contents of the shared folder will show up inside /mnt/share.

Note: Avoid using your actual password in the terminal for safety. I’ll show a better way later.


Step 4: Make It Mount Automatically at Boot

If you want the share to connect every time your computer starts, you’ll need to add it to the /etc/fstab file.

But don’t store your password directly in that file. Instead, make a separate file to keep your credentials safe.

Create a credentials file:

sudo nano /etc/smb-credentials

Then add:

username=youruser
password=yourpassword

Save and close the file. Then set the right permissions:

sudo chmod 600 /etc/smb-credentials

This makes sure nobody else can read your password.


Add the entry to fstab:

Now edit the fstab file:

sudo nano /etc/fstab

Add this line at the bottom:

# Windows Share
//192.168.1.100/sharedfolder /mnt/share cifs credentials=/etc/smb-credentials,iocharset=utf8,uid=1000,gid=1000 0 0

Here’s what the options mean:

  • credentials=... – points to your login file
  • iocharset=utf8 – helps with file names that use special characters
  • uid and gid – make sure you own the files

Save and exit.

Now try mounting everything from fstab:

sudo mount -a

If nothing breaks, you’re golden.


Common Issues (and How I Fixed Them)

Let’s be real. Sometimes things go wrong. Here are a few common mistakes I made, and how I fixed them:

  • Wrong path: Make sure the share name and IP are correct. Use double slashes at the beginning: //IP/share.
  • Permission denied: Try connecting to the share from another computer to test the username and password.
  • Mount point doesn’t exist: Always create the folder first.

Troubleshooting is part of the fun. It’s like playing hide-and-seek, but with network folders.


Some Helpful Commands

Here are some useful commands I keep in my notes:

  • df -h – shows mounted drives and their sizes
  • sudo umount /mnt/share – unmounts the share
  • mount | grep cifs – checks if the share is mounted
  • smbclient -L //192.168.1.100 -U youruser – lists available shares on a server

Stick these in a sticky note on your monitor. Nerdy? Yes. Useful? Definitely.


Benefits of Using CIFS/SMB on Ubuntu

Here’s why I like using CIFS/SMB:

Simple to Use

  • Easy to set up once you know the steps
  • Great for home networks and small teams
  • Works with most modern Linux and Windows systems

Good Compatibility

  • Lets Ubuntu talk to Windows servers
  • Supports file and folder permissions
  • Works with many types of file servers (NAS, Windows PCs, etc.)

Flexible and Customizable

  • You can mount it manually or automatically
  • Secure options are available
  • You can control access with user and group settings

Is it perfect? No. But it gets the job done when you just want to share files across your network.


Funny But True: Don’t Get Lost in the CIFS-t

Once I messed up my fstab file and my computer refused to boot. Oops. That’s why I always test my mount first before adding it to fstab. Lesson learned.

Think of CIFS as a bridge. You want it strong and stable. Not something that falls apart when you reboot.

And if you ever feel stuck, just remember—when life gives you a CIFS error, mount it anyway (after checking your logs).


Final Thoughts

Connecting Ubuntu to a Windows-style shared folder using CIFS/SMB might sound hard at first. But it’s not bad once you understand the steps.

It’s a great way to access shared files in your home or office. And you don’t need fancy software—just a few commands and some patience.

Try it out and let me know: What kind of files will you share first? Backups? Movies? Your secret pizza recipes?

Just remember—always double-check your IPs, test before rebooting, and never store your passwords in plain sight. And don’t be afraid to play around. That’s how we learn.

 

 

Leave a Reply