megatools - command line client application for Mega
====================================================

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

Megatools allow you to copy individual files as well as entire directory trees
to and from the cloud, download from public links without an account, and
create public links for your files and folders. You can also perform streaming
downloads, for example to preview videos and audio files without needing to
download the entire file.

Megatools are robust and optimized for fast operation - as fast as Mega servers
allow. Memory requirements and CPU utilization are kept at minimum. Megatools
can upload 70MiB/s and download 80 MiB/s on a cheap single core Intel based VPS.

You can register a mega account using the 'megatools reg' tool, with the
benefit of having true control of your encryption keys, compared to using the
mega.nz web client. Anything done in the web browser uses code you don't have
control over (unless it's your own website), and thus can't be fully trusted
with your password. Two-factor authentication and password changes are
supported too.

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

Megatools official website is at https://xff.cz/megatools/


Tools
=====

All tools are run as 'megatools <command>':

  reg      Register and verify a new mega account
  2fa      Show, enable or disable two-factor authentication
  passwd   Change the account password
  df       Show your cloud storage space usage/quota
  ls       List remote files and folders
  test     Test for existence of remote files or folders
  export   Create or remove public links for files and folders
  mkdir    Create remote folders
  rm       Remove remote files and folders
  put      Upload individual files
  get      Download individual files
  dl       Download from public file and folder links
           (doesn't require login)
  copy     Upload or download a directory tree

The old command names (megals, megaput, megadl, ...) are installed as
symbolic links to megatools, and a bash completion (commands, options and
remote paths) is installed with it.

All of these tools:

- Cache the session and the list of remote files locally for faster
  execution (in ~/.cache/megatools, %LOCALAPPDATA%\megatools on Windows).
  The cache is encrypted with a key derived from your password.
- Load the login and other settings from a configuration file (~/.megarc).


Usage
=====

Put your login into ~/.megarc, so that you don't have to pass it to every
command:

  [Login]
  Username = your@email
  Password = yourpassword

and make it readable only by you (chmod 600 ~/.megarc). Then for example:

  megatools df -h                               # check that the login works
  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/...#...'   # download from a link

See the man pages for how to use individual tools:

  man megatools
  man megatools-copy

'megatools <command> --help' lists the options of each command. Man pages are
also available online at:

  https://xff.cz/megatools/man/megatools.html


Installation on Windows
=======================

Official builds for 32bit and 64bit Windows are available at:

  https://xff.cz/megatools/builds/builds/

On Windows, the configuration file is called mega.ini (in your user profile
directory) instead of ~/.megarc.

Megatools is also available on Windows via Chocolatey thanks to ERap320.
See:

  https://chocolatey.org/packages/megatools/


Installation on macOS
=====================

Thanks to Carl Moden, megatools is available in Homebrew (http://brew.sh/).

You can therefore install megatools with:

  brew install megatools


Installation on your favorite GNU/Linux distribution
====================================================

Megatools may already be pre-packaged in the package repository
of your distribution. It is already available at least in:

- Arch Linux (AUR) - https://aur.archlinux.org/packages/megatools/
- Debian - https://packages.debian.org/sid/megatools
- Fedora - https://src.fedoraproject.org/rpms/megatools
- Gentoo - https://packages.gentoo.org/packages/net-misc/megatools
- openSUSE - https://software.opensuse.org/package/megatools
- Ubuntu - https://packages.ubuntu.com/search?keywords=megatools

Be sure to check your distribution's package repository first.


Installation on FreeBSD
=======================

Megatools is available in ports thanks to Maxim V. Kostikov:

  https://www.freshports.org/net/megatools/


Using a static build for Linux
==============================

Static builds (since version 1.11.0) provide a single megatools binary that
can be copied to any GNU/Linux distribution and run from there. They are made
for x86_64, i686, aarch64, arm and mips32. It is reported that you can even
copy an ARM build to your Android smartphone and run it from your phone.

This build is useful if you want to avoid the hassle of building megatools on
old distributions.

Static builds are available here:

  https://xff.cz/megatools/builds/builds/


Building megatools from source code
===================================

The official source code tarball is available at:

   http://xff.cz/megatools/builds/

You should check that the code was released by me by verifying PGP signatures
provided alongside the code.

You will need to install a few dependencies before you can build megatools from
source code. Package names of these dependencies differ depending on your
GNU/Linux distribution.

Runtime dependencies are: glib2 (>= 2.68), libcurl (>= 7.85) and openssl
(>= 3.0). Debian 12 and newer have them.

Build time dependencies are: a C compiler, meson, ninja and pkg-config
(pkgconf). Man pages are built when asciidoc and docbook2X (db2x_xsltproc,
db2x_manxml) are installed, and skipped otherwise.


On Debian, Ubuntu:

  apt-get -y install build-essential meson ninja-build pkg-config \
    libglib2.0-dev libssl-dev libcurl4-openssl-dev

  If you want to build man pages, too, you need to:

    apt install asciidoc docbook2x --no-install-recommends

On Fedora:

  dnf -y install gcc meson ninja-build pkgconf glib2-devel libcurl-devel \
    openssl-devel

On OpenSUSE:

  zypper -n install gcc meson ninja pkg-config glib2-devel libcurl-devel \
    openssl-devel

On Arch Linux:

  pacman -S --needed gcc meson ninja pkgconf glib2 curl openssl

On Alpine Linux:

  apk add build-base meson pkgconf glib-dev curl-dev openssl-dev

Meson options (-D<option>=<value>):

  -Dman=false        don't build the man pages
  -Dsymlinks=false   don't install the old megaXX command names

You can build megatools into your HOME directory, so that they'll not pollute
your /usr or /usr/local by using --prefix $HOME/.local option to meson.

Example build steps (take the latest version from the list of builds):

  wget https://xff.cz/megatools/builds/megatools-1.11.5.20250706.tar.gz{,.asc}
  gpg --verify megatools-1.11.5.20250706.tar.gz.asc
  tar xf megatools-1.11.5.20250706.tar.gz
  cd megatools-1.11.5.20250706
  meson setup --prefix $HOME/.local .build
  ninja -C .build
  ninja -C .build install

If you encounter issues, read the error messages carefully. They may contain
hints on how you can solve the issue yourself (missing dependencies, missing
C compiler build flags, etc.).

Now you can run megatools from ~/.local/bin.

  export PATH="$HOME/.local/bin:$PATH"
  megatools df -h


Building megatools from git repository and contributing code
============================================================

Megatools use the meson build system. See https://mesonbuild.com/

Build steps for meson are:

  git clone https://xff.cz/git/megatools
  cd megatools
  meson setup .build
  ninja -C .build
  sudo ninja -C .build install

You may need to install dependencies listed above in the previous section.


Third party tools/scripts
=========================

Megatools are meant as low-level tools that can be used as a base to create
more complicated tools for working with mega.nz. Other people have created
third party scripts on top of megatools. If you're one of them and want to
have your project listed here, let me know.

Some third party tools can be found at:

  https://amourspirit.github.io/mega_scripts/


Author
======

Megatools were written by Ondřej Jirman <megatools@xff.cz>, 2013-2026

My PGP key can be found at: https://xff.cz/key.txt
  (Fingerprint is: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED)

Official website is: https://xff.cz/megatools/


Contributors
============

- Alberto Garcia <berto@igalia.com>
- aurelien <aurelien.antunes@gmail.com>
- bAndie91 <bandie9100@gmail.com>
- Chris Tarazi <tarazichris@gmail.com>
- cyrozap <cyrozap@gmail.com>
- Dal1a <waveh@trimsj.com>
- David Guillen Fandos <david@davidgf.net>
- Erik Nordstrøm <erik@nordstroem.no>
- ivesen <ivesen@ivesen.moe>
- Johnathan Jenkins <john@nixheads.co.uk>
- Kagami Hiiragi <kagami@genshiken.org>
- Matthew Schultz <mattsch@gmail.com>
- Mert Dirik <mertdirik@gmail.com>
- Michael Ledin <mledin89@gmail.com>
- Michael Ripley <zkxs00@gmail.com>
- nyuszika7h <nyuszika7h@gmail.com>
- Palmer Dabbelt <palmer@dabbelt.com>
- protomouse <root@protomou.se>
- RealDolos <dolos@cock.li>
- strupo <sheeit@users.noreply.github.com>
- taiyu <taiyu.len@gmail.com>
- Tom Maneiro <tomman@tsdx.net.ve>
- Viktor (Icon) VAD <vad.viktor@gmail.com>
- wdlkmpx <wdlkmpx@gmail.com>


Support and bug reports
=======================

There is no support for megatools. I only accept patches and maintain reasonably
up to date static builds.

You can send patches to megatools@xff.cz if you want them integrated into
the main code base that may end up in Linux distributions.


License
=======

Megatools are licensed under GPLv2 with OpenSSL exemption, see LICENSE
file for details.

This product includes software developed by the OpenSSL Project for use
in the OpenSSL Toolkit. (http://www.openssl.org/)
