How to Access Your Nextcloud Files via WebDAV on Ubuntu Desktop

If you followed and finished our previous tutorial on how to set up Nextcloud on Ubuntu 16.04 VPS or dedicated server, then you might wonder “How can I access Nextcloud files from my Ubuntu/Linux computer?”  Nextcloud team released a Linux client but it’s a source package. If you don’t want to manually compile Nextcloud Linux client, then you can use WebDAV instead.

WebDAV (Web-based Distributed Authoring and Versioning) is an extension of the HTTP protocol. Using WebDAV, your Nextcloud will be mounted on your Linux desktop as if it’s a network drive. It won’t take any space on your local hard drive.

Graphical Linux WebDAV Client

The Nautilus file manager integrated a WebDAV client in itself. To access your Nextcloud files from Nautilus, go to File > Connect to Server.

Nautilus connect to server

In the Server Address field enter the Nextcloud WebDAV URL. davs means DAV secure. Replace red text with your actual domain name and username.

davs://nextcloud.your-domain.com/remote.php/dav/files/nextcloud-username

nextcloud webdav linux

Next, enter your Nextcloud username and password. And click connect.

nextcloud webdav mount

Once it’s mounted, you will see a new entry for your Nextcloud on the left pane of Nautilus file manager.

Mount Nextcloud via WebDAV Protocol From the Command Line

Install the davfs2 WebDAV file system driver.

sudo apt update

sudo apt install davfs2

During the installation, you will be asked whether you want unprivileged users be allowed to mount WebDAV resources. Choose Yes.

ubuntu webdav configuration

You can always bring back this dialog later by executing the following command:

sudo dpkg-reconfigure davfs2

Next, add your user account to the davfs2 group.

sudo gpasswd -a your-username davfs2

Re-login for the changes to take effect.

Then go to your home directory and create two directories, one to mount the Nextcloud WebDAV share, and the other to hold the WebDAV configuration.

cd

mkdir nextcloud

mkdir .davfs2

Copy /etc/davfs2/secrets to ~/.davfs2:

sudo cp /etc/davfs2/secrets ~/.davfs2/secrets

This secrets file must be readable and writable by the owner only (mode 0600). So issue the following command to make yourself as the owner.

sudo chown your-username:your-username ~/.davfs2/secrets

And set 0600 as the permission mode.

sudo chmod 600 ~/.davfs2/secrets

Then open the secrets file.

nano ~/.davfs2/secrets

Add your Nextcloud login credentials to the end of the secrets file, using your Nextcloud WebDAV URL and your Nextcloud username and password:

https://nextcloud.your-domain.com/remote.php/dav/files/nextcloud-username/  nextcloud-username password

Edit the file system table:

sudo nano /etc/fstab

Add the following line to the end of the file.

https://nextcloud.your-domain.com/remote.php/dav/files/nextcloud-username/ /home/username/nextcloud  davfs  user,rw,auto 0 0

After saving the file, you can mount your Nextcloud share with:

mount ~/nextcloud

Now you can view, create, edit or delete your Nextcloud files in this directory. To unmount, run:

umount ~/nextcloud

Note

If your Nextcloud is installed in a sub-directory of your website, then the WebDAV URL should be

https://your-domain.com/nextcloud/remote.php/dav/files/nextcloud-username/

A wrong WebDAV URL will result in 500 Internal Server Error. If the mount failed, you can check out Nextcloud logs by going to your Nextcloud admin page and clicking the logging tab.

You might see the following notice when mounting Nextcloud share.

/sbin/mount.davfs: warning: the server does not support locks

This tells us that Nextcloud server does not support file locking so that you want to make sure a file is not being edited from two different places at the same time, or your editing will be lost.  If you don’t want to see this warning, add the following line at the end of /etc/davfs2/davfs2.conf file.

use_locks 0

That’s it!

I hope this tutorial helped you mount Nextcloud share on your Ubuntu desktop. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+Twitter or like our Facebook page.

Rate this tutorial
[Total: 2 Average: 5]
  • Wayne Bratcher

    Hi Thanks for the great tutorial, I have one question when I mount the drive it asked for my username and password. Is this correct as I added them to the secrets file. If I type the details then it mounts the drives successfully. Where have I gone wrong?

    • Make sure there is no typo. You won’t be asked to enter username and password if everything is correct.