PostgreSQL: command not found - macos

I installed PostgreSQL via MacPorts. However, going to /opt/local/lib/postgresql84/bin I am unable to execute any of the pg commands. Does anyone know what I am doing wrong?

When you say "going to", it sounds like you're using the cd command to change to that directory. Something like:
$ cd /opt/local/lib/postgresql84/bin
$ psql
psql: command not found
Normally on Unix systems, the current directory is not part of your executable search path. So either explicitly execute psql from the current directory using ./:
$ cd /opt/local/lib/postgresql84/bin
$ ./psql
or, add the directory to your PATH:
$ export PATH=/opt/local/lib/postgresql84/bin:$PATH
$ psql

I had installed postgres (Mac,The capitan SO) with the dmg and also I got the same issue. I had to install psql through brew. Try with this :
brew install postgres
This worked for me.

Try this command:
find / -name psql

Try
whereis psql

Related

Linux: Curl installed but -bash: :curl: command not found

Running Debian Stretch on an r710. Using the non-free/contrib build for driver support.
When I try to use packages that I've installed (curl, zpool, etc), I have to include the path to the package... Which is a pain when I don't always know where packages install to.
Two questions:
How do I remedy the path issue in the short term?
How do I amend Debian so that when packages are installed, their paths update/install automatically?
Just install it by:
apt install curl
or sudo apt install curl
Find where the command is stored by
which <command>
Either you can try run curl from the output above for example /usr/bin/curl then try execute this:
/usr/bin/curl
For a temporary fix until you solve the real problem you can do:
cd /usr/local/bin; ln -s $(which curl) curl
Or you can just set an alias:
echo "alias curl='$(which curl)'" >> ~/.bashrc; . ~/.bashrc
Troubleshoot your problem:
Check so PATH folder has the correct paths exported:
printf "%s\n" $PATH
Modify current PATH
Use the export command to add new paths and see if that works you can then update your ~/.bashrc or ~/.bash_profile, but first you can try in shell without adding it permanent to $PATH
export PATH=$PATH:/missed/bin/folder
To format your PATH variable for easy viewing in future you can add below function to your .bashrc
function path(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}

command not found even when "which" shows its path with sudo

I'm on Fedora release 25 with zsh 5.2
I am trying to use a command with sudo. (In this example, docker-compose)
Problem:
which command shows where it is.
$ sudo PATH=$PATH which docker-compose
/usr/local/bin/docker-compose
In spite of that, command not found
$ sudo PATH=$PATH docker-compose
sudo: docker-compose: command not found
I could make it work by sudo `which docker-compose` but I want to know why this occurs.
What I tried:
I double-quoted PATH=$PATH but got the same result.
$ sudo "PATH=$PATH" docker-compose
sudo: docker-compose: command not found
/usr/local/bin/ is not on root path. Check with
sudo bash -c 'echo "$PATH"'
/usr/sbin:/usr/bin:/sbin:/bin
Use absolute path to the command.
Adding /usr/local/bin to root path seems to be a security risk.

skip installing confirm('yes' or 'no') in Dockerfile [duplicate]

How do I install the anaconda / miniconda without prompts on Linux command line?
Is there a way to pass -y kind of option to agree to the T&Cs, suggested installation location etc. by default?
can be achieved by bash miniconda.sh -b (thanks #darthbith)
The command line usage for this can only be seen with -h flag but not --help, so I missed it.
To install the anaconda to another place, use the -p option:
bash anaconda.sh -b -p /some/path
AFAIK pyenv let you install anaconda/miniconda
(after successful instalation)
pyenv install --list
pyenv install miniconda3-4.3.30
For a quick installation of miniconda silently I use a wrapper
script script that can be executed from the terminal without
even downloading the script. It takes the installation destination path
as an argument (in this case ~/miniconda) and does some validation too.
curl -s https://gist.githubusercontent.com/mherkazandjian/cce01cf3e15c0b41c1c4321245a99096/raw/03c86dae9a212446cf5b095643854f029b39c921/miniconda_installer.sh | bash -s -- ~/miniconda
Silent installation can be done like this, but it doesn't update the PATH variable so you can't run it after the installation with a short command like conda:
cd /tmp/
curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -u
Here -b means batch/silent mode, and -u means update the existing installation of Miniconda at that path, rather than failing.
You need to run additional commands to initialize PATH and other shell init scripts, e.g. for Bash:
source ~/miniconda3/bin/activate
conda init bash

How to run (./) a bash script located in the cloud?

Using a ubuntu 16.04 what I do is :
Download the .sh script using wget https://gist.githubusercontent.com/...
Turn the .sh file executable sudo chmod guo+x sysInit.sh
Execute the code through sudo ./sysInit.sh
I was wondering if it is possible to run the code directly from the web.
Would be something like: sudo ./ https://gist.githubusercontent.com/....
Is it possible to do that?
You can use cUrl to download and run your script. I don't think its installed by default on Ubuntu so you'll have to sudo apt-get install curl first if you want to use it. To download and run your script with sudo just run
curl -sL https://gist.githubusercontent.com/blah.sh | sudo sh
Be warned this is very risky and not advised for security reasons. See this related question why-using-curl-sudo-sh-is-not-advised
Yes, it is possible using curl and piping the result to sh.
Try the following command.
curl https://url-to-your-script-file/scriptFile.sh | sh
No, sudo only works from a command line prompt in a shell

git-crypt path on MacOSX

I have installed git-crypt (https://github.com/shadowhand/git-encrypt) on Windows and it's work fine.
But when i try on MacOSX (Mavericks), it's not successful.
From the guide this command on Linux:
$ sudo ln -s "$(pwd)/gitcrypt" /usr/local/bin/gitcrypt
But i can not make it work on MacOSX.
I also try this command without success:
sudo -s 'echo "/usr/local/bin/gitcrypt" > /etc/paths.d/$(pwd)/gitcrypt'
I have found solution. I post here for anyone find it:
$ clone https://github.com/shadowhand/git-encrypt /usr/local/git-encrypt
$ sudo vi /etc/paths
Add /usr/local/git-encrypt to the end save and quit terminal.

Resources