Terminal – Fixing ‘spctl: command not found’ Error

bashterminal

I recently upgraded to MacOS Catalina, on a 13-in, 2019 MacBook Pro.

I am installing some software, and the OS was complaining that it is not from a verified provider, so I decided to bypass it using:

sudo spctl --master-disable

However, I only got:

-bash: spctl: command not found

Here is my ~/.bash_profile

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
export PATH=$LD_LIBRARY_PATH:$HOME/.local/bin/
export PATH=$PATH:/bin:/usr/bin
export PATH=$PATH:/usr/local/bin/
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Any ideas how to fix it? spctl is a default function, so I guess I deleted something.

Best Answer

$ type spctl
spctl is /usr/sbin/spctl

So make sure to add /usr/sbin (and /sbin) to your PATH.

Usually this is done automatically in /etc/profile which takes all the paths listed in /etc/paths. As has been pointed out in the comments, you override this by setting the PATH to LD_LIBRARY_PATH in line 2 of your .bash_profile. If you fix this, you won't need line 3 (nor probably line 4) any longer.