Difference between revisions of "Linux CLI commands I Cannot Remember..."

From wiki.N4VX.net
Jump to navigation Jump to search
 
(40 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
inxi -Fx - System information<br>
 
inxi -Fx - System information<br>
 
weather - cli weather info<br>
 
weather - cli weather info<br>
 +
another weather - <code>curl wttr.in/AVL</code><br>
 +
price of $BTC - <code>curl rate.sx/BTC</code> or add a time span <code>curl rate.sx/BTC@30d</code>
 +
 
===CLI Commands with some useful syntax===
 
===CLI Commands with some useful syntax===
* list the fingerprint of key <code>ssh-keygen -lf ~/.ssh/id_rsa.pub </code><br>
+
* list the fingerprint of key  
<br>
+
ssh-keygen -lf ~/.ssh/id_rsa.pub
 
*parse fail2ban logs
 
*parse fail2ban logs
 
#<code>cat /var/log/fail2ban.log | grep Ban | awk '{print $6,$7,$1,$2}' | uniq </code><br>
 
#<code>cat /var/log/fail2ban.log | grep Ban | awk '{print $6,$7,$1,$2}' | uniq </code><br>
 
#<code>sudo cat fail2ban.log | grep Ban | awk '{print $8}' | sort | uniq -c </code><br>
 
#<code>sudo cat fail2ban.log | grep Ban | awk '{print $8}' | sort | uniq -c </code><br>
 
#<code>sudo cat /var/log/fail2ban.log | grep Ban | awk '{print $8,$7}' | sort | uniq -c </code><br>
 
#<code>sudo cat /var/log/fail2ban.log | grep Ban | awk '{print $8,$7}' | sort | uniq -c </code><br>
 +
* useless waste of time and peta-flops
 +
cat /dev/urandom | hd | grep "ca fe"
 +
*Scrape 1FC data from RadioReference
 +
** parse RadioReference.com 1FC data from website and save CCs to list
 +
wget -O 1fc.html http://www.radioreference.com/apps/db/?sid=7118 && cat 1fc.html | sed 's/[a-zA-Z<>="\/: #-]/ /g' | grep "[7,8][5,6,7][0-9].[0-9][0-9][0-9][0-9][0-9]c" | awk '{ print $6 }' > 1fc.cc 
 +
**or the new version
 +
wget -O 1fc.html http://www.radioreference.com/apps/db/?sid=7118 && cat 1fc.html | grep '[7,8][0-9][0-9].[0-9]\+c' | sed 's/[><]/ /g' | awk '{print $6}' | sort -un > 1fc.cc && wc -l 1fc.cc >> 1fc.cc && cat 1fc.cc | sed 's/1fc.cc/Control Channels/g' > 1fc.txt && cat 1fc.txt
  
 +
** parse the 1fc.html data for ALL freqs in use
 +
cat 1fc.html | grep "[7,8][0-9][0-9].[0-9][0-9][0-9][0-9][0-9]" | sed 's/[a-zA-Z<>="\/: #-]//g' > 1fc.all<br>
 +
* read the "p" text in a news webpage
 +
cat index.html | grep '<nowiki><p></nowiki>' | sed 's/<[^<>]*>//g' | sed 's/[^>]*>//g' | sed 's/<[^<]*//g' | sed 's/MORE//g' | festival --tts<br>
 +
* working outbound mail CLI
 +
cat /var/log/apache2/error.log | mail -s "Apache Error Logs" mail@domain.tld<br>
 +
* open udp ports for chromecast <code>iptables -I INPUT -p udp -m udp --dport 32768:61000 -j ACCEPT</code><br>
 +
* working RTL-SDR ADS-B webserver <code>$PATH/dump1090 --raw --net --net-http-port 8008 & mono $PATH/VirtualRadar.exe</code><br>
 +
* modify file timestamp <code>touch -t YYYYMMDDHHMM filename.ext</code><br>
 +
* rename images by their EXIF timestamp <code><nowiki>exiv2 -r'%Y%m%d_%H%M%S' -F *.JPG</nowiki></code> and <code><nowiki>exiv2 -r'%Y%m%d_%H%M%S_COMMENT_STUFF' -F *.JPG</nowiki></code><br>
 +
* EAS decoder <code>multimon-ng -a EAS -t wav $FILE</code><br />
 +
* rtl-fm play audio localy broadcast FM <code>rtl_fm -g 50 -f 99.9M -M wfm -s 180k -E deemp | play -r 180k -t raw -e s -b 16 -c 1 -V1 - lowpass 16k</code><br />
 +
* lock screen rotation in Ubuntu 18.04 on HP ProBook 6560b <code><nowiki>gsettings set org.gnome.settings-daemon.plugins.orientation active false</nowiki></code><br />
 +
* imagemagick perspective with tiling <code>convert flag.jpg -virtual-pixel tile -distort Perspective '0,0 30,55 2121,0 917,35 0,1414 55,1111 2121,1414 820,707' flagA.jpg</code><br />
 +
* imagemagick add watermark/overlay with opacity <code>convert flagA.jpg -resize 1024x1024 miff:- | composite -dissolve 37% -gravity center overlay.png - overlayflag.png</code><br />
 +
* convert .mov to .mp4 with ffmpeg - <code>ffmpeg -i my-video.mov -vcodec h264 -acodec mp2 my-video.mp4 </code><br />
 +
* reload .bashrc <code>. ~/.bashrc</code><br />
 +
<br>
 +
* Convert vertically shot video (I secretly hate you) to proper 16x9 format with "echo pillarboxing" effect on the sides. Ok, it's not a secret. I hate you for vertical video.
 +
ffmpeg -i input.mp4 -vf 'split[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,gblur=sigma=20[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2' output.mp4 <br />
 +
* Turn a multi-page pdf into a single page pdf
 +
pdftk full-pdf.pdf cat 1 output outfile_page1.pdf
  
* useless waste of time and peta-flops <code>cat /dev/urandom | hd | grep "ca fe"</code>
+
===More than commands...===
 
+
====Add swap space in Ubuntu 18.04LTS====
* parse RadioReference.com 1FC data from website and save CCs to list <br>
+
** [[Add swap space in Ubuntu 18.04LTS | Directions Here]]
<code> wget -O 1fc.html http://www.radioreference.com/apps/db/?sid=7118 && cat 1fc.html | sed 's/[a-zA-Z<>="\/: #-]/ /g' | grep "[7,8][5,6,7][0-9].[0-9][0-9][0-9][0-9][0-9]c" | awk '{ print $6 }' > 1fc.cc </code>
+
**from - [https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/ https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/]
 
+
<br>
* parse the 1fc.html data for ALL freqs in use <br>
+
====Scan and check USB drives====
<code>cat 1fc.html | grep "[7,8][0-9][0-9].[0-9][0-9][0-9][0-9][0-9]" | sed 's/[a-zA-Z<>="\/: #-]//g' > 1fc.all</code><br>
+
** [[Scan and check USB drives | Directions Here]]
 
+
**from - [https://www.debugpoint.com/2020/07/scan-repair-bad-sector-disk-linux/ https://www.debugpoint.com/2020/07/scan-repair-bad-sector-disk-linux/]
* read the <p> text in a (news) webpage *<br>
+
<br>
<code>cat index.html | grep '<p>' | sed 's/<[^<>]*>//g' | sed 's/[^>]*>//g' | sed 's/<[^<]*//g' | sed 's/MORE//g' | festival --tts</code><br>
+
*[[TOR and Regular DNS in Ubuntu | Resolve TOR .onion and regular DNS]]
 
+
<br>
* working outbound mail CLI <br>
+
====Bypass CGNAT(NAT444) with Wireguard and a VPS====
<code>cat /var/log/apache2/error.log | mail -s "Apache Error Logs" kf4nvx@gmail.com</code><br>
+
** [[Bypass CG-NAT(NAT444) with Wireguard and a VPS | Directions Here]]
 
+
** lifted from [https://hacdias.com/2020/11/30/access-network-behind-cgnat https://hacdias.com/2020/11/30/access-network-behind-cgnat]
/* open udp ports for chromecast */
+
<br />
iptables -I INPUT -p udp -m udp --dport 32768:61000 -j ACCEPT
+
====Batch transcode .wma to .mp3====
 
+
**[[wma2mp3.sh | wma2mp3.sh]]
/* working RTL-SDR ADS-B webserver */
+
** lifted from [https://askubuntu.com/questions/55352/convert-library-of-wma-tracks-to-mp3s https://askubuntu.com/questions/55352/convert-library-of-wma-tracks-to-mp3s]
$PATH/dump1090 --raw --net --net-http-port 8008 & mono $PATH/VirtualRadar.exe
+
<br />
 
+
====Add Alby support to Azuracast Public Page====
/* modify file timestamp */
+
docker exec -t $YOUR_AZURACAST_CONTAINER /bin/bash
touch -t YYYYMMDDHHMM filename.ext
+
nano /var/azuracast/www/templates/frontend/public/index.phtml
 
+
add the line below in the appropriate place with all the other <meta blah blah> tags
/* rename images by their EXIF timestamp */
+
<meta name="lightning" content="lnurlp:$YOUR_ALBY_NAME@getalby.com" />
exiv2 -r'%Y%m%d_%H%M%S' -F *.JPG
+
Boom!!
 
+
====Update Umbrel from CLI====
/* EAS decoder */
+
sudo ./PATHTOUMBREL/scripts/update --repo getumbrel/umbrel
multimon-ng -a EAS -t wav $FILE
+
====Mosquitto MQTT Broker with Docker Compose====
 
+
[[Mosquitto MQTT Broker with Docker Compose | Directions Here]]
/* rtl-fm play audio localy broadcast FM */
+
* credit to [https://techoverflow.net/2021/11/25/how-to-setup-standalone-mosquitto-mqtt-broker-using-docker-compose/ https://techoverflow.net/2021/11/25/how-to-setup-standalone-mosquitto-mqtt-broker-using-docker-compose/]
rtl_fm -g 50 -f 99.9M -M wfm -s 180k -E deemp | play -r 180k -t raw -e s -b 16 -c 1 -V1 - lowpass 16k
+
====Add font to ubuntu====
 +
Many fonts are packaged for Ubuntu and available via the "Fonts" category of the Ubuntu Software Center. If you prefer apt-get, search for packages starting with otf- or ttf-.
 +
Font files that are placed in the hidden .fonts directory of your home folder will automatically be available (but /etc/fonts/fonts.conf indicates it will be removed soon.). You can also place them in the <code>~/.local/share/fonts</code> directory on newer versions of Ubuntu per the comments below.
 +
You can also double-click on the font file (or select Open with Font Viewer in the right-click menu). Then click the Install Font button.
 +
If you need the fonts to be available system-wide, you'll need to copy them to <code>/usr/local/share/fonts</code> and reboot (or manually rebuild the font cache with <code>fc-cache -f -v</code>).
 +
You can confirm they are installed correctly by running <code>fc-list | grep "<name-of-font>"</code>
 +
You may need to restart some programs, like OpenOffice Writer, before they actually show the new fonts (usually such programs are caching the font list when they start up).
 +
Edit: Changed advice to manually install into <code>/usr/local/share/fonts</code> instead of <code>/usr/share/fonts</code> to reflect comments and best practice.

Latest revision as of 20:05, 31 December 2023

Random CLI Commands

htop - graphical process monitor
iptraf - graphical IP traffic monitor
meshmap - HSMM mesh map generator
figlet - make ASCII letters
chirpw - radio programming
camgrab - CLI webcam pic grabber
pwgen - password generator
links2 - ncurses web browser
inxi -Fx - System information
weather - cli weather info
another weather - curl wttr.in/AVL
price of $BTC - curl rate.sx/BTC or add a time span curl rate.sx/BTC@30d

CLI Commands with some useful syntax

  • list the fingerprint of key
ssh-keygen -lf ~/.ssh/id_rsa.pub
  • parse fail2ban logs
  1. cat /var/log/fail2ban.log | grep Ban | awk '{print $6,$7,$1,$2}' | uniq
  2. sudo cat fail2ban.log | grep Ban | awk '{print $8}' | sort | uniq -c
  3. sudo cat /var/log/fail2ban.log | grep Ban | awk '{print $8,$7}' | sort | uniq -c
  • useless waste of time and peta-flops
cat /dev/urandom | hd | grep "ca fe"
  • Scrape 1FC data from RadioReference
    • parse RadioReference.com 1FC data from website and save CCs to list
wget -O 1fc.html http://www.radioreference.com/apps/db/?sid=7118 && cat 1fc.html | sed 's/[a-zA-Z<>="\/: #-]/ /g' | grep "[7,8][5,6,7][0-9].[0-9][0-9][0-9][0-9][0-9]c" | awk '{ print $6 }' > 1fc.cc  
    • or the new version
wget -O 1fc.html http://www.radioreference.com/apps/db/?sid=7118 && cat 1fc.html | grep '[7,8][0-9][0-9].[0-9]\+c' | sed 's/[><]/ /g' | awk '{print $6}' | sort -un > 1fc.cc && wc -l 1fc.cc >> 1fc.cc && cat 1fc.cc | sed 's/1fc.cc/Control Channels/g' > 1fc.txt && cat 1fc.txt
    • parse the 1fc.html data for ALL freqs in use
cat 1fc.html | grep "[7,8][0-9][0-9].[0-9][0-9][0-9][0-9][0-9]" | sed 's/[a-zA-Z<>="\/: #-]//g' > 1fc.all
  • read the "p" text in a news webpage
cat index.html | grep '<p>' | sed 's/<[^<>]*>//g' | sed 's/[^>]*>//g' | sed 's/<[^<]*//g' | sed 's/MORE//g' | festival --tts
  • working outbound mail CLI
cat /var/log/apache2/error.log | mail -s "Apache Error Logs" mail@domain.tld
  • open udp ports for chromecast iptables -I INPUT -p udp -m udp --dport 32768:61000 -j ACCEPT
  • working RTL-SDR ADS-B webserver $PATH/dump1090 --raw --net --net-http-port 8008 & mono $PATH/VirtualRadar.exe
  • modify file timestamp touch -t YYYYMMDDHHMM filename.ext
  • rename images by their EXIF timestamp exiv2 -r'%Y%m%d_%H%M%S' -F *.JPG and exiv2 -r'%Y%m%d_%H%M%S_COMMENT_STUFF' -F *.JPG
  • EAS decoder multimon-ng -a EAS -t wav $FILE
  • rtl-fm play audio localy broadcast FM rtl_fm -g 50 -f 99.9M -M wfm -s 180k -E deemp | play -r 180k -t raw -e s -b 16 -c 1 -V1 - lowpass 16k
  • lock screen rotation in Ubuntu 18.04 on HP ProBook 6560b gsettings set org.gnome.settings-daemon.plugins.orientation active false
  • imagemagick perspective with tiling convert flag.jpg -virtual-pixel tile -distort Perspective '0,0 30,55 2121,0 917,35 0,1414 55,1111 2121,1414 820,707' flagA.jpg
  • imagemagick add watermark/overlay with opacity convert flagA.jpg -resize 1024x1024 miff:- | composite -dissolve 37% -gravity center overlay.png - overlayflag.png
  • convert .mov to .mp4 with ffmpeg - ffmpeg -i my-video.mov -vcodec h264 -acodec mp2 my-video.mp4
  • reload .bashrc . ~/.bashrc


  • Convert vertically shot video (I secretly hate you) to proper 16x9 format with "echo pillarboxing" effect on the sides. Ok, it's not a secret. I hate you for vertical video.
ffmpeg -i input.mp4 -vf 'split[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,gblur=sigma=20[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2' output.mp4 
  • Turn a multi-page pdf into a single page pdf
pdftk full-pdf.pdf cat 1 output outfile_page1.pdf

More than commands...

Add swap space in Ubuntu 18.04LTS


Scan and check USB drives



Bypass CGNAT(NAT444) with Wireguard and a VPS


Batch transcode .wma to .mp3


Add Alby support to Azuracast Public Page

docker exec -t $YOUR_AZURACAST_CONTAINER /bin/bash
nano /var/azuracast/www/templates/frontend/public/index.phtml

add the line below in the appropriate place with all the other <meta blah blah> tags

<meta name="lightning" content="lnurlp:$YOUR_ALBY_NAME@getalby.com" />

Boom!!

Update Umbrel from CLI

sudo ./PATHTOUMBREL/scripts/update --repo getumbrel/umbrel

Mosquitto MQTT Broker with Docker Compose

Directions Here

Add font to ubuntu

Many fonts are packaged for Ubuntu and available via the "Fonts" category of the Ubuntu Software Center. If you prefer apt-get, search for packages starting with otf- or ttf-. Font files that are placed in the hidden .fonts directory of your home folder will automatically be available (but /etc/fonts/fonts.conf indicates it will be removed soon.). You can also place them in the ~/.local/share/fonts directory on newer versions of Ubuntu per the comments below. You can also double-click on the font file (or select Open with Font Viewer in the right-click menu). Then click the Install Font button. If you need the fonts to be available system-wide, you'll need to copy them to /usr/local/share/fonts and reboot (or manually rebuild the font cache with fc-cache -f -v). You can confirm they are installed correctly by running fc-list | grep "<name-of-font>" You may need to restart some programs, like OpenOffice Writer, before they actually show the new fonts (usually such programs are caching the font list when they start up). Edit: Changed advice to manually install into /usr/local/share/fonts instead of /usr/share/fonts to reflect comments and best practice.