SFDX – Salesforce Command Line Interface (CLI) Commands – Part 1

In this blog, I would like to share with you the available Salesforce CLI Commands. CLI Commands will reduce your effort in creating and configuring the Apex, Visualforce, Lightning components. Refer to my previous blogs for setting up the SFDX with visual studio code IDE.


Run Salesforce CLI Commands

To run the command from Visual Studio Code, open the command palette by pressing Ctrl + Shift + P or Cmd + Shift + P or from the Integrated terminal (Ctrl+Cmd+`).

SFDX Commands – on Command Palette
login command sfdx
Integrated Terminal – with Login CLI Command

Available Salesforce CLI Commands

  1. Authorize or Login to an Org Using the Web-Based Flow

force:auth:web:loginclientidsetdefaultdevhubusernamesetalias  —instanceurl <https://test.salesforce.com>

    • setdefaultdevhubusername – set the org to be default developer hub org.  optional parameter
    • setalias –  to set the alias name for the connected org by mapping the session id (only generated on successful login)
    • clientid Consumer key of the connected app, optional parameter
    • instanceurl – Instance Url of the org to be connected,  https://login.salesforce.com be the default instance URL

Use the –setdefaultdevhubusername parameter only when authorizing a Dev Hub org. Do not use it when authorizing to other orgs, such as a sandbox.

More details

2.Logout from connected orgs

force:auth:logout –all | –targetusername  – -noprompt

  • – -all | -a  – Includes all authenticated orgs: for example, Dev Hubs, sandboxes, DE orgs, and expired, deleted, and unknown-status scratch orgs, Optional
  • – -noprompt |-p –  do not prompt for confirmation, Optional
  • – -targetusername | -u  – a username or alias for the target org. Overrides the default target org, Optional

– – all and – -targetusername can’t be used together.

More details.

3.Lists all orgs that the Salesforce CLI has created or authenticated

sfdx force:org:list – -all

  • – -all –Lists all authenticated orgs, including expired, deleted, and unknown-status scratch orgs, Optional
  • – -clean –  Remove all local org authorizations for deleted or expired orgs, Optional
  • -p |- -noprompt – Do not prompt for confirmation, Optional

More details.

4.Lists all alias

sfdx force:alias:list

Lists the aliases that the Salesforce CLI can use for various commands and tasks

5. Open a connected Org or Org component

Opens an org in your browser.

sfdx force:org:open -u <Alias | username> -p <Path to components>

  • -p | –path- Navigation URL path (not including domain), Optional
  • -r | –urlonly  –  Displays a navigation URL but doesn’t launch your browseOptional
  • -u | –targetusername – username or alias for the target org. Overrides the default target org, Optional


sfdx force:org:open -u sfdcEvangel

sfdx force:org:open –path one/one.app

More Details.

In the next blog, I will explain about the commands related to scratch org management.


Don’t forget to share the post if you like it & bookmark the blog for future references. If you have any comments or doubts on this post, Please comment on the box.




Leave a Reply

%d bloggers like this: