pg_ctl: command not found
Let’s say you have a fresh new installation of PostgreSQL, then you open up a new terminal window to check the PostgreSQL server and type
$ pg_ctl
and boom!:
$ pg_ctl: command not found
Why? Does the installation fail? What about psql the official client? Let’s see…
$ psql –version
$ psql (PostgreSQL) 16.0 (Ubuntu 16.0-1.pgdg20.04+1)
OK, we know that PostgreSQL is installed, the official client with the –version flag returns the actual version of the database.
Let’s try the following command:
$ pg_config
Nice! A lot information about the installation. Everything seems OK.
Let’s do one last verification:
$ ls -l /usr/lib/postgresql/16/bin/
Wow, all the PostgreSQL applications are there!!! So what’s happening?
When a command is not found and you are completely sure the application is installed, one of the common reason is that weed need to add the PATH to the environment.
$ vim ./bashrc
Let’s open the bashrc file and the following line:
$ export PATH="$PATH:/usr/lib/postgresql/16/bin"
Reload your terminal and let’s check if is OK:
$ pg_ctl –version
$ pg_ctl (PostgreSQL) 16.0 (Ubuntu 16.0-1.pgdg20.04+1)
…and done!