Do you work with files stored on a remote server, a NAS, or a cloud service? Make your life easier by mounting these shares directly in your file explorer on Ubuntu. This guide shows you how to do it in a few simple steps.
Ubuntu uses the Gnome desktop environment by default, which includes powerful tools for managing remote shares.
GIO: The software component for file access Link to heading
GIO is a software library that provides a high-level API for file access. It is an essential component of the Gnome desktop environment, and by extension of Ubuntu, which allows you to handle local and remote files transparently.
Command line usage Link to heading
Mounting Link to heading
To mount a remote share, simply use the gio mount command followed by the share’s address.
For example, to mount a Samba share on a NAS:
gio mount smb://nas.example.com/home/
Or to mount a WebDAV share on a Nextcloud server:
gio mount davs://nextcloud.example.com/remote.php/dav/files/user
Unmounting Link to heading
To unmount a share, simply list the mounts with the gio mount -l command and copy the URI of the share to be unmounted. Then, use the gio mount -u command followed by the URI.
Automatic mounting at session startup Link to heading
To automatically mount a share at user session startup, simply create a .desktop file in the ~/.config/autostart directory.
Here is an example of a file for mounting a Samba share:
[Desktop Entry]
Type=Application
Name[en_US]=My remote share
Name=Mount my remote share
Comment[en_US]=My remote share
Comment=Mount my remote share
TryExec=gio
Exec=gio mount smb://my-server.local/share/
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Just replace My remote share, Mount my remote share, smb://my-server.local/share/ with your share’s information.
Testing the .desktop file
Link to heading
To test the .desktop file without restarting the session, simply launch it manually with the gio launch command.
gio launch ~/.config/autostart/my-share.desktop
And there you have it, your remote share will now be mounted automatically at each session startup.
To go further Link to heading
The gio command manpage on the Ubuntu website is a valuable resource for exploring all the features of this tool.