I am running Ubuntu Server 18.04, and I was wondering if it was possible to download mega.nz files from the command-line, e.g. using putty or some other tool?


4 Answers 4


Megatools allow you to copy individual files as well as entire directory trees to and from the cloud. You can also perform streaming downloads for example to preview videos and audio files, without needing to download the entire file first. Megatools are robust and optimized for fast operation - as fast as Mega servers allow. This is quite fast. Memory requirements and CPU utilization are kept at minimum.

Megatools is provided in Ubuntu by the universe repository. You can install megatools in all currently supported versions of Ubuntu with the following command:

sudo apt install megatools

Then run man megatools to show the available command line tools. The SYNOPSIS section provides a synopsis of the available commands.


As of November/23 the megatools repo has been removed, you should look for megacmd (github, from @milahu's answer) instead.

As of November/21, Ubuntu 20.04 and megatools 1.10.2, you can use Megatools as mentioned in @karel's answer, but megadl has an unfixed issue while dealing with MEGA URLs.

If you need to download a file, the URL will be something like https://mega.nz/file/<some_id>#<some_other_id> and needs to be changed into https://mega.co.nz/#!<some_id>!<some_other_id> for it to work. Remember to put between single quotes, so:

megadl 'https://mega.co.nz/#!<some_id>!<some_other_id>'

Folder URLs need to be adapted too, from https://mega.nz/folder/<some_id>#<some_other_id> to https://mega.co.nz/#F!<some_id>!<some_other_id>, so:

megadl 'https://mega.co.nz/#F!<some_id>!<some_other_id>'
  • strLink="https://mega.nz/folder/ExdyETia#m0FwgdqrHmfnS4Xakn_rMg/file/R00wWJYZ";megadl "$(echo "$strLink" |sed -r -e 's"mega.nz"mega.co.nz"' -e "s'#'!'g" -e 's"/folder/"/#F!"' -e 's"/file/"!"')" (the link is for lineageos btw) but I think this link is not downloading (despite accepting the link now) because it is in an encrypted folder see github.com/megous/megatools/issues/254. I will try to compile the latest from that github. Jun 1, 2022 at 5:47
  • It seems that the bug was resolved now, as far as I can see from the bug tracker. Jan 22, 2023 at 17:13
  • The issue was already marked as closed back when I wrote this answer. You can see people as recently as Jan 21 github.com/megous/megatools/issues/157#issuecomment-1013698756 claiming the workaround is needed and works as expected. I haven't touched in this recently, so I can neither confirm nor deny it's been fixed. Jan 22, 2023 at 18:37

megacmd works without login

mega-get "https://mega.nz/file/bFdkyJhK#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

have fun building this on debian : P

"proper" distros like nixos or arch have a package for megacmd ...

but you can use nix on debian : D

sudo apt install nix nix-setup-systemd
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel update
export PATH=$PATH:$HOME/.nix-profile/bin

nix-env --install megacmd
mega-get ...
  • this only works if is a public shares; for private ones you'll still have to login
    – Adrian
    Jan 11, 2022 at 15:17

I solved this making a .sh file with 600 lines that look like this:

megadl 'https://mega.nz/xxxxxxxxxxxxxxxxxxxxxxxxx'

You hace to download megatools previously. Give to your .sh file execution permissions (chmod +x fileName) and launch it into your command line (./fileName.sh)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .