psql command not found - Ubuntu
How to Install psql Command on Ubuntu
If you are using Ubuntu and encounter the error “psql command not found,” it means that the psql command-line tool for interacting with PostgreSQL databases is not installed on your system. In this tutorial, we will guide you through the process of installing psql on Ubuntu.
Step 1: Update Package Index
Before installing psql, it’s recommended to update the package index to ensure you are installing the latest version available in the Ubuntu repositories. Open a terminal and run the following command:
sudo apt update
Step 2: Install PostgreSQL Client
To install the PostgreSQL client, which includes the psql command, run the following command:
sudo apt install postgresql-client
If the postgresql-client package is not found, you can try installing the postgresql package instead:
sudo apt install postgresql
Step 3: Verify Installation
After the installation is complete, you can verify that psql is installed by running:
psql --version
If you see the version information for psql, then the installation was successful.
Conclusion
In this tutorial, you have learned how to install the psql command-line tool on Ubuntu. By following these steps, you can now use psql to interact with PostgreSQL databases directly from your terminal.