Newer Version Available

This content describes an older version of this product. View Latest

Install the Salesforce CLI

Use the CLI commands to create environments for development and testing, synchronize source code between your scratch orgs and version control system, and execute test suites.

Install the CLI on macOS

You install the Salesforce CLI on macOS with a .pkg file.
  1. Download the .pkg file.
  2. Double-click the .pkg file.

Install the CLI on Windows

You install the Salesforce CLI on Windows with an .exe file.
Download and run the Windows installer.

The Salesforce CLI works best within the native Windows command prompt (cmd.exe) and the Microsoft Powershell. We do not recommend using the Salesforce CLI with a Linux terminal emulator, such as cygwin or MinGW, because support for bugs is limited.

Warning

Install the CLI on the Windows 10 Subsystem for Linux

The Windows Subsystem for Linux (WSL) allows you to run native Linux command-line tools on Windows 10 alongside your traditional Windows desktop.
  1. From the Run dialog box (Windows key + R), run optionalfeatures.exe.
  2. In Windows Features, select Windows Subsystem for Linux.
    Windows Subsystem for Linux
  3. From the command prompt, enter bash, which triggers the installation of Ubuntu. At the prompt, enter y to agree to install the components.
    1> bash
  4. When the Ubuntu install is finished, create the directory /mnt/c/ProgramFilesLinux.
    1mkdir /mnt/c/ProgramFilesLinux
  5. Change to the new directory.
    1cd /mnt/c/ProgramFilesLinux
  6. Download or wget one of these tarballs.
    1wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
    1wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-386.tar.xz
  7. Create an sfdx directory.
    1mkdir sfdx
  8. Unpack the contents for your tarball version:
    1tar xJf sfdx-linux-amd64.tar.xz -C sfdx --strip-components 1
    1tar xJf sfdx-linux-386.tar.xz -C sfdx --strip-components 1

    -C unpacks the contents in the sfdx directory, while --strip-components 1 removes the root path component.

  9. Run the install script.
    1./sfdx/install

    The Salesforce CLI is installed in /usr/local/bin/sfdx.

Install the CLI on Linux

The Linux version of the Salesforce CLI is distributed as a tarball.

Find the download URL for your tarball from this manifest file. The downloads section lists unversioned URLs for the latest installers, which are especially useful for CI use cases. Select the URL based on your target platform.

  1. Download or wget one of these tarballs.
    1wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
    1wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-386.tar.xz
  2. Create an sfdx directory.
    1mkdir sfdx
  3. Unpack the contents for your tarball version:
    1tar xJf sfdx-linux-amd64.tar.xz -C sfdx --strip-components 1
    1tar xJf sfdx-linux-386.tar.xz -C sfdx --strip-components 1

    -C unpacks the contents in the sfdx directory, while --strip-components 1 removes the root path component.

  4. Run the install script.
    1./sfdx/install

    The Salesforce CLI is installed in /usr/local/bin/sfdx.

Install the CLI with npm

If you've installed Node.js on your computer, you can use npm to install the Salesforce CLI. This method lets you install the Salesforce CLI from the command line and can be especially useful for continuous integration (CI) use cases.

This installation method is a good option if you don’t have administrator permissions on your workstation, or if group policy blocks CLI installation and updates. Installing the CLI with npm doesn’t require root permissions.

  1. Ensure that Node v8.6.0 or later is installed on your computer. For example, on macOS or Linux:
    1node --version
    2v8.6.0
  2. Run this command.
    1npm install sfdx-cli --global

    If you receive a permission error when installing the CLI using npm, we recommend not using sudo. See Fixing npm permissions.

Verify Your Installation

Verify your Salesforce CLI installation and plug-in versions.
Run this command to verify the Salesforce CLI version:
1sfdx --version
2sfdx-cli/6.0.10-3713d7b alpha (darwin-x64) node-v8.6.0

Run this command to verify the Salesforce CLI plug-in version:

1sfdx plugins --core
2salesforcedx 41.2.0 (core)

This command returns a list of the other plug-ins installed in the CLI:

1sfdx plugins

The core salesforcedx plug-in is not included in the preceding list unless you’ve explicitly installed a newer version with the sfdx plugins:install command.

Run this command to return a list of the command families in the force topic:

1sfdx force --help

This command returns all the force commands:

1sfdx force:doc:commands:list

Install a Specific Version of the salesforcedx Plug-In

By default, the latest version of the Salesforce CLI and salesforcedx plug-in is installed when you install the CLI for the first time. Sometimes, however, you want to use a specific version of the salesforcedx plug-in.
Run this command to install a specific version of the Salesforce CLI, in this example, version 42.2.0:
1sfdx plugins:install salesforcedx@42.2.0