Mosquitto link troubleshooting brew install mosquito


Returns:

Warning: mosquitto 1.6.8 is already installed, it's just not linked
You can use `brew link mosquitto` to link this version.


Link attempt:

Users-MacBook-Air:~ user$ brew link mosquitto
Linking /usr/local/Cellar/mosquitto/1.6.8... 
Error: Could not symlink sbin/mosquitto
/usr/local/sbin is not writable.
Users-MacBook-Air:~ user$ ls /usr/local/sbin
ls: /usr/local/sbin: No such file or directory
Users-MacBook-Air:~ user$ sudo brew link mosquitto
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
Users-MacBook-Air:~ user$ mkdir /usr/local/sbin
mkdir: /usr/local/sbin: Permission denied


The goal is to invoke mosquitto_sub.   What must be done to enable mosquito_sub?

Users-MacBook-Air:~ user$ brew upgrade mosquito
Warning: mosquitto 1.6.8 already installed
Users-MacBook-Air:~ user$ mosquitto_sub -h test.mosquitto.org -t "#" -v
-bash: mosquitto_sub: command not found


UPDATES \ RESPONSES

CREATE DIRECTORY: sudo mkdir /usr/local/sbin

Users-MacBook-Air:~ user$ mosquitto_sub -h test.mosquitto.org -t "#" -v
-bash: mosquitto_sub: command not found
Users-MacBook-Air:~ user$ sudo mkdir /usr/local/sbin
Password:
Users-MacBook-Air:~ user$ ls -l  /usr/local/ |  grep sbin
drwxr-xr-x    2 root  wheel     64 Dec 15 14:00 sbin
Users-MacBook-Air:~ user$ ls -l  /usr/local/sbin
Users-MacBook-Air:~ user$ chmod 777 /usr/local/sbin
chmod: Unable to change file mode on /usr/local/sbin: Operation not permitted
Users-MacBook-Air:~ user$ sudo chmod 777 /usr/local/sbin
Users-MacBook-Air:~ user$ ls -l  /usr/local/ |  grep sbin
drwxrwxrwx    2 root  wheel     64 Dec 15 14:00 sbin
Users-MacBook-Air:~ user$ brew link mosquitto
Linking /usr/local/Cellar/mosquitto/1.6.8... 30 symlinks created
Users-MacBook-Air:~ user$ mosquitto_sub -h test.mosquitto.org -t "#" -v
owntracks/busware/iPhone {"t":"t","tst":1576424485,"acc":65,"_type":"location","alt":17,"lon":10.67649557998085,"vac":10,"lat":54.04553

Users-MacBook-Air:~ user$ sudo chmod 755 /usr/local/sbin
Password:
Users-MacBook-Air:~ user$ ls -l  /usr/local/ |  grep sbin
drwxr-xr-x    3 root  wheel     96 Dec 15 14:02 sbin


PATH MODIFICATION TEST

Users-MacBook-Air:~ user$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Users-MacBook-Air:~ user$ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/Cellar/mosquitto/ 
Users-MacBook-Air:~ user$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/Cellar/mosquitto/
Users-MacBook-Air:~ user$ mosquitto_sub -h test.mosquitto.org -t "#" -v
-bash: mosquitto_sub: command not found
Run

sudo mkdir /usr/local/sbin
sudo chown $(whoami) /usr/local/sbin
brew link mosquitto