Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active May 11, 2022 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitfvb/998984b4e8b5c3d2e818b2b9b224b05d to your computer and use it in GitHub Desktop.
Save gitfvb/998984b4e8b5c3d2e818b2b9b224b05d to your computer and use it in GitHub Desktop.
Raspberry Pi (raspi) helpful commands

Deactivate WIFI

Check your current network status with

ifconfig

If your wifi has an ip address, it is still connected and active. Deactivate it temporarily with

sudo ifconfig wlan0 down

To permanently deactivate the wifi you can add a line to your crontab. Open it with

sudo crontab -e

If it is the first of crontab it asks for your favorite editor. I normally use nano, choice 1 in my case. Then add this line

@reboot ifconfig wlan0 down

Or if the deactivation should only be done 5 minutes after startup (then you can still connect without ethernet if you need to)

@reboot sleep 300 && ifconfig wlan0 down

This should look like this here

grafik

Save with CTRL+O and exit with CTRL+X.

Change ownership of file

E.g. create file with sqlite3 iobroker.sqlite and then transfer ownershop with

/opt/iobroker/iobroker-data/sqlite $ sudo chown iobroker:iobroker iobroker.sqlite

Create a postgres database

Like described here: https://pimylifeup.com/raspberry-pi-postgresql/

Install postgresql and create user

sudo apt update
sudo apt install postgresql
sudo su postgres
createuser pi -P --interactive

Answer this question with y

Shall the new role be a superuser? (y/n) y

Then start psql

psql

Create a database for the new user and find out the config for external connections

create database pi;
SHOW config_file

Allow external connection

Use that path in the following commands to edit it and scan for some more information

sudo nano /etc/postgresql/13/main/postgresql.conf

Now uncomment or change this line to allow connections from external hosts

listen_addresses = '*'

Now we need to allow the user external connections, so look for the pg_hba.conf file in your postgresql.conf

grep pg_hba.conf /etc/postgresql/13/main/postgresql.conf

Edit that file and add this line at the end. Read instructions in this file if you want other settings.

host    all        all             0.0.0.0/0               md5

View status of the database and restart it

sudo systemctl status postgresql
sudo systemctl restart postgresql

Connecting to the database

Then use a tool like sqlelectron to connect to that database

Resources

RAM

free -m

shows you something like

pi@rpi:~ $ free -m
               total        used        free      shared  buff/cache   available
Mem:             923         683         100          14         139         200
Swap:             99          98           1

The swap file is always pretty small and it can be increased. Good link to increase the swap on rasperry pi: https://pimylifeup.com/raspberry-pi-swap-file/

Shutdown/reboot

Reboot

sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment