How to mount Nextcloud WebDAV on Linux

A Nextcloud WebDAV mount lets a Linux account use files from the server through a normal local directory. This fits small automation jobs, editor workflows, and tools that need a filesystem path instead of a browser tab or the desktop sync client.

On Linux, davfs2 mounts the user's WebDAV collection through FUSE. The Nextcloud endpoint includes the account name under /remote.php/dav/files/, so the server URL, secrets entry, and mount point must all refer to the same account.

Use an app password instead of the main account password, especially when two-factor authentication is enabled. A WebDAV mount depends on network access and keeps local cache files while data is open, so test the mount manually before relying on the saved /etc/fstab entry for repeated use.

Steps to mount Nextcloud WebDAV with davfs2 on Linux:

  1. Install davfs2 on Ubuntu or Debian.
    $ sudo apt install --assume-yes davfs2

    Use the distribution package for the davfs2 filesystem driver. On Fedora, RHEL, and openSUSE systems, install the package named davfs2 with the native package manager.

  2. Add the Linux account to the davfs2 group.
    $ sudo usermod --append --groups davfs2 "$USER"

    Open a new login session before the mount step if this command changed the current account's group membership.

  3. Create the mount point and per-user davfs2 directory.
    $ mkdir -p "$HOME/nextcloud" "$HOME/.davfs2"
  4. Open the user secrets file.
    $ nano ~/.davfs2/secrets
  5. Add the Nextcloud WebDAV URL, username, and app password.
    https://cloud.example.com/remote.php/dav/files/ada/ ada app-password-value

    Store a dedicated app password here, not the main account password. The file is a reusable credential for the mounted account.
    Related: How to create a Nextcloud app password

  6. Restrict the user secrets file.
    $ chmod 600 ~/.davfs2/secrets
  7. Back up /etc/fstab before adding the saved mount.
    $ sudo cp --archive /etc/fstab /etc/fstab.bak

    A malformed /etc/fstab line can delay boot or leave the mount unavailable until the file is corrected.

  8. Open /etc/fstab with root privileges.
    $ sudoedit /etc/fstab
  9. Add a davfs entry for the Nextcloud mount.
    https://cloud.example.com/remote.php/dav/files/ada/ /home/ada/nextcloud davfs user,rw,noauto,_netdev 0 0

    Use the real absolute home path in /etc/fstab because the file does not expand ~. Keep noauto when the user should mount the share on demand; use auto only when the network mount is expected during system startup or login.

  10. Verify the saved /etc/fstab entry.
    $ sudo findmnt --verify --verbose /home/ada/nextcloud
    /home/ada/nextcloud
       [ ] target exists
       [ ] userspace options: user
       [ ] VFS options: noauto
       [ ] do not check https://cloud.example.com/remote.php/dav/files/ada/ source (pseudo/net)
       [ ] do not check https://cloud.example.com/remote.php/dav/files/ada/ FS type (pseudo/net)
    Success, no errors or warnings detected

    Correct any parse, target, or option error before testing the mount.
    Related: How to check fstab before rebooting in Linux

  11. Mount the saved Nextcloud entry by its mount point.
    $ mount ~/nextcloud
  12. Confirm that davfs2 attached the expected WebDAV URL.
    $ findmnt --mountpoint ~/nextcloud --output TARGET,FSTYPE,SOURCE
    TARGET              FSTYPE SOURCE
    /home/ada/nextcloud davfs  https://cloud.example.com/remote.php/dav/files/ada/
  13. List files through the mounted directory.
    $ ls ~/nextcloud
    Documents
    Photos
    welcome.txt
  14. Write a small test file through the mount.
    $ printf 'Nextcloud WebDAV check\n' > ~/nextcloud/mount-check.txt
  15. Read the test file from the mounted path.
    $ cat ~/nextcloud/mount-check.txt
    Nextcloud WebDAV check
  16. Remove the temporary test file.
    $ rm ~/nextcloud/mount-check.txt

    Leave the mount active if the Linux account should keep using it. Run umount ~/nextcloud later when the session is temporary.
    Related: How to unmount a disk in Linux