vim ~/.bash_aliases
1 2 | alias kp="pgrep python | xargs sudo kill" alias tp="top -b -n1 | grep python" |
vim ~/.bash_aliases
1 2 | alias kp="pgrep python | xargs sudo kill" alias tp="top -b -n1 | grep python" |
1 2 3 4 5 6 7 8 9 10 11 12 13 | [Unit] Description=Copy user wpa_supplicant.conf ConditionPathExists=/boot/wpa_supplicant.conf Before=dhcpcd.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/mv /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf ExecStartPost=/bin/chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf [Install] WantedBy=multi-user.target |
Über serielles Terminal (USB-Kabel) auf pi einloggen. Falls WLAN Hotspot bereits existiert, dann mit dem PC sich damit verbinden und ein SSH Terminal Sitzung zum WLAN 192.168.8.1 verbinden. Dann die folgendes eingeben:
1 2 | Sudo touch /usr/share/network-conf/ap/iptables.up.rules sudo turn-wifi-into-apmode yes |
SSID und Passwort eingeben:
default: SSID=sensor-xx PASSWORD=123456789
# Wifi Hotspot am PC einrichten
# Über serielles Terminal auf pi einloggen, dann
1 2 | sudo nmcli dev wifi sudo nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0 |
# die Einstellungen werden gespeichert und auch nach Neustart wird Verbindung aufgebaut.
1 | sudo nmcli dev
|
#if the status of a device is "unmanaged" it means that device cannot be accessed by NetworkManager. To make it accessed you need to clear the settings under "/etc/network/interfaces" and reboot your system.
1 2 3 | sudo nmcli r wifi on sudo nmcli dev wifi sudo nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0 |
Just include your .ini file into bash body:
File example.ini:
1 2 3 | DBNAME=test DBUSER=scott DBPASSWORD=tiger |
File example.sh
1 2 3 4 5 | #!/bin/bash #Including .ini file . example.ini #Test echo "${DBNAME} ${DBUSER} ${DBPASSWORD}" |
[ Source: https://stackoverflow.com/questions/6318809/how-do-i-grab-an-ini-value-within-a-shell-script ]
At times you create a script and then you want to have the scripts controlled by systemd or in some cases you wish to have the scripts getting restarted by itself when it is killed due to some reason. In such cases systemd in Linux helps to configure services which can be managed. To do so follow the following steps.
1 | cd /etc/systemd/system
|
1 2 3 4 5 6 7 8 9 10 11 | [Unit] Description=<description about this service> [Service] User=<user e.g. root> WorkingDirectory=<directory_of_script e.g. /root> ExecStart=<script which needs to be executed> Restart=always [Install] WantedBy=multi-user.target |
1 | sudo systemctl daemon-reload
|
1 | sudo systemctl start your-service.service
|
1 | sudo systemctl status your-service.service
|
1 | sudo systemctl enable your-service.service
|
1 | sudo systemctl disable your-service.service
|
[ Source: https://www.shubhamdipt.com/blog/how-to-create-a-systemd-service-in-linux/]
1 2 3 4 5 6 7 8 9 10 11 12 13 | ~/src/pi-gen $ cat $(find stage[012] -type f -name '*package*') | tr " " "\n" | grep 'pi' | sort libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 pi-bluetooth python-rpi.gpio raspberrypi-bootloader raspberrypi-net-mods raspberrypi-sys-mods raspi-config raspi-copies-and-fills rpi-update |
1 2 3 4 5 6 7 8 9 10 11 12 13 | [Unit] Description=Copy user wpa_supplicant.conf ConditionPathExists=/boot/wpa_supplicant.conf Before=dhcpcd.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/mv /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf ExecStartPost=/bin/chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 10 11 | [Unit] Description=Turn on SSH if /boot/ssh is present ConditionPathExistsGlob=/boot/ssh{,.txt} After=regenerate_ssh_host_keys.service [Service] Type=oneshot ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /boot/ssh ; rm -f /boot/ssh.txt" [Install] WantedBy=multi-user.target |
Um Dateien in einer Datei.wim zu ändern, und zwar nicht im 1. Index sondern 2. öffnet man Powershell (ich habs jetzt im admin Modus gestart...