Whatbox Logo

Wiki > megacmd_old

megacmd is a utility for copying files to and from your Mega storage service.


Usage ./megacmd:
    megacmd [OPTIONS] list mega:/foo/bar/
    megacmd [OPTIONS] get mega:/foo/file.txt /tmp/
    megacmd [OPTIONS] put /tmp/hello.txt mega:/bar/
    megacmd [OPTIONS] delete mega:/foo/bar
    megacmd [OPTIONS] mkdir mega:/foo/bar
    megacmd [OPTIONS] move mega:/foo/file.txt mega:/bar/foo.txt
    megacmd [OPTIONS] sync mega:/foo/ /tmp/foo/
    megacmd [OPTIONS] sync /tmp/foo mega:/foo

  -conf="/Users/slakshman/.megacmd.json": Config file path
  -force=false: Force hard delete or overwrite
  -help=false: Help
  -ignore-same-size=false: Consider files with same size and path suffix as same
  -recursive=false: Recursive listing
  -verbose=1: Verbose
  -version=false: Version


megacmd is written against go 1.3 and exhibits bugs when compiled with newer versions. Additionally due to the amount of time since the last stable release and with no stable release obvious in the future is it preferable to compile the latest version from git to try and avoid known and fixed issues.

  1. Ensure you're in your home directory

  2. Create ~/bin and add it to your shell's PATH if you haven't done so before.

     mkdir -p ~/bin && echo "PATH=\$HOME/bin:\$PATH" >> ~/.bashrc && source ~/.bashrc
  3. Install the required Go 1.3 compiler. We will fetch an official pre-compiled binary ready for use.

     wget https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz
  4. Unpack the Go compiler

     tar xvf go1.3.3.linux-amd64.tar.gz
  5. Copy the Go binaries to the ~/bin directory

     cp ~/go/bin/* ~/bin/
  6. Clone the megacmd Git repository

     git clone https://github.com/t3rm1n4l/megacmd.git
  7. Change to the megacmd directory

     cd megacmd
  8. Compile megacmd

     GOROOT="${HOME}/go" make
  9. Copy the compiled megacmd to the ~/bin directory, allowing it to be used in any directory

     cp megacmd ~/bin/


You can edit ~/.megacmd.json using your favourite editor like nano (eg: nano ~/.megacmd.json), and fill out your user credentials. It is not currently possible to store these encrypted so plain text is the only option when using this tool.

    "User" : "your-mega-username",
    "Password" : "your-mega-password",
    "DownloadWorkers" : 4,
    "UploadWorkers" : 4,
    "SkipSameSize" : true,
    "Verbose" : 1