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: 14 Average: 3.9]

7 Responses to “How to Access Your Nextcloud Files via WebDAV on Ubuntu Desktop

  • Wayne Bratcher
    7 years ago

    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?

    • Xiao Guo-An (Admin)
      7 years ago

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

  • DonQuixote
    5 years ago

    Xiao, not with NextCloud, but with another webDAV server ,

    2 PCs, Ubuntu 16 and 18 OS they where not able to fully boot ( systemd error message was shown) , …

    This (almost) blocking problem was solved just changing ‘auto’ (mount) parameter at /etc/fstab , from

     https://webdav.server/index.php/dav/files/username/ /home/username/webdav  davfs  user,rw,auto 0 0 

    to ‘noauto’ , hence

     https://webdav.server/index.php/dav/files/username/ /home/username/webdav  davfs  user,rw,noauto 0 0 
    • I am having the same issue. While starting up, ubuntu tries to mount the nextcloud and fails (i dont know why). This hinders the system to boot and it is really tricky to solve the issue as you need to change the fstab while the boot fails. Anyways, I managed it, but now, i have to mount manually after each restart. Is there any way to make it load automatically?

      By the way, the instructions are excellent and saved my day.

  • MaxiReglisse
    3 years ago

    as explained in https://www.hiroom2.com/2017/07/31/debian-9-davfs2-en/, for avoiding mounting WebDAV before network initialization, you need to add _netdev option. For making x-systemd.automount to mount WebDAV, you need to add x-systemd.automount to option.

    https://webdav.server/index.php/dav/files/username/ /home/username/webdav davfs _netdev,x-systemd.automount 0 0

  • Works like a charm, thanks!

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here