Skip to content

How To Open Postman Using Terminal In Ubuntu

API Testing Blog

Opening Postman from the Terminal in Ubuntu

Opening Postman from the Ubuntu terminal is a convenient way to streamline your workflow, especially when automating tasks or working with scripts. Here’s a step-by-step guide:

1. Installing Postman

  • Download: Head to the official Postman website (https://www.postman.com/) and download the appropriate Debian package for your Ubuntu system.
  • Installation: Open a terminal and navigate to the download directory. Run the following command:
    Terminal window
    sudo dpkg -i postman-*.deb
    Replace postman-*.deb with the actual downloaded filename.

2. Launching Postman

  • Use the postman command: After installation, you can directly launch Postman from the terminal using:

    Terminal window
    postman

    This will open the Postman application with your default browser.

  • Specifying the browser: If you want to use a different browser, you can use the --app flag:

    Terminal window
    postman --app=firefox

    Replace firefox with the name of your desired browser.

3. Opening Specific Collections or Workspaces

  • Collections: You can open a specific collection using the --collection flag:

    Terminal window
    postman --collection=my-collection.json

    Replace my-collection.json with the path to your collection file.

  • Workspaces: Similarly, you can open a specific workspace using the --workspace flag:

    Terminal window
    postman --workspace=my-workspace.json

    Replace my-workspace.json with the path to your workspace file.

4. Launching Postman in the Background

  • nohup command: To run Postman in the background, use the nohup command:
    Terminal window
    nohup postman &
    This will ensure Postman continues running even if you close the terminal window.

5. Integrating Postman with Scripts

  • Using postman command within scripts: You can integrate Postman commands directly into your bash scripts. For example:
    #!/bin/bash
    # Send a GET request to a specific endpoint
    postman --url="https://www.example.com/api" --method="GET" --header="Authorization: Bearer your_token"
    # Check the response status code
    if [ $? -eq 0 ]; then
    echo "Request successful"
    else
    echo "Request failed"
    fi

6. Using postman-cli for Advanced Automation

  • Install postman-cli: The postman-cli tool provides a more sophisticated command-line interface for Postman. Install it using:

    Terminal window
    npm install -g newman
  • Run collections using newman: You can execute a collection with newman and use various options like environment variables and reporters. For example:

    Terminal window
    newman run my-collection.json -e my-environment.json -r json > results.json

    This will run the my-collection.json using the variables defined in my-environment.json and save the results in results.json in JSON format.

By leveraging these terminal commands and the postman-cli tool, you can seamlessly integrate Postman into your automated testing and scripting workflows, enhancing your API testing experience in Ubuntu.

API Testing Blog