How To Install Postman In Ubuntu 20.04 Using Terminal
Installing Postman on Ubuntu 20.04 Using the Terminal
Postman is a powerful tool for API testing and development. While it’s typically used as a desktop application, you can also leverage its functionality directly from the terminal. This guide will walk you through installing and using Postman on Ubuntu 20.04 via the command line.
Prerequisites
- A Ubuntu 20.04 system.
- A user with sudo privileges.
- Basic understanding of the command line.
1. Download and Install Node.js
Postman’s command-line interface is built on Node.js. We need to install it before proceeding:
-
Add the NodeSource repository:
Terminal window curl -fsSL https://deb.nodesource.com/setup_18.x | sudo bash -This command downloads the NodeSource repository and adds it to your system’s sources.
-
Install Node.js:
Terminal window sudo apt-get install nodejsThis command retrieves the Node.js package and installs it on your Ubuntu machine.
2. Install the Postman CLI
Now that Node.js is in place, we can install the Postman CLI.
-
Use npm (Node Package Manager):
Terminal window sudo npm install -g newmanThis command installs the
newman
package globally, making the Postman CLI accessible system-wide.
3. Verify Installation
After installation, let’s check if everything is working correctly.
-
Execute the
newman -version
command:Terminal window newman -versionThis command should print the installed version of Newman, your command-line interface for Postman.
4. Running Your First Postman Test From the Terminal
Let’s see a simple example of how to use Postman CLI:
-
Create your Postman Collection:
- Open Postman (the desktop app) and build your collection of API requests. You can use an existing collection or create a new one.
- Make sure to save the collection as a JSON file (e.g.,
mytests.json
).
-
Run The Test:
Terminal window newman run mytests.jsonThis command will execute the tests defined in
mytests.json
. The output will display the results of each test request.
5. Additional Newman Commands:
Newman provides several commands for managing and running your tests.
- Generating Reports: (
newman run mytests.json -r html -o report.html
) - Environment Variables: (
newman run mytests.json -e environment.json
) - Running with Test Data: (
newman run mytests.json -d data.csv
)
6. Exploring Further
Postman CLI provides robust features for defining, executing, and analyzing your API tests. Explore the Newman documentation for further details: https://www.npmjs.com/package/newman
You can also visit the Postman website for guides and tutorials: https://www.postman.com/
By following these steps, you can successfully set up Postman on your Ubuntu 20.04 system and utilize its powerful command-line functionalities for API testing. This will empower you to automate your testing workflows, create comprehensive reports, and streamline your API development processes.