I have installed PostgreSQL and it is working ok. However, when I went to restore a backup I got the error -bash: psql: command not found:
[root#server1 ~]# su postgres
[postgres#server1 root]$ psql -f all.sql
bash: psql: command not found
[postgres#server1 root]$
What have I done wrong?
export PATH=/usr/pgsql-9.2/bin:$PATH
The program executable psql is in the directory /usr/pgsql-9.2/bin, and that directory is not included in the path by default, so we have to tell our shell (terminal) program where to find psql. When most packages are installed, they are added to an existing path, such as /usr/local/bin, but not this program.
So we have to add the program's path to the shell PATH variable if we do not want to have to type the complete path to the program every time we execute it.
This line should typically be added to theshell startup script, which for the bash shell will be in the file ~/.bashrc.
perhaps psql isn't in the PATH of the postgres user. Use the locate command to find where psql is and ensure that it's path is in the PATH for the postgres user.
The question is for linux but I had the same issue with git bash on my Windows machine.
My pqsql is installed here:
C:\Program Files\PostgreSQL\10\bin\psql.exe
You can add the location of psql.exe to your Path environment variable as
described in this other answer, and shown in the screenshot below:
After changing the above, please close all cmd and/or bash windows, and re-open them (as mentioned in the comments #Ayush Shankar). If you are using an IDE like Visual Studio Code, please close and re-open the entire IDE (as mentioned in the comments #Somraj Chowdhury)
You might need to change default logging user using below command.
psql -U postgres
Here postgres is the username. Without -U, it will pick the windows loggedin user.
It can be due to psql not being in PATH
$ locate psql
/usr/lib/postgresql/9.6/bin/psql
Then create a link in /usr/bin
ln -s /usr/lib/postgresql/9.6/bin/psql /usr/bin/psql
Then try to execute psql it should work.
In case you are running it on Fedora or CentOS, this is what worked for me (PostgreSQL 9.6):
In terminal:
$ sudo visudo -f /etc/sudoers
modify the following text from:
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
to
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.6/bin
exit, then:
$ printenv PATH
$ sudo su postgres
$ psql
To exit postgreSQL terminal, you need to digit:
$ \q
Source: https://serverfault.com/questions/541847/why-doesnt-sudo-know-where-psql-is#comment623883_541880
If you are using the Postgres Mac app (by Heroku) and Bundler, you can add the pg_config directly inside the app, to your bundle.
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
...then run bundle again.
Note: check the version first using the following.
ls /Applications/Postgres.app/Contents/Versions/
Check if PostgreSQL is installed or not.
If not you can do the same in ubuntu using this command.
sudo apt update
sudo apt install postgresql postgresql-contrib
there must be two reasons for this either the package is not install or psql is not defined in the PATH
the simple way is to create a link within the /usr/bin or /usr/local/sbin/
First find the the file
sudo find / -name psql
then create soft link
sudo ln -sf /opt/pgpro/1c-14/bin/psql /usr/local/sbin/psql
Sometimes we face this issue when the gem installation command doesn't find the pg client library for various reasons, such as if psql is not in the path.
In those cases, providing the command with the path to pg_config may fix the issue.
gem install pg -v 1.3.5 -- --with-pg-config=/path/to/pg_config
In my case, I faced a similar issue when I installed postgresql#12 with Homebrew in the Rosetta environment.
Following command solved the issue in my case.
gem install pg -v 1.3.5 -- --with-pg-config=/usr/local/Homebrew/Cellar/postgresql#12/12.13/bin/pg_config
Related
I am trying to install KICS into AWS EC2 (Ubuntu). I am suing the one-line install script:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
However when I run:
kics version
or
which kics
It seems like it cannot find the command. It forces me to reboot before being able to see it, however rebooting is not an option in my use-case.
As per the documentation of KICS (https://docs.kics.io/latest/getting-started/#one-liner_install_script):
Run the following command to download and install kics. It will detect your current OS and download the appropriate binary package, defaults installation to ./bin and the queries will be placed alongside the binary in ./bin/assets/queries:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
If you want to place it somewhere else like /usr/local/bin:
sudo curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash -s -- -b /usr/local/bin
So by default, it will install in /home/<user>/bin folder if using the first command. This folder may not be in PATH environment variable because of which which command doesn't work.
So, you need to install using the second command in order to install in /usr/local/bin which should probably be there in PATH and after that which command will also work.
I'm trying to install globally some packages for my Unix environment on Windows with WSL. I use nvm to manage the different versions of Node.js.
The problem is while using the sudo command before a global npm install :
sudo npm install --global prompt-pure
I get an error: sudo: npm: command not found !
Doing a simple npm install --global pure-prompt will work, but as I'm not super user, the global installation ends up with a permission error.
How can I fix this annoying problem and keep nvm ?
Thanks by advance
When you try to run sudo npm, it tries to run the npm binary file /usr/bin/npm but your binary is located in a different place, which can be found running which npm.
Example: /home/damo/.nvm/versions/node/v8.11.1/bin/npm
The solution is to create a link in /usr/bin/ pointing to the actual binary:
sudo ln -s "$(which npm)" /usr/bin/npm
You can also add the following link so you can run sudo node
sudo ln -s "$(which node)" /usr/bin/node
For me I needed to actually cheat and run as root before installing node as root. For this I ran sudo su in a Ubuntu WSL term and then installed node.
Once I did that I could sudo su then npm run special-script.
I don't know a better way to get a script to attach to restricted ports like 443 for testing https connections but it works.
As you will find in the man file for sudo man sudo sudo will execute a command as another user. That other user has a different home directory to you and access to different commands
When i run sudo which node i get nothing, but which node returns /home/damo/.nvm/versions/node/v8.11.1/bin/node
Lets look at your actual goal. You say you are trying to install pure-prompt, i know this does not ask your explicit question but given you have zsh installed have you tried oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh) i use this on every install of linux i ever have to work with (VMs, WSL, docker). Very customizable and looks great out of the box.
I'm currently running into an issue where I am not able to use makepkg on my server.
I've verified that pacman is installed correctly so I'm assuming this has to have something to do with my environment PATH?
Trying to run makepkg from my bash prompt I just get
-bash: makepkg: command not found
Well, you need the correct path of command...
Try exec echo in $PATH and try export the path command to $PATH.
export PATH=$PATH:/path/of/command
Try reinstalling pacman, like so: sudo pacman -S pacman
I am trying to install pycharm on my linux OS.
following the instructions pycharm/dowload.
Since I run a linux machine I made sure the pychrarm files in the current directory:
ietX220:~$ ls
Desktop pycharm-community-4.0.1
Documents Music
pycharm-community- 4.0.1.tar.gz
Downloads New Folder Templates
Dropbox octave-workspace Videos
examples.desktop Pictures VirtualBox VMs
jdk1.8.0_25 Public Win7-PV2hh-6c3HY-
QJHM9-8RJJH-P86W8.iso
ietX220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
As you can see the pycharm file is in the current(home) directory but is not found.
Then I opened the tar file made pycharm.sh executable:
chmod +x pycharm.sh
And then ran:
~/pycharm-community-4.0.1/bin$ ./pycharm.sh
Startup Error: Application cannot start in headless mode
What am I doing wrong?
I am having the same issue. It looks like maybe you and I both have a minimal (headless) Java install on our systems. Use your system's method for finding installed packages and search for Java, and i'll bet you find only openjdk-headless
yum list installed | grep openjdk
# or on debian-based systems
# dpkg --get-selections | grep openjdk
# =>java-1.7.0-openjdk-headless
Solution then is to install the same package without the "-headless" suffix.
Here's where I am getting my information for the solution: https://bugzilla.redhat.com/show_bug.cgi?id=1177379
I had the same problem and as mentioned before the error was that openjdk was headless. What i did is i installed from the begining openjdk using the command apt-get install default-jdk (for ubuntu). I know it's not the best way to do it, however it is rather quick and simple.
If you have already all the prerequisites (such as Java) installed, try out charmy (PyCharm installer for Linux).
virtualenv charmy-env
source charmy-env/bin/activate
pip install charmy
charmy install
That will install PyCharm into your home directory. It will also simplify your feature PyCharm upgrades. To upgrade you would just have to type
charmy install
instead of downloading distribution manually, unpacking it, etc.
See https://pypi.python.org/pypi/charmy for more.
PYcharm is now available as a snap. Can be easily installed as below
sudo apt update && sudo apt install snapd
Then the community edition can be installed by
sudo snap install pycharm-community --classic
The classic escape is to get snaps that have been published with classic confinements
220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
gz files are not executable files. I think the current directory is not in your PATH variable. To get around that you would do "./pycharm-community-3.0.1.tar.gz" and you should see the message "Permission denied" as the gz file would not have execute permission. And if you gave it execute permission it would say "cannot execute binary file: Exec format error".
These are the instructions from the JetBrains website:
Copy the pycharm-*.tar.gz to the desired installation location
(make sure you have rw permissions for that directory)
Unpack the pycharm-*.tar.gz using the following command:
tar xfz pycharm-*.tar.gz
Remove the pycharm-*.tar.gz to save disk space (optional)
Run pycharm.sh from the bin subdirectory
NOTE: PyCharm on Linux doesn't need special installation or running
any installation script. It runs out of the pycharm-*.tar.gz
If you run the command "tar xfz pycharm-*.tar.gz" you should end up with a directory in your current directory named "pycharm-community-4.0.3".
If you cd pycharm-community-4.0.3/bin, "ls -al" should show that pycharm.sh is already executable. Run pycharm.sh and you should be done. The script will prompt for a password at the end so it can put a startup script in a system directory. You must have admin privileges for that part to work. But if you don't, you can still start PyCharm by executing "[path to pycharm directory]/bin/pycharm.sh &" at the command prompt.
I am not sure what the "NOTE:" is saying, but I would ignore it as you get a working PyCharm by doing what it says above the NOTE: .
Setup the newest stable jdk(like jdk1.7 or jdk 1.8) in your system, and set it is the default jdk.
1.download JDK8
2.SET JAVA HOME
sudo gedit /etc/environment
export JAVA_HOME=/home/username/Java/jdk1.8
export JRE_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
sudo gedit /etc/profile
//before umask xxx adde
export JAVA_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$JAVA_HOME/bin
3. run pycharm
./pycharm.sh
I am currently using Red Hat linux. I just want to find out whether MySQL is installed in that system. If yes where is it located? can anyone help please...
Type mysql --version to see if it is installed.
To find location use find -name mysql.
If you're looking for the RPM.
rpm -qa | grep MySQL
Most of it's data is stored in /var/lib/mysql so that's another good place to look.
If it is installed
which mysql
will give you the location of the binary.
You could also do an
updatedb
and a
locate mysql
to find any mysql files.
yum list installed | grep mysql
Then if it's not installed you can do (as root)
yum install mysql -y
to ckeck the status use the below command, which worked on debian....
/etc/init.d/mysql status
to start my sql server use the below command
/etc/init.d/mysql start
to stop the server use the below command
/etc/init.d/mysql stop
Usually you can find a program under a subdirectory "../bin".
System programs are under /usr/bin or /bin. To check where files of mysql package are placed, on RHEL 6 type like this :
rpm -ql mysql (which is the main part of the package)
and the result is a list of "exe" files such as "mysqladmin" tool. About to know the version of the server, run the command:
mysqladmin -u "valid-user" version
rpmquery <package Name> By this command you can check which package is installed.
For Example: rpmquery mysql