Accessing a webdav drive from Linux shell
Table of Contents
Option 1: Connect on an interactive session
Pre-requisites
- You need to retrieve the webdav URL from your provider. Sample:
https://testportal.com/remote.php/dav/files/your_username/
- Install command line tool “cadaver” (installation method depends on your Linux distribution)
Connecting via “cadaver”
cadaver https://testportal.com/remote.php/dav/files/your_username/
You will be prompted to provide your password. Once logged in, you will be connected to a webdav shell.
Available commands
ls [path]
List contents of current [or other] collection
cd path
Change to specified collection
pwd
Display name of current collection
put local [remote]
Upload local file
get remote [local]
Download remote resource
mget remote...
Download many remote resources
mput local...
Upload many local files
edit resource
Edit given resource
less remote...
Display remote resource through pager
mkcol remote...
Create remote collection(s)
cat remote...
Display remote resource(s)
delete remote...
Delete non-collection resource(s)
rmcol remote...
Delete remote collections and ALL contents
copy source... dest
Copy resource(s) from source to dest
move source... dest
Move resource(s) from source to dest
lock resource
Lock given resource
unlock resource
Unlock given resource
discover resource
Display lock information for resource
steal resource
Steal lock token for resource
showlocks
Display list of owned locks
propnames res
Names of properties defined on resource
chexec [+|-] remote
Change isexecutable property of resource
propget res [propname]
Retrieve properties of resource
propset res propname value
Set property on resource
set [option] [value]
Set an option, or display options
open URL
Open connection to given URL
close
Close current connection
quit
Exit program
unset [option] [value]
Unsets or clears value from option.
lcd [directory]
Change local working directory
lls [options]
Display local directory listing
lpwd
Print local working directory
logout
Logout of authentication session
help [command]
Display help message
Option #2: Mount the remote webdav as a local folder
I find this method much more convenient.
- Install davfs file system drivers
- apt-get install davfs2 or yum install davfs2
- Add your local user to “davfs” group
- usermod -aG davfs2 <username>
- Create a local folder to use as mount point
- mkdir /yourmountpoint
- Create a folder to store your users’s davfs settings
- mkdir ~/.davfs2
- Copy davfs global settings to your user’s folder
- cp /etc/davfs2/secrets ~/.davfs2/secrets
- Add an entry to /etc/fstab:
https://testportal.com/remote.php/dav/files/your_username/ /yourmountpoint davfs user,rw,noauto 0 0
- Mount the share
- mount /yourmountpoint