Get the Command-Line Tool

Now that you have created an account, you're ready to get the command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage.

The B2 command-line tool is available in four flavors. We offer an easy-to-use self-contained download for Windows and Linux users, a Homebrew formula for Mac users, a Python version from the Python Package Index (PyPI), and Github sources.

Self-Contained Download

The self-contained download is the easiest way to get up and running; no installation or Python needed. Simply download the version for your operating system and run it from a command window. For detailed documentation, visit our B2 CLI page.

Note: For Mac users, we recommend Homebrew as the quickest way to get set up. Mac users may also use the Python version or Github sources, if preferred.

Once you’ve downloaded the self-contained tool, you can learn how to use the B2 command-line tool in the usage section below. Prior to running the tool, execute the following command:
chmod +x <tool filename>


Homebrew is widely used in the Mac community, particularly amongst developers. We recommend using the B2 CLI Homebrew formula as the quickest setup method for Mac users:
brew install b2-tools

Python Version

If you'd like to run the Python version of the B2 command-line tool, it has been packaged in Python modules and published on the Python Package Index (PyPI). The easiest way to get the Python version of the B2 command-line Tool is using the standard Python pip3 installation tool.

Your first step is to make sure that you have Python 3 (3.7 or later) installed.

Python Installation on Mac (OSX)

To install Python3, pip3, and the B2 command-line tool on Mac OSX:

  1. Go to Python Releases for Mac OS X, select the "Latest Python 3 Release", and scroll to the bottom.
  2. Download and run the "macOS 64-bit installer"
  3. Open a new Terminal window and type pip3 install --upgrade b2

If you see a message like this, it's because Apple installs a really old version of one of the Python libraries that B2 uses:

  1. OSError: [Errno 1] Operation not permitted: '/tmp/pip-BMa2Su-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

You can work around this with the --ignore-installed option:

  1. sudo pip3 install --upgrade --ignore-installed b2

Python Installation on Windows

To install Python3, pip3, and the B2 command-line tool on Windows:

  1. Go to Python Releases for Windows, select the "Latest Python 3 Release", and scroll to the bottom.
  2. Download the "Windows x86-64 executable installer". For older 32-bit windows, download the "Windows x86 executable installer".
  3. Run the installer. By default it will install Python to your Users directory.
  4. Check the "Add Python 3.x to PATH" box to enable you to use Python from any directory.
  5. Open a Command Prompt window and type pip3 install --upgrade b2

Github Sources

This version of the B2 command-line tool is useful for Python developers who wish to work with the B2 command-line tool source code. The sources for the B2 Command Line Tool are available from Github in the B2_Command_Line_Tool project.

The first step is make sure that you have Python3 installed and then download the latest version of the source code from Github:

The Developer Info section of the project's file has all the info needed to build and contribute to the project.


Once you have the b2 command-line tool installed, you can type "b2" on the command-line to see all of the options.

If you see a message like b2: Permission denied on OSX or Linux, it's because we need to set the executable bit on the file with the command:

For more information about the calls that can be made in the B2 CLI, see our B2 CLI page or the downloadable B2 CLI Guide.

  This program provides command-line access to the B2 service.


      b2 authorize-account [<applicationKeyId>] [<applicationKey>]
      b2 cancel-all-unfinished-large-files <bucketName>
      b2 cancel-large-file <fileId>
      b2 clear-account
      b2 copy-file-by-id [--metadataDirective [copy|replace]] [--contentType <contentType>] \
               [--info <key>=<value>]* [--range start,end] \
               <sourceFileId> <destinationBucketName> <b2FileName>
      b2 create-bucket [-h] [--bucketInfo BUCKETINFO] [--corsRules CORSRULES] [--lifecycleRules LIFECYCLERULES] [--defaultServerSideEncryption {SSE-B2,none}] [--defaultServerSideEncryptionAlgorithm {AES256}] bucketName bucketType
      b2 create-key [--duration <validDurationSeconds>] [--bucket <bucketName>] [--namePrefix <namePrefix>] <keyName> <capabilities>
      b2 delete-bucket <bucketName>
      b2 delete-file-version [<fileName>] <fileId>
      b2 delete-key <applicationKeyId>
      b2 download-file-by-id [--noProgress] <fileId> <localFileName>
      b2 download-file-by-name [--noProgress] <bucketName> <fileName> <localFileName>
      b2 get-account-info
      b2 get-bucket [--showSize] <bucketName>
      b2 get-download-auth [--prefix <fileNamePrefix>] [--duration <durationInSeconds>] <bucketName>
      b2 get-download-url-with-auth [--duration <durationInSeconds>] <bucketName> <fileName>
      b2 get-file-info <fileId>
      b2 help [commandName]
      b2 hide-file <bucketName> <fileName>
      b2 list-buckets
      b2 list-keys
      b2 list-parts <largeFileId>
      b2 list-unfinished-large-files <bucketName>
      b2 ls [--long] [--versions] [--recursive] <bucketName> [<folderName>]
      b2 make-url <fileId>
      b2 sync [--delete] [--keepDays N] [--skipNewer] [--replaceNewer] \
          [--compareVersions <option>] [--compareThreshold N] \
          [--threads N] [--noProgress] [--dryRun ] [--allowEmptySource ] \
          [--excludeRegex <regex> [--includeRegex <regex>]] \
          [--excludeDirRegex <regex>] \
          [--excludeAllSymlinks ] \
          <source> <destination>
      b2 update-bucket [-h] [--bucketInfo BUCKETINFO] [--corsRules CORSRULES] [--lifecycleRules LIFECYCLERULES] [--defaultServerSideEncryption {SSE-B2,none}] [--defaultServerSideEncryptionAlgorithm {AES256}] bucketName bucketType
      b2 upload-file [--sha1 <sha1sum>] [--contentType <contentType>] \
          [--info <key>=<value>]* [--minPartSize N] \
          [--noProgress] [--threads N] <bucketName> <localFilePath> <b2FileName>
      b2 version

  The environment variable B2_ACCOUNT_INFO specifies the sqlite
  file to use for caching authentication information.
  The default file to use is: ~/.b2_account_info

  For more details on one command: b2 <command> --help

  When authorizing with application keys, this tool requires that the key
  have the 'listBuckets' capability so that it can take the bucket names
  you provide on the command line and translate them into bucket IDs for the
  B2 Storage service.  Each different command may required additional
  capabilities.  You can find the details for each command in the help for
  that command.

Now that you have the command-line tool, you're ready to make a bucket to hold your files.

Note: The ls command may time out when used on directories containing several million hidden files.