Monoista

Logo

View My GitHub Profile

Disabling Raspberry Pi Internall Bluetooth Adapter

edit /boot/config.txt

sudo nano /boot/config.txt

and add this at the bottom

# Disable internal Bluetooth adapter
dtoverlay=disable-bt

Screen

launch Screen

screen

attach to a running session

screen -x

list current sessions

screen -ls

attach to a running session

screen -r [session]

create new window

CTRL+a c

rename current window

CTRL+a A

show a lost of all windows for selection

CTRA+a "

switch to a window by number

CTR+a [0-9]

detach a running session

CTRL+a d

split current window vertically

CTRL+a S

split current window horizontally

CTRL+a |

switch to new window region

CTRL+a tab

remove current window region

CTRL+a X

exit screen

CTRL+a :

lock screen by a password

CTRL-a x

Securing Raspberry Pi

install Fail2Ban

sudo apt install fail2ban

change default settings

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

restart service

sudo service fail2ban restart

check status

sudo fail2ban-client status

or

sudo fail2ban-client status sshd

CouchDB and Raspberry Pi

install all necessary dependencies

sudo apt-get --no-install-recommends -y install \
     build-essential pkg-config erlang \
     libicu-dev libmozjs185-dev libcurl4-openssl-dev

download CouchDB source

wget https://www.apache.org/dyn/closer.lua?path=/couchdb/source/3.1.1/apache-couchdb-3.1.1.tar.gz

configure installation

./configure

build CouchDB

make release

create couchdb user and its home directory

sudo useradd -d /home/couchdb couchdb
sudo mkdir /home/couchdb
sudo chown couchdb:couchdb /home/couchdb

copy build into /home/couchdb directory

cd ./rel/couchdb/
sudo cp -Rp * /home/couchdb
sudo chown -R couchdb:couchdb /home/couchdb

update permission of ini files

sudo chmod 0644 /home/couchdb/etc/*

start CouchDB server

sudo -i -u couchdb /home/couchdb/bin/couchdb

edit local.ini for accessing CouchDB from other external IP address

sudo nano /home/couchdb/etc/local.ini

change line

#bind_address = 127.0.0.1

to

bind_address = 0.0.0.0

and restart CoachDB server

check that CouchDB is running

http://127.0.0.1:5984/_utils/index.html

running CouchDB on boot

sudo mkdir /var/log/couchdb/
sudo chown couchdb:couchdb /var/log/couchdb

go to http://127.0.0.1:5984/_utils/#/_config select + Add Options set log for Section, file for Name and /var/log/couchdb/couch.log for Value.

create the systemd service

sudo nano /lib/systemd/system/couchdb.service
[Unit]
Description=CouchDB Service
After=network.target
  
[Service]
Type=idle
User=couchdb
Restart=always
ExecStart=/home/couchdb/bin/couchdb
  
[Install]
WantedBy=default.target

set permissions

sudo chmod 644 /lib/systemd/system/couchdb.service
sudo systemctl daemon-reload
sudo systemctl enable couchdb.service

MQTT Client and Broker on Raspberry Pi

install Mosquitto Broker and Client

sudo apt install mosquitto mosquitto-clients

subscribe to a topic

mosquitto_sub -h localhost -t "mqtt/test"

publish to a topic

mosquitto_pub -h localhost -t "mqtt/test" -m "test"