Connect the CLI to Your Developer Hub
In this exercise, you will…
- Open your system’s terminal/shell program (the “command line”)
- Make sure the Salesforce CLI is installed
- Authenticate the CLI to your Developer Hub
Open your system’s terminal/shell program (the “command line”)
In order to use the Salesforce CLI, you need to get to a “command line” on your local machine.
- MacOS users should use the Terminal app (or something similar like iTerm)
- Windows users should use PowerShell if possible, though the Commannd Prompt (cmd.exe) will also work
Make sure the Salesforce CLI is installed
NOTE: As of May 29, 2019, the sfdx force --version
command has been removed from the CLI. To complete this step, please use sfdx plugins --core
to ensure that your CLI is installed correctly.
Let’s start with a simple command that will help make sure that the Salesforce CLI is installed and running OK on your machine.
Execute this command:
sfdx force --version
After executing the above, your terminal should look something like this:

Authenticate the CLI to your Developer Hub
The Salesforce CLI can’t do anything interesting until you’ve connected it to your Developer Hub. To do that you’ll use the force:auth:web:login
command.
Execute this command:
sfdx force:auth:web:login -d -a DevHub
Salesforce DX Command / Flags | Description |
---|---|
force:auth:web:login |
Authorizes a Salesforce org by opening a browser so you can log in through salesforce.com. |
-d (--setdefaultdevhubusername) |
Sets the authenticated org as the default Dev Hub org for scratch org creation. |
-a (--setalias) |
Sets an alias for the authenticated org. |
Your web browser will open automatically. When prompted…
- Enter the username and password for your Developer Hub org
- Click the “Log In” button to continue

After logging in, you’ll be asked to allow the Salesforce CLI Connected App to access your org…
- Review the capabilities needed by the Salesforce CLI to create scratch orgs on your behalf
- Click the “Allow” button to continue

After authorizing the Salesforce CLI Connected App, your terminal should look something like this:
