I have installed the new postgresql-12 on my ubuntu 22 and set the path but when I want to know the postgrsql status it is giving me this Error.
Thank you.
I have installed the new postgresql-12 on my ubuntu 22 and set the path but when I want to know the postgrsql status it is giving me this Error.
Thank you.
You are getting this error because sudo
is not in path,
Everything is a file in linux system, even commands as well.
You can check content of PATH variable by executing command $ echo $PATH If you do not find /usr/bin in the output than you can append /usr/bin in PATH variable by executing command
export PATH=$PATH:/usr/bin
because sudo
file is located in 2 places, i.e /usr/bin or /bin
directories.
It's happening because of some missing line in .bashrc
file or which ever shell you are using, you can check that by echo $SHELL
Just add the export line in your respective shell config file and it'll be permanent solution.
For Reference see this answer on AskUbuntu.
Since sudo
is looking is trying to locate /bin:usr/bin
in PATH, you can try exporting this in the PATH environment variable.
export PATH=$PATH:/bin:/usr/bin
Note: If you want to make this change permanent, try adding it at the end of ~/.bashrc
file and then saving the changes using source ~/.bashrc
.
sudo cannot find the especified path, to solve it just modify your ~/.bashrc
file adding in the last line:
export PATH="/bin:/usr/bin:$PATH"
and after it run the command: source ~/.bashrc
/usr/bin
is not included in your environment PATH.
export PATH="/usr/bin:$PATH"
exit out the terminal and try again.
Do not just copy-paste the command "export PATH=/usr/lib/postgresql/12/bin/:PATH".
Please ensure that you provide the correct path to the PostgreSQL bin directory. You can find the path of the bin directory by running the command inside the bin directory.
pwd
Also you can follow this blog tutorial which is a step-by-step tutorial for installing PostgreSQL from source.
The error already tells you the problem. sudo
is not in the PATH.
Hence, you should add sudo to PATH in ~/.bashrc
and run source ~/.bashrc
.
This should solve this issue.
The error in the screenshot is saying that /bin:/usr/bin
is not included in the PATH environment variable. So, you need to add this directory to the PATH variable:
export PATH="/bin:/usr/bin:$PATH"
Your system is unable to locate a particular file.
Run this command export PATH="/bin:/usr/bin:$PATH"
before checking the status of PostgreSQL in your system.
You get this error because you are you using systemctl
when you did not install Postgres as a system service. Since you installed from source code you have to navigate into your Postgres directory and run bin/pg_ctl status -D /path/to/data_directory
to ascertain the status of your Postgres instance.
I think according to the error you should just add the /bin:/usr/bin
paths to the PATH as stated, you can do that by running the following command:
export PATH=$PATH:/bin:/usr/bin
What the command does, is that it adds the /bin:/usr/bin
paths to PATH.
Hope that was helpful, let me know how it goes with you!.