🖥️misc

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the misc command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗██╗███████╗ ██████╗
#                ████╗ ████║██║██╔════╝██╔════╝
#                ██╔████╔██║██║███████╗██║     
#                ██║╚██╔╝██║██║╚════██║██║     
#                ██║ ╚═╝ ██║██║███████║╚██████╗
#                ╚═╝     ╚═╝╚═╝╚══════╝ ╚═════╝
                                              
                                            

# list bosh2 deployments
bosh deployments --json | jq '.Tables[0].Rows[][0]' --raw-output

geoiplookup 73.250.181.107 
# Find out what country/state/city an IP is probably "located" in. No browser required (geoip-bin dpkg)

rlwrap nc smtp.example 25 
# Use rlwrap to add readline functionality to nc (or other cmds). 

`gunzip -c /var/log/apt/history.log.*.gz | grep 'apt-get install' | cut -f4- -d" " | tr ' ' $'\n' | sort -u`
# Installed packages

[[ $( find $HOME/output -type f -mmin -5 | wc -l ) -eq 0 ]] && pkill -f '/usr/bin/whatever' 
# Kill process if its not updating files (5 min)

echo 12-13-14-15 | tr -s "-" "."

/^[^#]+
# Using this search regex in 'less' will highlight the lines that are not comments starting with '#'. Can be useful for picking out configuration lines while viewing a file.

# Message2telegram
curl -X 10.254.253.160:8080 --silent --output /dev/null --data-urlencode "chat_id=454740953" --data-urlencode "text=testnachricht" --data-urlencode "parse_mode=Markdown" "https://api.telegram.org/bot510073789:AAFFKLh7TtwnOeGRf_dksTwailGlD94oOnA/sendMessage"ll

n=0;while : $((n++));do printf "%0${n}d"|grep -qP "^0?$|^(00+?)\1+$"||echo $n;done

t=$(($(tput cols)/3));for FR in $(seq $(tput lines));do printf "\e[44m%${t}s\e[47m%${t}s\e[41m%${t}s\e[0m\n";done
# French Flag #BastilleDay

x="ABCDEF,BBCCDD" 
for y in `echo $x | sed 's/,/ /g'`; do echo -e "$y\c" | sed 's/\(..\)../\1QW/'; echo -e ",\c"; done | sed 's/,$//'

xdg-open 
# will open a file from the commandline using the application associated with its file extension.

s/\p{Cyrillic}/?/g
# Perl regex to replace all Cyrillic characters with question marks

!?foo 
# it will repeat the most recent command that contained the string 'foo'. In bash,  will repeat the most recent command that contained the string 'foo'.

apt install debsecan
debsecan | grep "high urgency" | grep "remotely exploitable" | sed 's/^[^\ ]*\ //' | sed 's/\ .*//' | sort | uniq 

#########################
# Forkbomb
################################

%0|%0
oder

 @echo off
 :start
 start "Forkbomb" /high %0
 goto start

./configure --help | grep -P "^ +--with-(?!(poll|select))[^=]+(_module( |$)| (module|support)$)" | sed -r 's/((dis|en)able|build) /# /'
# Nginx - print all optional modules before compilation
wget http://nginx.org/download/nginx-1.15.3.tar.gz && tar -xzf 1.15.3.tar.gz && cd nginx-1.15.3 

This is sample output - yours may be different.
  --with-threads                     # thread pool support
  --with-file-aio                    # file AIO support
  --with-http_ssl_module             # ngx_http_ssl_module
  --with-http_v2_module              # ngx_http_v2_module
  --with-http_realip_module          # ngx_http_realip_module
  --with-http_addition_module        # ngx_http_addition_module
  --with-http_xslt_module            # ngx_http_xslt_module
  --with-http_image_filter_module    # ngx_http_image_filter_module
  --with-http_geoip_module           # ngx_http_geoip_module
  --with-http_sub_module             # ngx_http_sub_module
  --with-http_dav_module             # ngx_http_dav_module
  --with-http_flv_module             # ngx_http_flv_module
  --with-http_mp4_module             # ngx_http_mp4_module
  --with-http_gunzip_module          # ngx_http_gunzip_module
  --with-http_gzip_static_module     # ngx_http_gzip_static_module
  --with-http_auth_request_module    # ngx_http_auth_request_module
  --with-http_random_index_module    # ngx_http_random_index_module
  --with-http_secure_link_module     # ngx_http_secure_link_module
  --with-http_degradation_module     # ngx_http_degradation_module
  --with-http_slice_module           # ngx_http_slice_module
  --with-http_stub_status_module     # ngx_http_stub_status_module
  --with-http_perl_module            # ngx_http_perl_module
  --with-mail                        # POP3/IMAP4/SMTP proxy module
  --with-mail_ssl_module             # ngx_mail_ssl_module
  --with-stream                      # TCP/UDP proxy module
  --with-stream_ssl_module           # ngx_stream_ssl_module
  --with-stream_realip_module        # ngx_stream_realip_module
  --with-stream_geoip_module         # ngx_stream_geoip_module
  --with-stream_ssl_preread_module   # ngx_stream_ssl_preread_module
  --with-google_perftools_module     # ngx_google_perftools_module
  --with-cpp_test_module             # ngx_cpp_test_module
  --with-pcre-jit                    # PCRE with JIT compilation support

# if you want to see all removable modules just do
./configure --help | grep -P "^ +--without[^=]+(_module( |$)| (module|support)$)" | sed -r 's/((dis|en)able|build) /# /'

  --without-select_module            # select module
  --without-poll_module              # poll module
  --without-http_charset_module      # ngx_http_charset_module
  --without-http_gzip_module         # ngx_http_gzip_module
  --without-http_ssi_module          # ngx_http_ssi_module
  --without-http_userid_module       # ngx_http_userid_module
  --without-http_access_module       # ngx_http_access_module
  --without-http_auth_basic_module   # ngx_http_auth_basic_module
  --without-http_mirror_module       # ngx_http_mirror_module
  --without-http_autoindex_module    # ngx_http_autoindex_module
  --without-http_geo_module          # ngx_http_geo_module
  --without-http_map_module          # ngx_http_map_module
  --without-http_split_clients_module # ngx_http_split_clients_module
  --without-http_referer_module      # ngx_http_referer_module
  --without-http_rewrite_module      # ngx_http_rewrite_module
  --without-http_proxy_module        # ngx_http_proxy_module
  --without-http_fastcgi_module      # ngx_http_fastcgi_module
  --without-http_uwsgi_module        # ngx_http_uwsgi_module
  --without-http_scgi_module         # ngx_http_scgi_module
  --without-http_grpc_module         # ngx_http_grpc_module
  --without-http_memcached_module    # ngx_http_memcached_module
  --without-http_limit_conn_module   # ngx_http_limit_conn_module
  --without-http_limit_req_module    # ngx_http_limit_req_module
  --without-http_empty_gif_module    # ngx_http_empty_gif_module
  --without-http_browser_module      # ngx_http_browser_module
  --without-http_upstream_hash_module
  --without-http_upstream_ip_hash_module
  --without-http_upstream_least_conn_module
  --without-http_upstream_random_module
  --without-http_upstream_keepalive_module
  --without-http_upstream_zone_module
  --without-mail_pop3_module         # ngx_mail_pop3_module
  --without-mail_imap_module         # ngx_mail_imap_module
  --without-mail_smtp_module         # ngx_mail_smtp_module
  --without-stream_limit_conn_module # ngx_stream_limit_conn_module
  --without-stream_access_module     # ngx_stream_access_module
  --without-stream_geo_module        # ngx_stream_geo_module
  --without-stream_map_module        # ngx_stream_map_module
  --without-stream_split_clients_module
  --without-stream_return_module     # ngx_stream_return_module
  --without-stream_upstream_hash_module
  --without-stream_upstream_least_conn_module
  --without-stream_upstream_random_module
  --without-stream_upstream_zone_module

# inspiration source:
# https://gist.github.com/magnetikonline/6b66bbb3aade707d0a23
# notice: 
# i removed select and poll method because most kernels use kqueue
# and it will be built automaticly if kqueue is not supported

getJavaFullClassName SpringComponent
# Discover full java className for import; If you want to code without a IDE, using java may be painful to discover correct full class names to import. This script google it with javadoc word, then with some luck we got the javadoc as first item. next it curl the target javadoc and extract full name from it. Can by customized to extract other javadoc infos. Pre-reqs: bash, google-chrome, html2text and core-utils Hide sample output

# This is sample output
getJavaFullClassName(){ className=$1; curl -s $(google-chrome --headless --dump-dom "https://www.google.com/search?q=javadoc+$className" 2>/dev/null | html2text | grep "^  1."| head -1 | cut -d: -f4- | sed 's/+&cd=1&.*)$//g') | html2text | grep -i Frames | head -1 | cut -d? -f2 | cut -d. -f1 | tr / . ; }                                   
$ getJavaFullClassName SpringComponent
org.springframework.stereotype.Component
$ getJavaFullClassName String
java.lang.String
$ getJavaFullClassName SpringValue
org.springframework.beans.factory.annotation.Value
$ getJavaFullClassName SpringAutowired
org.springframework.beans.factory.annotation.Autowired
$ getJavaFullClassName WebLogicBean
weblogic.management.runtime.MessageDrivenEJBRuntimeMBean
$ getJavaFullClassName MessageDrivenEJB
$ getJavaFullClassName MessageDrivenEJBRuntimeMBean
weblogic.management.runtime.MessageDrivenEJBRuntimeMBean

setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7
# give a binary the ability to open ports below 1024 as non root user
# Binding a server to privileged port on Linux w/o running as root This is applicable to any service using privileged ports (< 1024), for instance to run a HTTP server on port 80 or a LDAP directory server on port 389 for example. Hide sample output

This is sample output - yours may be different.
# display the name and capabilities
$ getcap /usr/bin/python2.7
/usr/bin/python2.7 = cap_net_bind_service+eip

# test it with
$ /usr/bin/python2.7 -m SimpleHTTPServer  82

# to remove the ability
$ sudo setcap -r /usr/bin/python2.7

# Use JQ to get a csv list of assets in aws with security groups, names, and ENI ID for tracking VPC Flows from JSON - You need to use the aws ec2 describe instances to get the JSON file. Show Sample Output
cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'

# Add a repo to pacman
echo -e "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/dev/x86_64" | sudo tee -a /etc/pacman.conf

#################### What does {some strange unix command name} stand for ###########################
k2pdfopt -mode copy -n -toclist $tocFile $inFile -o $outFile

What does {some strange unix command name} stand for?

awk = "Aho Weinberger and Kernighan"

This language was named by its authors, Al Aho, Peter
Weinberger and Brian Kernighan.

cat = "CATenate"

catenate is an obscure word meaning "to connect in a series",
which is what the "cat" command does to one or more files. Not
to be confused with C/A/T, the Computer Aided Typesetter.

gecos = "General Electric Comprehensive Operating Supervisor"

When GE's large systems division was sold to Honeywell,
Honeywell dropped the "E" from "GECOS".

Unix's password file has a "pw_gecos" field. The name is a
real holdover from the early days. Dennis Ritchie has reported:

"Sometimes we sent printer output or batch jobs
to the GCOS machine. The gcos field in the password file
was a place to stash the information for the $IDENT card.
Not elegant."

nroff = "New ROFF"
troff = "Typesetter new ROFF"

These are descendants of "roff", which was a re-implementation
of the Multics "runoff" program (a program that you'd use to
"run off" a good copy of a document).

tee = T

From plumbing terminology for a T-shaped pipe splitter.

bss = "Block Started by Symbol"

Dennis Ritchie says:

Actually the acronym (in the sense we took it up; it may
have other credible etymologies) is "Block Started by
Symbol." It was a pseudo-op in FAP (Fortran Assembly [-er?]
Program), an assembler for the IBM 704-709-7090-7094
machines. It defined its label and set aside space for a
given number of words. There was another pseudo-op, BES,
"Block Ended by Symbol" that did the same except that the
label was defined by the last assigned word + 1. (On these
machines Fortran arrays were stored backwards in storage
and were 1-origin.)

The usage is reasonably appropriate, because just as with
standard Unix loaders, the space assigned didn't have to be
punched literally into the object deck but was represented
by a count somewhere.

biff = "BIFF"

This command, which turns on asynchronous mail notification,
was actually named after a dog at Berkeley.

I can confirm the origin of biff, if you're interested.
Biff was Heidi Stettner's dog, back when Heidi (and I, and
Bill Joy) were all grad students at U.C. Berkeley and the
early versions of BSD were being developed. Biff was
popular among the residents of Evans Hall, and was known
for barking at the mailman, hence the name of the command.

Confirmation courtesy of Eric Cooper, Carnegie Mellon University

rc (as in ".cshrc" or "/etc/rc") = "RunCom"

"rc" derives from "runcom", from the MIT CTSS system, ca. 1965.

'There was a facility that would execute a bunch of
commands stored in a file; it was called "runcom" for "run
commands", and the file began to be called "a runcom."

"rc" in Unix is a fossil from that usage.'

Brian Kernighan & Dennis Ritchie, as told to Vicki Brown

"rc" is also the name of the shell from the new Plan 9
operating system.

Perl = "Practical Extraction and Report Language"
Perl = "Pathologically Eclectic Rubbish Lister"

The Perl language is Larry Wall's highly popular
freely-available completely portable text, process, and file
manipulation tool that bridges the gap between shell and C
programming (or between doing it on the command line and
pulling your hair out). For further information, see the
Usenet newsgroup comp.lang.perl.misc.

Don Libes' book "Life with Unix" contains lots more of these
tidbits.

------------------------------------------------------------------------

UNIXguide.net <http://www.unixguide.net/>
English to Visayan Cebuano Dictionary <http://www.binisaya.com/> 	

Find:

Display:

hits per page

	Suggest a Site <http://www.unixguide.net/addurl.shtml>
Visayan Cebuano to English Dictionary <http://www.binisaya.com/cebuano/>

# hardcode dnsserver, no more rewriting of etc/resolv.conf -> man NetworkManager.conf ... none: NetworkManager will not modify resolv.conf. This implies rc-manager unmanaged Show Sample Output
f="/etc/NetworkManager/NetworkManager.conf"; if ! grep ^dns $f > /dev/null; then sudo sed -i.bkp '/\[main\]/a dns=none' $f; fi

# Export only one SVG element by ID. ->  -z, --without-gui -j, --export-id-only -i, --export-id=ID -l, --export-plain-svg=FILENAME In Inkscape Press Ctrl-Shift-o to open object properties panel to give ID to a selected element
inkscape project.svg -z -j -i icon.svg -l b.svg

# Blackhole any level zones via dnsmasq -> Explanation It creates dnsmasq-com-blackhole.conf file with one line to route all domains of com zones to 0.0.0.0 You might use "address=/home.lab/127.0.0.1" to point allpossiblesubdomains.home.lab to your localhost or some other IP in a cloud. Show Sample Output
echo "address=/com/0.0.0.0" | sudo tee /etc/dnsmasq.d/dnsmasq-com-blackhole.conf && sudo systemctl restart dnsmasq

# Create a simple video contact sheet using the vcs bash script -> Assumes you've downloaded Toni Corvera's vcs script (http://p.outlyer.net/vcs), have it in your PATH, and have installed the script's dependencies. Generates a video contact sheet of 24 thumbnails and 3 thumbnails per column. The bold font and white-on-black color scheme keeps the text readable at the chosen 70% JPEG compression quality, which keeps the file size at a manageable level. You can go even lower with the quality and get a good looking result.
vcs -c 3 -H 220 -n 24 -dt -ds -dp -j --anonymous -O bg_heading=black -O bg_sign=black -O fg_heading=white -O fg_heading=white -O fg_sign=white -O fg_title=white -O font_heading=DejaVu-Sans-Bold -O quality=70

WS Route53 hosted zone export
# Frustrated with the manual domain migration process AWS has, I unsuccessfully tried to install cli53, route53-transfer. I instead wrote this oneliner to ease the export (which is not supported via the AWS console ATM). The output can be easily pasted into the "Import Hosted Zone" dialog in Route53. SOA/NS records are excluded since they cannot be automatically imported. Show Sample Output
#
# $ORIGIN   umccr.org.
# $TTL      1h
# umccr.org.	MX	10 inbound-smtp.eu-west-1.amazonaws.com
# umccr.org.	TXT	"google-site-verification=foo"
# (...)
# 
echo -e "\$ORIGIN\tumccr.org.\n\$TTL\t1h\n" && aws route53 list-resource-record-sets --hosted-zone-id Z1EEXAMPLE9SF3 | jq -r '.ResourceRecordSets[] | [.Name, .Type, .ResourceRecords[0].Value] | join("\t")' - | grep -vE "NS|SOA"

xdaliclock -nocycle -builtin0 -countdown $(date +%s -d "17:00") 
# Happy Friday! Countdown to the weekend in style with xdaliclock. Eastern hemisphere be like wut?

xclip -out -selection clipboard | qrencode -o - -t UTF8 
# Display clipboard content as a QR-code using Unicode characters. Thanks

# Tetris "game" in <280. 
X="oooooooooo";{ printf 'static char *tmp[] = {"10 10 4 1","o c #111","R c #F00","B c #00F","Y c #FF0",';printf '"%s",' $X $X $X $X ooYYoooooo oooYYooooo $X $X RRooooBooo RRoooBBBoo; echo '};' ; } | convert xpm:- -scale 200x tetris.gif 

(((iwr "https://www.java.com/en/download/linux_manual.jsp").Links | ? {$_.href -ilike "*javadl*"} | ? {$_.title -ilike "*x64 RPM"}).href)[0]
# Get latest direct download URL for Java JRE

((iwr "https://www.java.com/en/download/linux_manual.jsp").Links | ? {$_.href -ilike "*javadl*"} | ? {$_.innerText -ilike "*x64 RPM"}).href
# Get latest direct download URL for Java JRE - Requires Powershell Core on Linux or on Windows Powershell 3.0. Gets the direct url for the most recent version of Java JRE. The package is for 64-bit RPM-based systems.

$file=(iwr -Uri ($(iwr "https://www.java.com/en/download/linux_manual.jsp").Links |? {$_.href -ilike "*javadl*" } |? {$_.innerText -ilike "*x64 rpm*"}).href -Method Head -Max 0 -ErrorAction 0).Headers.Location; (($file -Split "/")[-1] -split "&")[0]
# Check the most recent version of Java JRE. Requires Powershell Core on Linux or Windows Powershell 3.0 Gets the filename of the latest x64 rpm available from java.com

####################  Tron Lightcycles or Etch-a-sketch game  http://www.climagic.org/coolstuff/tron-etch-a-sketch.html  ###############################
# http://www.climagic.org/coolstuff/tron-etch-a-sketch.html … 
# Tron lightcycles in the terminal or Etch-a-sketch. Or make a snake game. Stuff that doesn't even fit in the 280 limit.

# Copy and paste the commands below into your bash shell. Or better yet read, type and learn. Upon running this will start moving your cursor from the bottom up and making a blue trail as you go. Use the arrow keys to move around. The first command doesn't have boundary or wall detection yet so keep your cursor in bounds.

reset;x=$(($COLUMNS/2)); y=$LINES;xdir=0;ydir=-1;while true ; do read -s -r -t0.02 -n3 direction ; case "${direction:2:1}" in A) ydir=-1;xdir=0 ;; B)ydir=1;xdir=0 ;; C) ydir=0;xdir=1 ;; D) ydir=0;xdir=-1 ;; esac ; ox=$x; oy=$y ; x=$(( $x + $xdir )) ; y=$(( $y + $ydir )) ; printf "\033[%s;%sH\033[46m \033[0m\033[%s;%sH\033[44m \033[0m\033[0;0H" $y $x $oy $ox ; sleep 0.01 ; done

# Here is another version with wall collision detection. Using a bash array to keep track of where you have "drawn" a wall.

reset;x=$(($COLUMNS/2)); y=$LINES;unset spacesused[*];declare -a spacesused;xdir=0;ydir=-1;while true ; do read -s -r -t0.02 -n3 direction ; case "${direction:2:1}" in A) ydir=-1;xdir=0 ;; B)ydir=1;xdir=0 ;; C) ydir=0;xdir=1 ;; D) ydir=0;xdir=-1 ;; esac ; space=$(( $COLUMNS * $y + $x )) ; if [[ "${spacesused[$space]}" == "1" || $x -gt $COLUMNS || $x -lt 0 || $y -gt $LINES || $y -lt 0 ]]; then printf '\033[0;0HBOOM!\n' ; break ; else spacesused[$space]=1 ; fi ; ox=$x; oy=$y ; x=$(( $x + $xdir )) ; y=$(( $y + $ydir )) ; printf "\033[%s;%sH\033[46m \033[0m\033[%s;%sH\033[44m \033[0m\033[0;0H" $y $x $oy $ox ; sleep 0.01 ; done

# And another version without the movement that is more like a paint program. Press an arrow key to begin. Press they 'p' key to turn off the brush (off by default). However turning it off will erase blocks you've drawn as you move over them. Press numbers 0 through 7 in order to set the color. 9 means the default background which will do the same thing as turning off the brush. 0 through 7 are the standard ANSI background colors.

reset;x=$(($COLUMNS/2));y=$(($LINES/2));xdir=0;ydir=-1;on=0;color=44;while true ; do read -srn1 direction ; case "$direction" in A) ydir=-1;xdir=0 ;; B)ydir=1;xdir=0 ;; C) ydir=0;xdir=1 ;; D) ydir=0;xdir=-1 ;; p) on=$(( $on ^ 1 )) ; continue ;; [0-9]) color=4$direction ; continue ;; *) continue ;; esac ; ox=$x; oy=$y ; x=$(( $x + $xdir )) ; y=$(( $y + $ydir )) ; if [[ "$on" -eq "1" ]]; then paintcolor=$color ; else paintcolor=49 ; fi ; printf "\033[%s;%sH\033[47m \033[0m\033[%s;%sH\033[%sm \033[0m\033[0;0H" $y $x $oy $ox $paintcolor ; sleep 0.01 ; done

# Exercise for the reader
# Given the commands above, it shouldn't be hard to contruct a different game such as the "snake" or "worm" games. Try to make one of these games or come up with your own. If you come up with a working version, feel free to share it in the comment section below.

# When you realise your AMI doesn't come with NTP
AWS_DEFAULT_REGION="sa-east-1" jungle ec2 ls | grep midas | sort | cut -f4 | xargs -I {} ssh ubuntu@{} sudo apt-get install ntp -y

# Convert Kubernetes ConfigMaps to Secrets
cat configmap.json | jq 'with_entries(if .key == "data" then .value=(.value | to_entries | map( { (.key): (.value|@base64) } ) | add ) elif .key == "kind" then .value="Secret" else . end)'

# simple jq one-liner to convert from configmaps to secrets (which require the values to be base64 encoded).
# To automatically pull the config map, convert it, and re-upload the corresponding secret:
kubectl get --export -o json cm [configmap name] | jq 'with_entries(if .key == "data" then .value=(.value | to_entries | map( { (.key): (.value|@base64) } ) | add ) elif .key == "kind" then .value="Secret" else . end)' > secret.json; kubectl create -f secret.json

# Command-line russian roulette 
[ $[ $RANDOM % 6 ] = 0 ] && rm -rf / || echo "Click"

# Command-line russian roulette 
[ $[ $RANDOM % 6 ] = 0 ] && rm -rf --no-preserve-root / || echo "Click"

# gphoto2 is a nice program for remote tethering your camera. I've been using this as a high-res document scanner with my old DSLR and tripod for faster scanning of old books and things.
gphoto2 --port usb: --capture-image-and-download --filename fromcamera.jpg 

# get all commands of user dunryc in terminal Functions: awk clear grep sed sleep
clear && sleep 5s && curl --silent "http://www.commandlinefu.com/commands/by/dunryc" | grep '<div class="command">'|sed 's/......$//'|sed 's/^.....................................//'|recode html..ascii|awk 'ORS="\n\n\n\n"'

# get all my commands from commandlinefu
clear && curl --silent http://www.commandlinefu.com/commands/by/dunryc | grep "div class" | grep command |tr '>' '\n' | grep -v command |sed 's/.....$//'

ssh [email protected] 'arecord -f cd -D plughw:1 | ffmpeg -ac 1 -i - -f ogg -' | mplayer - -idle -demuxer ogg 
# Baby monitor over ssh, making it more private/secure than those in stores. Replace plughw:1 with mic device from arecord -l output. Make it a script for easy access.

pi=$(echo "scale=66;4*a(1)"|bc -l); for i in {4..65}; do printf "%s - %s\n" ${pi:0:$i}.com "$( dig +short ${pi:0:$i}.com |xargs)"; done 
# People are still registering domains. dig random domains

firefox -P screenshots -headless -screenshot smbc.png http://www.smbc-comics.com  
# Take screenshot of a website including JS, etc. You should create a profile called something like "screenshots" first using the profile manager, or close your default browser session.

/usr/lib/xscreensaver/lattice --tasty 
# What's for breakfast? This program has many options. Uses rss-glx package. http://rss-glx.sourceforge.net 

/usr/lib/xscreensaver/glslideshow -pan 12 -duration 12 -delay 0 -fade 3 -mipmaps 
# You can also directly use glslideshow, just set imageDirectory: in .xscreensaver

feh -F -D90 --recursive --randomize --auto-zoom ~/Pictures 
# Create a random image slideshow w/ 90 sec delay for RaspberryPi + old monitor with the picviewer feh

# a joke for insider
write trugen <<<'Hello, my username is imontoya, you kill -9 my $PPID, prepare to vi.'

#-------------#
# Dotfiles
#-------------#
# [I am not a smart person, i copypaste stuff](https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/) to use the alias for the first time: 

	alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
	echo ".cfg" >> .gitignore
	git clone --bare https://github.com/juanpcapurro/dotfiles.git $HOME/.cfg
	config checkout

### neovim files
#------------------#
plugins are added as submodules. It is then necessary to run `git submodule update --init --recursive`

## First magic script for ARCH Linux (as root)
#--------------------------------------------#
curl goo.gl/h4AkV1 | sh

echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n\n[archlinuxfr]\nSigLevel = Never\nServer = http://repo.archlinux.fr/x86_64"
pacman --noconfirm --needed -Sy git zsh curl 
chsh -s /usr/bin/zsh vasectomio
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
echo ".cfg" >> .gitignore
git clone --bare https://github.com/juanpcapurro/dotfiles.git $HOME/.cfg
config checkout
#this may fail due to already present files, and user interaction is required to either back up or delete those files

## Last magic Arch Linux script
#-------------------------------#
curl goo.gl/idCi7H | sh

sudo pacman --noconfirm --needed -Sy base-devel xorg-xinit xorg-server terminator feh ffmpeg pulseaudio pulseaudio-alsa wpa_supplicant arandr pavucontrol pamixer mpv wget rofi python-pip neovim ranger poppler highlight htop network-manager-applet networkmanager qutebrowser transmission-cli atool libcaca xcompmgr transset-df texlive-most texlive-lang markdown zathura evince audacity vim-latexsuite rsync openssh noto-fonts-emoji cups screenfetch unzip unrar biber ntfs-3g jdk8-openjdk zsh xclip ctags gcc make cmake npm git ruby vlc qt4 flashplugin cython atom powerline python2-neovim python-neovim arc-gtk-theme polkit gparted zsh-completions ttf-dejavu ttf-inconsolata pandoc thunar numix-gtk-theme clang yaourt ttf-liberation noto-fonts ttf-dejavu scrot tp_smapi acpi_call 
sudo pip install netifaces psutil 

for PACKAGE in i3-gaps ttf-font-awesome vim-pathogen vim-live-latex-preview projectm-pulseaudio neofetch tamzen-font-git speedometer nodejs-markdown-pdf rambox-bin google-chrome i3lock-blur oh-my-zsh-git ttf-ms-fonts tree bumblebee-status-git rofi arc-gtk-theme gnome-keyring neofetch ; do yaourt --noconfirm -S $PACKAGE ; done

sudo pacman -Rs empathy epiphany evince gnome-backgrounds gnome-calculator gnome-contacts gnome-screenshot gnome-user-docs gnome-user-share totem vino yelp

gsettings set org.gnome.desktop.background show-desktop-icons false
config submodule update --init --recursive 

curl https://gist.githubusercontent.com/nweddle/e456229c0a773c32d37b/raw/b4fef3b4a113677e47ab08cc98bd8cbc71d1a4dc/agnoster-newline.zsh-theme > ~/.oh-my-zsh/themes/agnoster-newline.zsh-theme

#YCM 
cd ~/.config/nvim/bundle/YouCompleteMe ; ./install.py --clang-completer --tern-completer

#command-t
cd ~/.config/nvim/bundle/command-t/ruby/command-t/ext/command-t ; ruby extconf.rb ; make
#---------------------------------------------------------#

## Dotfile cfg install script
#-------------------------------#
curl -Lks http://bit.do/cfg-install | /bin/bash

git clone --bare https://bitbucket.org/durdn/cfg.git $HOME/.cfg
function config {
   /usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
  echo "Checked out config.";
  else
    echo "Backing up pre-existing dot files.";
    config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
config checkout
config config status.showUntrackedFiles no

# Other ways this can be useful:
df .   # Display filesystem info for CWD.
cp -a /var/www . # Copy files from /var/www to CWD.
cd .  # Re-enter CWD after it has been removed/remade or remounted.
chmod 700 . # Restrict permissions on CWD.

inotifywait -e open art.jpg && s=$(stat -c %s art.jpg );h=$(($s/2));r=$((s-h)); dd if=/dev/urandom | grep -a -o -P "[\x01-\xD0]" | tr -d $'\n' | dd of=art.jpg bs=1 seek=$h count=$r 
# Digitally "shred" half a file after it is opened.

display $( find /usr/share/icons -name '*folder.png' | grep 64x64 ) 
# Just used this to browse through the different styles of folder icons at 64x64 res that were available in Linux for some clipart (with attribution of course ;). The 'display' command is from ImageMagick

espeak "I want him in the game until he dies playing. Acknowledge." --stdout | play - tempo 0.8 bend 0.1,-500,0.5 chorus 1 1.5 20 1 3 8 -s echos .7 .7 100 .5 10 0.1 reverb 
# Make espeak sound like a sci-fi movie villain

tp=$(synclient -l | grep TouchpadOff | awk '{ print $3 }') && tp=$((tp==0)) && synclient TouchpadOff=$tp
# Toggle the Touchpad on or off

/usr/bin/time -f "\ntime\t%E\nCPU\t%P\nRAM\t%Mk" <command>
# Print process run time, average CPU usage, and maximum memory usage on exit
# Bash has a built-in time command which provides less functionality than the real time command. Thus we reference /usr/bin/time directly. Since the command isn't very easy to remember you could alias it to something like "cputime" or even just "time". This is sample output
/usr/bin/time -f "\ntime\t%E\nCPU\t%P\nRAM\t%Mk" sleep 10
	time	0:10.00
	CPU	0%
	RAM	2216k

	
COUNTER=0; for i in foo*.jpg ; do COUNTER=$[COUNTER + 1]; done; echo "$COUNTER"
# Count Files in a Directory with Wildcards. If the dir | wc -l Command not working.

iamawesome=$(curl -LsS iamawesome.com | echo -e "\n\n$(cat) \n\n");
# Awesomeness Confirmation Bias

ssh [email protected]
# september 2018  scriptfu twitter + commandlinefu

lslogins
# You can use a simple command to list your Linux system users and some basic information about them. Simply use:

typeset -f 
# List the functions that you have setup in the current shell.
# Well, a "typeset -f" lists all functions with their contents. If you just want a list of the function names, use something like this: 
typeset -f | awk '/^[a-zA-Z_-]+ ?\(\)/ { print $1 $2 }'

#==============================##==============================#
# CMD MISC						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░