My personal cheatsheet for using the Linux command line.
Install netdata from https://learn.netdata.cloud/docs/agent/packaging/installer
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
"apply code from netdata.cloud to add device"Install Raspbian Lite (headless) place file wpa_supplicant.conf in boot directory
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here e.g. CH, US>
network={
ssid="<Name of your wireless LAN>"
psk="<Password for your wireless LAN>"
}
place empty file named ssh to enable ssh
sudo hostname -b
sudo nano /etc/hostname
sudo nano /etc/hosts
sudo hostnameMake sure the file under /etc/hostname includes the new hostname.
Make all updates
sudo apt-get install build-essential debhelper librtlsdr-dev pkg-config dh-systemd libncurses5-dev libbladerf-dev git screen
git clone https://github.com/flightaware/dump1090.git
cd dump1090
sudo dpkg-buildpackage -bcd dump1090
screen -S dump1090
ps aux | grep dump
kill pid
./dump1090 --mlat --forward-mlat --net --net-ro-port 30002 --net-bo-port 30005 --fix --modeac --gain -10 --quiet &
CTRL + A then D to leave screen
screen -r => to reattachAlternatively for cli output:
./dump1090 --mlat --forward-mlat --net --net-ro-port 30002 --net-bo-port 30005 --fix --modeac --gain -10 --interactive --interactive-ttl 60dump1090-1.15 (deb)
./dump1090 --mlat --forward-mlat --net --net-ro-port 30002 --net-bo-port 30005 --fix --modeac --gain -10 --enable-agc --interactive --interactive-ttl 60 --stats
sudo bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/adsb-scripts/master/readsb-install.sh)"run as root
apt install build-essential debhelper tcl8.6-dev autoconf python3-dev python3-venv dh-systemd libz-dev
git clone https://github.com/flightaware/piaware_builder.git
./sensible-build.sh bionic
cd package-bionic/
dpkg-buildpackage -uc -us -b
cd ../
./apt install piaware_*.debhttps://discussions.flightaware.com/t/how-piaware-feeders-are-identified-updated-2017-07-16/19811/60
Login
mysql -u [username] -p [pw]Count the average number of id's in a table (decimal output)
SELECT COUNT(*) * 1.0 / COUNT(DISTINCT DATE([Column])) FROM [Table];Select all records in a table where the value is smaller than X
SELECT * FROM [Table] WHERE [Column] < XSelect a Databse
USE [Database];Show all tables in a Database
SHOW TABLES;Import .sql.zip file
unzip -p dbdump.sql.zip | mysql -u root -p [yourdbname]Show commands
SHOW DATABASES
SHOW TABLES
SHOW OPEN TABLES
SHOW COLUMNS
SHOW KEYS
SHOW VARIABLES
SHOW STATUS
SHOW TABLE STATUS
SHOW PROCEDURE STATUS
SHOW FUNCTION STATUS
SHOW CHARACTER SET
SHOW COLLATIONDirectory
/usr/share/phpmyadmin
Fix count() issue
sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php
Upgrade
cd /usr/share/
sudo mv phpmyadmin phpmyadmin_old_version
wget "newest version"
sudo rm -rf phpMyAdmin-4.8.3-all-languages
tar -xvf phpMyAdmin*
sudo mv phpMyAdmin-4.8.3-all-languages phpmyadmin
cd phpmyadmin_old_version
sudo cp config.inc.php ../phpmyadmin/config.inc.php
sudo cp -r themes ../phpmyadmin/
cd ..
cd phpmyadmin
sudo mkdir tmp
sudo chmod 777 /usr/share/phpmyadmin/tmp
Restart MariaDB on DSM
/usr/syno/bin/synopkg restart MariaDB./mysql location
/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin
my.cnf dir
/var/packages/MariaDB10/etc/my.cnf
Configure GIT
git config --global user.email "user.name@email.ch"
git config --global user.name "Name Surname"Commit to master
git init
git add README.md
git commit -m "initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin mastergit pull
git status
git branch
git branch dingsbums
git checkout dingsbums
git git add -A
git commit
git push
(git push --set-upstream origin dingsbums)
To add a new Samba user, you first have to create a new Unix user.
sudo usera --shell /bin/false USER # new unix user
sudo passwd USER # set password
sudo smbpasswd -a USER # create samba usersudo smartctl -A /dev/sda -d megaraid,1 | grep -i temperatureEnable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linuxyoutube-dl -x —audio-format mp3 -f bestaudio -l https://www.youtube.com/playlist?list=scp your_username@remotehost.edu:foobar.txt /local/direcho "ping" >/dev/udp/$host/$port.tar.bz2
tar -jxvf file.tar.bz2.tar.xz
tar xvfJ file.tar.xz.tar.gz
tar -zxvf file.tar.gz.gz
gunzip file.gzZip something
zip foo.zip fooZip recursively
zip -r file.zip directory/Configure GIT
git config --global user.email "user.name@email.ch"
git config --global user.name "Name Surname"Commit to master
git init
git add README.md
git commit -m "initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin masterTo add a new Samba user, you first have to create a new Unix user.
sudo usera --shell /bin/false USER # new unix user
sudo passwd USER # set password
sudo smbpasswd -a USER # create samba userlsblk -l #find the usb drive
umount /dev/sdX
bs=4MB if=file.iso of=/dev/sdXCheck for how long your SSL certificate remains valid.
openssl x509 -noout -dates -in /etc/letsencrypt/live/yourdomain.tld/cert.pemNixcraft: How To Compile And Run a C/C++ Code In Linux
Compile a C++ file
g++ CODE.cpp -o BINARY.exeCompile a C file
gcc CODE.c -o BINARY.exeRecursively download
wget -r -np -nH —cut-dirs=2 -R index.html http://maven.jzy3d.org/releases/org/jzy3d/Size of a directory
du -sh DIR/Recursively copy all files of type
find DIR -iname \*.TXT -exec cp {} DESTINATION \;Random Filename argument
echo `ls dir | sort -R | tail -n 1`sudo dpkg -i pack.debnohup command > /dev/null 2>&1set all file and dir permissions in subdirectories to:
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;SSH tunnel
-D [Bind Port]
-p [Remote Port]
ssh -CnN -D 9999 -p 22 user@server.ch # forwards local port 9999 via ssl tunnelSSH tunnel settings for PuTTY
Connection > SSH > Tunnels :
Source Port: port
☒ Dynamic
☒ Auto
[Add]
Session :
Host Name: server
Port: port
Saved Sessions: name
[Save]
[Load]
cat /dev/urandom | xxd -p -c 92 | lolcat
figlet -c Happy Birthday | lolcat
toilet -f mono12 -F metal Hello
espeak "Hello"
sldd if=/dev/zero of=/dev/block/bootdevice/by-name/misc bs=256 count=1 conv=notrunc #Heading 1 ##Heading 2 ###Heading 3 ####Heading 4 #####Heading 5 ######Heading 6
Paragraph
text Inline Code text
Mistaken text.
Italics
Bold
Tasks
- a task list item
- list syntax required
- normal formatting
- incomplete
- completed
Code Blocks
4 space indention
makes full-width
standard code blocks
var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;
document.write(today);#sc_drag_area {
height:100px;
left:150px;
position: absolute;
top:100px;
width:250px;
z-index: 9999;
}- List item one
- List item two
- A nested item
- Number list item one 1.1. A nested item
- Number list item two
- Number list item three
Quote
Second line Quote
Standard link = http://ghost.org Custom Text Link
Table
| Left-Aligned | Center Aligned | Right Aligned |
|---|---|---|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |