megatools(1)
============

NAME
----
megatools - Mega.nz command line tools


SYNOPSIS
--------
[verse]
'megatools df' [--free|--total|--used] [--mb|--gb|-h]
'megatools ls' [-e] [-h] [--header] [-l] [-R] [-n] [-0] [<remotepaths>...]
'megatools test' [-f|-d] <remotepaths>...
'megatools export' [--remove] <remotepaths>...
'megatools put' [--no-progress] [--overwrite] [--path <remotepath>] <paths>...
'megatools mkdir' <remotepaths>...
'megatools get' [--no-progress] [--path <path>] <remotepaths>...
'megatools get' --path - <remotefile>
'megatools copy' [-n] [--no-progress] [--no-follow] --local <path> --remote <remotepath>
'megatools copy' [-n] [--no-progress] --download --local <path> --remote <remotepath>
'megatools rm' <remotepaths>...
'megatools dl' [--no-progress] [--print-names] [--choose-files] [--path <path>] <links>...
'megatools dl' --path - <filelink>
'megatools dl' --list <links>...
'megatools reg' [--scripted] --register --email <email> --name <realname> [--password <password>]
'megatools reg' [--scripted] --verify <state> <link>
'megatools reg' [--scripted] --verify --email <email> --password <password> <link>
'megatools 2fa' [--scripted] [--setup | --enable <code> | --disable <code>]
'megatools passwd' [--new-password <password>]


DESCRIPTION
-----------

Megatools is a collection of programs for accessing the Mega.nz cloud
storage from the command line of your desktop or server.

You can upload and download individual files as well as entire directory
trees, download from public links without an account, create public links,
and stream files to stdout, for example to preview videos and audio files
without downloading them first.

Megatools are robust and optimized for fast operation - as fast as Mega
servers allow. Memory requirements and CPU utilization are kept at minimum.

You can register an account with man:megatools-reg[1], with the benefit of
having true control of your encryption keys.

Mega website can be found at https://mega.nz.

Megatools can be downloaded at https://xff.cz/megatools/


COMMANDS
--------

man:megatools-reg[1]::
	Register and verify a new mega account

man:megatools-2fa[1]::
	Show, enable or disable two-factor authentication

man:megatools-passwd[1]::
	Change the account password

man:megatools-df[1]::
	Show your cloud storage space usage/quota

man:megatools-ls[1]::
	List remote files and folders

man:megatools-test[1]::
	Test for existence of files or folders

man:megatools-export[1]::
	Create or remove public links for files and folders

man:megatools-mkdir[1]::
	Create remote folders

man:megatools-rm[1]::
	Remove remote files and folders

man:megatools-put[1]::
	Upload individual files

man:megatools-get[1]::
	Download individual files

man:megatools-dl[1]::
	Download from public file and folder links (doesn't require login)

man:megatools-copy[1]::
	Upload or download a directory tree

Run `megatools <command> --help` for a short list of the options of each
command. `megatools` without a command prints all the usages.

For compatibility with older versions, the commands can also be run as
`megadf`, `megals`, `megaput`, ... (symbolic links to `megatools`, installed
unless megatools was built with `-Dsymlinks=false`).


GETTING STARTED
---------------

Store your login in `~/.megarc` (see man:megarc[5]), so that you don't have
to give it to every command, and check that it works:

------------
$ cat ~/.megarc
[Login]
Username = your@email
Password = yourpassword
$ chmod 600 ~/.megarc
$ megatools df -h
Total: 20.0 GiB
Used:  6.4 GiB
Free:  13.6 GiB
------------

A few common tasks:

------------
$ megatools ls /Root                          # list your files
$ megatools mkdir /Root/Docs                  # create a folder
$ megatools put --path /Root/Docs report.pdf  # upload a file into it
$ megatools get /Root/Docs/report.pdf         # download it
$ megatools copy --local Photos --remote /Root/Photos   # upload a tree
$ megatools export /Root/Docs/report.pdf      # create a public link
$ megatools dl 'https://mega.nz/file/7YVWhCzZ#bauBlAkK...'  # download a link
------------

Without a config file, give the login with `-u` (and `-p`, or type the
password when asked).


CONFIGURATION FILES
-------------------

Megatools reads the login, speed limits, proxy and other settings from
`./.megarc` or `~/.megarc` (`mega.ini` on Windows). See man:megarc[5].
Options given on the command line override the config file.


SESSION CACHE
-------------

Logging in takes a few requests, so megatools keeps the session (the session
id and the account keys) and the list of remote files in a cache, encrypted
with a key derived from your password. Each command reuses it, and changes
made by megatools update it.

Changes made in the webclient or on another computer are not seen until the
file list in the cache times out (after 10 minutes by default, see `Timeout`
in man:megarc[5]), or until a command is run with `--reload`. A timed out
cache still reuses the session, so no new login (and no 2FA code) is needed
as long as the session is valid on the server.

The cache is stored in `~/.cache/megatools` (`$XDG_CACHE_HOME/megatools`),
on Windows in `%LOCALAPPDATA%\megatools`,
one file per account, readable only by you.


ENVIRONMENT
-----------

`MEGATOOLS_CACHE_DIR`::
	Directory for the session cache.

`TMPDIR`::
	When set (and `MEGATOOLS_CACHE_DIR` isn't), the session cache is
	stored there, as in older versions.

`XDG_CACHE_HOME`::
	Base of the default cache directory (`~/.cache` when not set). Not
	used on Windows.


EXIT STATUS
-----------

The commands exit with status 0 on success and 1 on an error. When a
command gets several paths or links, a failure of one of them is reported
and the others are still processed; the exit status is then 1.
man:megatools-put[1] exits with 2 when a file already exists, and
man:megatools-test[1] has its own exit statuses.


include::remote-paths.txt[]

include::footer.txt[]
