How to Mount a Network Drive on Ubuntu

Tech reviewed: Deepak Prasad
Illustration of mounting a network drive on Ubuntu over SMB CIFS and NFS to a folder under /mnt/nas

Ubuntu can mount a network drive the same way Windows “maps” a share: you attach a remote folder to a local path such as /mnt/nas and read or write files through it. Most home and office setups use SMB/CIFS (Samba, NAS vendors, Unraid) or NFS (Linux file servers).

This guide covers mounting a network drive on Ubuntu from the terminal and the Files app: install cifs-utils, mount SMB shares with a credentials file, mount NFS exports, make mounts survive reboots with /etc/fstab, and unmount safely. I stood up a dummy Samba and NFS server on the same Ubuntu 25.04 host (glc-netshare and glc-public on 127.0.0.1) so every command below has real output. Swap 127.0.0.1 for your NAS IP or hostname.

Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic.

IMPORTANT
Store SMB passwords in a credentials file readable only by root (chmod 600). Do not put plain-text passwords in /etc/fstab or shell history when you can avoid it.

Quick command summary

Task Command
Install SMB client tools sudo apt install -y cifs-utils smbclient
Install NFS client tools sudo apt install -y nfs-common
List SMB shares smbclient -L //SERVER -U username
List NFS exports showmount -e SERVER
Create mount point sudo mkdir -p /mnt/nas && sudo chmod 755 /mnt/nas
Mount SMB (one-off) sudo mount -t cifs //SERVER/SHARE /mnt/nas -o credentials=/root/.smbcredentials,uid=$(id -u),gid=$(id -g)
Mount NFS (one-off) sudo mount -t nfs SERVER:/export/path /mnt/nas
Verify mount findmnt /mnt/nas or df -hT /mnt/nas
Unmount sudo umount /mnt/nas
fstab + apply Edit /etc/fstab, then sudo mount -a

What you are mounting

Protocol Typical server Ubuntu package Mount type
SMB / CIFS Windows, Samba, Synology, Unraid cifs-utils cifs
NFS Linux NAS, ESXi datastore, backup server nfs-common nfs or nfs4

SMB URLs look like //192.168.0.10/backups. NFS paths look like 192.168.0.10:/srv/backups. WebDAV (davfs2) and SSHFS are other options; this article focuses on SMB and NFS because those are what most “map network drive” guides target.

If you already export folders from an Ubuntu server, see how to set up a NAS server on Ubuntu for Samba and NFS on the server side.


Prerequisites

On the Ubuntu client:

bash
sudo apt update
sudo apt install -y cifs-utils nfs-common smbclient

On Ubuntu 25.04:

text
cifs-utils:
  Installed: 2:7.2-2ubuntu0.1
nfs-common:
  Installed: 1:2.8.2-2ubuntu1

You also need:

  • The server hostname or IP (for example 192.168.0.4 or nas.local).
  • The share or export name (for example glc-netshare).
  • For authenticated SMB: a username and password allowed on that share.
  • A local mount point directory—create it before you mount, same idea as mounting a USB drive.

Use sudo for system-wide mounts under /mnt or /media.


Lab setup used for testing (optional)

To reproduce my session without external hardware, I created a dummy share on the same machine:

bash
sudo mkdir -p /srv/glc-netshare /srv/glc-public
echo 'Hello from dummy network drive' | sudo tee /srv/glc-netshare/welcome.txt

Samba shares glc-netshare (authenticated) and glc-public (guest read-only) were added to /etc/samba/smb.conf, and NFS exported /srv/glc-netshare to 127.0.0.1 in /etc/exports. You do not need this on a normal desktop—point commands at your real NAS instead.


Discover shares on the server

SMB: list share names

bash
smbclient -L 192.168.0.4 -U glcshare

When prompted for a password, enter the SMB account password. On my host:

text
Sharename       Type      Comment
	---------       ----      -------
	glc-netshare    Disk
	glc-public      Disk
	IPC$            IPC       IPC Service (mail server (Samba, Ubuntu))

Use the Sharename column in your mount command: //192.168.0.4/glc-netshare.

NFS: list exports

bash
showmount -e 127.0.0.1
text
Export list for 127.0.0.1:
/srv/glc-netshare 127.0.0.1

Your server may export to * or a subnet instead of a single IP.


Mount a network drive on Ubuntu (SMB / CIFS)

Step 1: Create a mount point

bash
sudo mkdir -p /mnt/glc-netshare
sudo chmod 755 /mnt/glc-netshare
bash
sudo install -m 600 -o root -g root /dev/null /root/.smbcredentials
sudo nano /root/.smbcredentials

Contents:

text
username=glcshare
password=YourPasswordHere
domain=WORKGROUP

domain= is optional for many home NAS units.

Step 3: Mount the share

bash
sudo mount -t cifs //127.0.0.1/glc-netshare /mnt/glc-netshare \
  -o credentials=/root/.smbcredentials,uid=$(id -u),gid=$(id -g),file_mode=0664,dir_mode=0775

Verify:

bash
findmnt /mnt/glc-netshare
cat /mnt/glc-netshare/welcome.txt
text
TARGET            SOURCE                   FSTYPE OPTIONS
/mnt/glc-netshare //127.0.0.1/glc-netshare cifs   rw,relatime,vers=3.1.1,...,uid=1000,forceuid,gid=1000,forcegid,...
Hello from dummy network drive

uid= and gid= make files appear owned by your login user instead of root.

Guest read-only SMB mount

For a public share that allows guests:

bash
sudo mkdir -p /mnt/glc-public
sudo mount -t cifs //127.0.0.1/glc-public /mnt/glc-public -o guest,ro,uid=$(id -u),gid=$(id -g)
cat /mnt/glc-public/public.txt
text
public share file

Wrong password (real error)

This is what I saw with a bad password:

text
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)

Fix the credentials file or test with smbclient -L //SERVER -U user%pass before mounting again.

Write permission gotcha

My first mount could read but not create files until the server export was owned by the Samba user:

text
tee: /mnt/glc-netshare/from-client.txt: Permission denied

After sudo chown glcshare:glcshare /srv/glc-netshare on the server, this worked:

bash
echo 'written from client mount' > /mnt/glc-netshare/from-client.txt
cat /mnt/glc-netshare/from-client.txt
text
written from client mount

On a NAS you usually set permissions in the vendor UI instead of SSH.

Older SMB servers

If negotiation fails, pin an older dialect:

bash
sudo mount -t cifs //SERVER/SHARE /mnt/nas -o credentials=/root/.smbcredentials,vers=3.0,uid=$(id -u),gid=$(id -g)

findmnt then shows vers=3.0 in the options list.


Mount a network drive on Ubuntu (NFS)

NFS fits Linux-to-Linux shares and many NAS “NFS export” toggles.

bash
sudo mkdir -p /mnt/glc-nfs
sudo mount -t nfs 127.0.0.1:/srv/glc-netshare /mnt/glc-nfs
findmnt /mnt/glc-nfs
cat /mnt/glc-nfs/welcome.txt
text
TARGET       SOURCE                      FSTYPE OPTIONS
/mnt/glc-nfs 127.0.0.1:/srv/glc-netshare nfs4   rw,relatime,vers=4.2,...
Hello from dummy network drive

Check space:

bash
df -hT /mnt/glc-nfs
text
Filesystem                  Type  Size  Used Avail Use% Mounted on
127.0.0.1:/srv/glc-netshare nfs4   58G   42G   14G  76% /mnt/glc-nfs

For export options and server tuning, see NFS mount options examples.


Mount permanently with /etc/fstab

Edit fstab when you want the network drive available after every boot.

bash
sudo cp /etc/fstab /etc/fstab.bak.$(date +%F)
sudo nano /etc/fstab

SMB example:

text
//192.168.0.4/glc-netshare  /mnt/glc-netshare  cifs  credentials=/root/.smbcredentials,uid=1000,gid=1000,file_mode=0664,dir_mode=0775,_netdev,x-systemd.automount  0  0

NFS example:

text
192.168.0.4:/srv/glc-netshare  /mnt/glc-nfs  nfs  _netdev,x-systemd.automount  0  0
Option Why
_netdev Wait for networking before this mount; avoids hanging early boot when the NAS is off
x-systemd.automount Mount on first access instead of blocking boot
credentials= Keeps passwords out of fstab

Test before reboot:

bash
sudo umount /mnt/glc-netshare /mnt/glc-nfs 2>/dev/null || true
sudo mount -a
cat /mnt/glc-netshare/welcome.txt
text
Hello from dummy network drive

For systemd .mount units instead of fstab, see mount a partition using systemd.


Map a network drive in the Ubuntu GUI (Files)

On Ubuntu Desktop:

  1. Open Files (Nautilus).
  2. Click Other Locations in the sidebar.
  3. At Connect to Server, enter smb://192.168.0.4/glc-netshare or nfs://192.168.0.4/srv/glc-netshare.
  4. Click Connect and enter SMB credentials when asked.

The share appears in the sidebar for your session. GNOME typically mounts it under /run/user/$(id -u)/gvfs/. That is fine for interactive use; use /mnt plus fstab when you need a fixed path for scripts, Docker bind mounts, or servers.

Install gvfs-backends if the Connect to Server dialog lacks SMB:

bash
sudo apt install -y gvfs-backends

Unmount a network drive

bash
sudo umount /mnt/glc-netshare

Confirm:

bash
findmnt /mnt/glc-netshare || echo "not mounted"
text
not mounted

If you see target is busy, close terminals and apps using the mount point. Lazy unmount (sudo umount -l) detaches the tree while processes finish—use only when you understand leftover handles may still hold files open.


Troubleshooting

Symptom Likely cause Fix
mount: /mnt/nas: unknown filesystem type 'cifs' cifs-utils missing sudo apt install cifs-utils
mount error(13): Permission denied Bad credentials or no guest access Test with smbclient; fix credentials file
mount.nfs: access denied Client IP not in server export Adjust NAS NFS export / /etc/exports
No such file or directory for mount point Directory missing sudo mkdir -p /mnt/nas
Boot hangs on NAS mount fstab without _netdev Add _netdev and x-systemd.automount
Files owned by root on SMB Missing uid/gid options Add uid=$(id -u),gid=$(id -g) to mount options
Can read but not write CIFS Server-side ownership Fix export permissions on NAS or Samba force user

References


Summary

To mount a network drive on Ubuntu, install cifs-utils for SMB or nfs-common for NFS, create a mount point under /mnt, and run sudo mount -t cifs //server/share /mnt/nas with a root-only credentials file. Use showmount and smbclient -L to discover exports before you mount. For mounting a network drive permanently, add a line to /etc/fstab with _netdev and test with sudo mount -a. The Files app can connect via Other Locations → Connect to Server when you prefer a GUI over the terminal.


Frequently Asked Questions

1. What is the difference between mounting SMB and NFS on Ubuntu?

SMB/CIFS is the Windows-style share protocol (NAS boxes, Samba, Unraid). NFS is common on Linux servers and high-throughput LAN storage. Ubuntu uses mount -t cifs for SMB and mount -t nfs for NFS; pick the protocol your server exports.

2. What package do I need to mount a Windows or Samba share on Ubuntu?

Install cifs-utils with sudo apt install cifs-utils. That provides mount.cifs. For NFS shares, install nfs-common. Use smbclient to list available SMB share names before you mount.

3. How do I mount a network drive permanently on Ubuntu?

Add a line to /etc/fstab with the UNC or NFS export, mount point, filesystem type, options, and 0 0 dump/pass fields. Include _netdev so boot does not hang if the server is offline, and store SMB passwords in a root-only credentials file—not in fstab in plain text.

4. Why does mount.cifs return Permission denied?

Wrong username or password, a share that rejects guests, or missing credentials are the usual causes. On Ubuntu 25.04 a bad password produced mount error(13): Permission denied. Verify with smbclient -L //server -U user%pass before mounting.

5. Can I map a network drive on Ubuntu without the terminal?

Yes. Open Files, go to Other Locations, click Connect to Server, and enter smb://server/share or nfs://server/export. GNOME mounts the share under /run/user/UID/gvfs/ for the session. Terminal mounts under /mnt or /media are easier to script and persist with fstab.

6. How do I unmount a network drive on Ubuntu?

Run sudo umount /mnt/your-mount-point. If the target is busy, close files and shells using that directory, or use sudo umount -l for a lazy unmount when you understand the risk. GUI mounts disappear when you click the eject icon in Files.

7. What mount options fix UID and file permission issues on CIFS?

Add uid=YOUR_UID,gid=YOUR_GID,file_mode=0664,dir_mode=0775 so files look owned by your desktop user. If writes still fail, fix ownership on the Samba server export path or ask the admin which user the share expects.

8. Should I use 127.0.0.1 or the LAN IP to mount a NAS?

Use the NAS or file server LAN address (for example 192.168.0.10), not 127.0.0.1, unless you are deliberately testing a share on the same machine. Replace 127.0.0.1 in lab examples with your server IP or hostname.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, …

  • Red Hat Certified System Administrator in Red Hat OpenStack
  • Certified Kubernetes Application Developer (CKAD)
  • Red Hat Certified Specialist in Ansible Automation
  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security