mount samba share on ubuntu network drive

How To Easily Map A Network Drive On Ubuntu (GUI & commands)

Whether you use Ubuntu Desktop or Server, it’s possible to access files shared on the network, from a file server, a NAS or another computer. In fact, even if you use another Linux distribution, you’ll follow the same steps. In this tutorial, I’ll explain 3 methods to access a file share on Linux:

  1. Mapping a network drive from the file explorer on a Desktop version.
  2. Using the “mount” command correctly from a terminal (or Server edition).
  3. Configuring the system to automatically mount the Samba share on boot.

Pick the solution that seems the best one for you, and follow the corresponding steps below.

Linux doesn’t have to be intimidating. With my e-book, Master Linux Commands, you’ll uncover the secrets of the terminal in a fun, step-by-step journey. From basics to scripts, get ready to level up your Linux skills. Oh, and did I mention the handy cheat sheet you get as a bonus?

Method 1: From the desktop interface

If you have a Desktop interface on your system, you don’t need any commands to access a network drive from Ubuntu. Everything can be done directly in the file explorer.

Open the file explorer from the shortcut in the menu bar. It can be slightly different depending on the desktop environment you use, but basically, you should have something like:

Click on “Other Locations”, and the system will scan the network and list the other computers available.

Find the one hosting the network share you want to reach, and double-click on it.
In my case, my NAS is “DiskStation”, an authentication is required:

Type a username and password that is allowed to access this file server. It’s not necessarily the same as your Ubuntu session, depending on the network drive configuration.

Also, make sure to check “Remember forever” if you don’t want to type the login and password each time you use the network drive (it’s up to you if you prefer security or comfort).

Once logged in, the file explorer will show the shares available on this computer. In my case, I have only one, named “partage”.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

If you just need to access it once, you can simply click on it and browse the files.
But in most cases, I guess you want to add a shortcut to it in the left menu. To do this, right-click on the share icon and select “Mount”.

For your information, the network drive is accessible until the next reboot. It will then disappear, and you’ll have to do it all over again. If you want to keep it in the left menu, you have right-click the shortcut again, and choose “Add to bookmarks”.

It will keep it available in your bookmarks like:

Join Our Community!

Connect, learn, and grow with other Raspberry Pi enthusiasts. Support RaspberryTips and enjoy an ad-free reading experience. Get exclusive monthly video tutorials and many other benefits.

Learn more

And if you selected “Remember forever” in the login form, you won’t need to type your user and password ever again.

That’s it, mapping a network drive on Ubuntu Desktop isn’t more complicated than that. And if you saved the bookmark, you probably won’t need to do it frequently. But if you are interested, I have 2 other methods for you, using the command line instead.

Method 2: From a terminal (manual & temporary)

The traditional method to map a network drive on Ubuntu (and any Linux system), is to use the “mount” command, available by default on most distributions.

Mount is installed by default, but this doesn’t necessarily include all the file systems you need.

For example, I’m using a Samba share for this tutorial, requiring the “cifs-utils” package, which is not installed by default on Ubuntu Server. You might need something else depending on the type of network share (“nfs-utils” for example), but the procedure is the same.

So, start by installing the tools to access your network share (most likely, you need “cifs-utils”):
sudo apt update
sudo apt install cifs-utils

On Linux, network shares are “mounted” to a local folder, that must be created beforehand. If you are a Windows user, you may not be used to this, but the first step is to create a new folder, to which we’ll map the network drive.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

You can create the folder wherever you want, I chose to create it in my home folder:
mkdir share
It’s not necessarily a good idea if you have several users, but it’s fine for the example.

Then the basic syntax for the mount command looks like:
sudo mount <network-share> <local-folder>
And you can have options, like this:
sudo mount -o <options> <network-share> <local-folder>

A basic command example may look like this:
sudo mount //IP_ADDRESS/share_name share
But in my case, I need to specify a different username, so I added an option:
sudo mount -o user=admin // share

As you can see, it works directly, and I can see the content of my network drive with:
ls share

You’ll quickly realize that they are two major issues with this solution:

  • The network share is only temporarily accessible.
    It will be disconnected on the next reboot, and won’t be reconnected automatically.
    I’ll explain how to fix this point with the last method (next part).
  • The mount is done with sudo (mandatory), so all the permissions are given to root.
    You can read all the files but can’t modify or delete them.
    In most cases, you can’t even create new files.

To fix the permissions issues, you can specify them in the mount command.

For example, as I have only one user on my system, I just need to tell the mount command to set my username as the owner. I can do this by adding the “uid” option in the mount command, like this:
sudo mount -o user=admin,uid=$(id -u) <target> <destination>

The command “id -u” returns the user id of the current user. And as you can see on the screenshot, “pat” (my username) is now the file owner for everything on the network drive, allowing me to edit files.

If you are interested in other options (maybe add the password or set a different group), you can use the “man” command to see all the possibilities:
man mount

If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Method 3: Automatically mount a samba share

On Linux, you can use the /etc/fstab file to automatically mount a network share on boot. This file includes the IP address, shared folder and destination, as well as all the other options of the mount command.

Here are the steps to map a network drive with fstab:

  • Create a mounting point, for example:
    sudo mkdir /mnt/share
    /mnt is typically where you can create and manage all the network shares on Ubuntu.
  • Open the fstab file:
    sudo nano /etc/fstab
  • Add a new line at the end, following this format:
    <target> <destination> <file-system> <options> 0 0
    If I apply this to the same example as in the previous parts, I add:
    // /mnt/share cifs user=admin,password=XXX,uid=1000 0 0

As you can see, in this case, I specify the password in the options, as I want the system to mount it automatically, the password is required.
Once done, it looks like:

Save and exit the file (CTRL+X).
If everything is set properly, it will be mounted automatically on your next reboot.

You can also manipulate the mounting point with the mount command, without all the options (as they are stored in this file):
sudo mount /mnt/share

And to disconnect it manually, you can use:
sudo umount /mnt/share

To see if the network share is mounted, and monitor the disk usage, you can use:
df -h
It will be listed as a standard disk partition.

That’s it, you now know 3 ways to access your file shares from Ubuntu (or any Linux computer), with the GUI or in command lines. I hope I answered all your questions, and if you want more tutorials for Linux, here are a few ones I recommend you check out:

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.

Additional Resources

Overwhelmed with Linux commands?
My e-book, “Master Linux Commands”, is your essential guide to mastering the terminal. Get practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
Grab your copy now.

VIP Community
If you just want to hang out with me and other Linux fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Python is a great language to get started with programming on any Linux computer.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

Similar Posts