Linux crib sheet

 


This is my command crib sheet for the various things I run on my Raspberry Pi. I look stuff up I’ve forgotten (most of it) and then generally copy/paste stuff from here to avoid errors introduced by my sausage fingers. Despite 40+ years in IT my typing skills are still abysmal and I never used Unix professionally.

This is essentially just my own cribsheet so explanations are very limited – sometimes I can’t even remember what all the voodoo means myself and have to use google again.

Links

Useful Commands

Links
Log
Monitoring
Permissions
Shutdown and restart
Update and Config
WiFi

Applications

DynDNS Updater
Flight Radar 24 feed
Lighttpd webserver
RuneAudio
Samba server
TightVNC
USB Sound
WeeWX
WsprryPi

External links

Use of Find
Various Linux articles
USB sound


Creating links

sudo ln -s /usr/share/phpmyadmin /var/www/    (I needed this on my Pi 2 to get PHPMyAdmin to work)

sudo ln -s /home/pi/monitoring /var/www/      (allows me to keep y monitor code in Pi's home directory)

Log

tail -f /var/log/syslog

Monitoring

top (shows cpu use etc.)
ps -aef (shows processes)
sudo kill (kill a process)
jobs (shows disconnected processes)
fg (to reconnect to disconnected processes)
lsusb (shows usb devices)
sudo usermod -aG sudo  add a user to sudo group

Permissions stuff

It is useful to change the permissions on the www directory to allow your user to update the webpages without needing to be root.
Change the directory owner and group

sudo chown www-data:www-data /var/www
allow the group to write to the directory
sudo chmod 775 /var/www
Add the pi user to the www-data group
sudo usermod -a -G www-data pi

Shutdown + Restart

sudo halt
sudo reboot

Update and Config

sudo apt-get update
sudo apt-get upgrade

sudo raspi-config

WiFi

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

network={
ssid="Your SSID"
psk="Your_wifi_password"
}

sudo iwlist wlan0 scan




DynDNS updater

apt-get install ddclient

nano /etc/ddclient.conf
And adjust setting to something like:
daemon 600
pid=/var/run/ddclient.pid
ssl=yes
protocol=dyndns2
use=web, web=checkip.dyndns.com, web-skip='IP Address'
server=members.dyndns.org
login=accountname
password='accountpassword'
yourdomain.dyndns.org

/etc/init.d/ddclient restart

Flight Radar 24 feed

sudo service fr24feed start

tail -f /var/log/fr24feed.log

Lighttpd webserver

sudo /etc/init.d/lighttpd restart
sudo apt-get install php5-curl

/etc/php5/cgi/php.ini
upload_max_filesize, memory_limit and post_max_size 

Samba Server

sudo nano /etc/samba/smb.conf
sudo service samba restart

sudo nano /etc/modprobe.d/alsa-base.conf
# options snd-usb-audio index=-2 (comment out to allow USB device to be default sound)

amixer

alsamixer

TightVNC

vncserver :0 -geometry 1920x1080 -depth 24 -dpi 96

vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565
vncpasswd

vncserver -kill :0 

/etc/init.d/vncboot {start|stop}

sudo nano /etc/init.d/vncboot 

WeeWX

This bit was just to set up automatic starting

sudo cp util/init.d/weewx.debian /etc/init.d/weewx
sudo chmod +x /etc/init.d/weewx
sudo update-rc.d weewx defaults 98
sudo /etc/init.d/weewx start
sudo /etc/init.d/weewx stop

WsprryPi

To get the code login and do this:

git clone -b feature/lpf https://github.com/griffc/WsprryPi.git

this will create a folder called WsprryPi

cd WsprryPi
make

To see the options do:

sudo ./wspr --help

Help output…

Usage:
wspr [options] callsign locator tx_pwr_dBm f1 ...
OR
wspr [options] --test-tone f

Options:
-h --help
Print out this help screen.
-p --ppm ppm
Known PPM correction to 19.2MHz RPi nominal crystal frequency.
-s --self-calibration
Call ntp_adjtime() before every transmission to obtain the PPM error of the crystal.
-r --repeat
Repeatedly, and in order, transmit on all the specified command line freqs.
-x --terminate
Terminate after n transmissions have been completed.
-o --offset
Add a random frequency offset to each transmission:
+/- 80 Hz for WSPR
+/- 8 Hz for WSPR-15
-t --test-tone freq
Simply output a test tone and the specified frequency. Only used
for debugging and to verify calibration.
-n --no-delay
Transmit immediately, do not wait for a WSPR TX window. Used
for testing only.
-l --lpf
LPF switching. 0 for off, 1 - 5 for band relay. eg -l124 for relay 1, 2 and 4

Frequencies can be specified either as an absolute TX carrier frequency, or
using one of the following strings. If a string is used, the transmission
will happen in the middle of the WSPR region of the selected band.
LF LF-15 MF MF-15 160m 160m-15 80m 60m 40m 30m 20m 17m 15m 12m 10m 6m 4m 2m
-15 indicates the WSPR-15 region of band .

Transmission gaps can be created by specifying a TX frequency of 0

This is what My son runs and what I’ll eventually be running…

nohup sudo ./wspr -s -o -r -l123450 M0XDK IO92 10 80m 40m 30m 20m 12m 0 > wspr.log &

nohup sudo ./wspr -s -o -r G6KIZ IO92 10 80m 40m 30m 20m 12m 0 > wspr.log &

To run via cron php script every 10 minutes

*/10 * * * * /usr/lib/cgi-bin/php /var/www/run_wspr.php (location of php and script may vary)

RuneAudio

WinSCP handy for file transfers
Login – root rune

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
network={
ssid=”Azkaban”
psk=”********”
key_mgmt=WPA-PSK
}

network={
ssid=”Hogwarts”
psk=”********”
key_mgmt=WPA-PSK
}
update_config=1

Radio URLs
http://media-ice.musicradio.com/ClassicFMMP3
http://live.radiogoldfm.ro:8002

Playlists
/var/lib/mpd/playlists