#Android VOLUME_DOWN adb shell input keyevent KEYCODE_VOLUME_DOWN #Extract one file from a remote tar.gz and put it where you want it tar --strip-components=1 -C ~/bin/ -xzf <( curl -L https://dist.ipfs.tech/kubo/v0.36.0/kubo_v0.36.0_linux-amd64.tar.gz ) kubo/ipfs #List memory percentage per user ps aux | awk '{arr[$1]+=$4}; END {for (i in arr) {print i,arr[i]}}' | sort -hk2 | tail -10 #Display history of reboots journalctl --list-boots # display tabular history of reboots #Tapping screen for TikTok using shell script while true; do input tap $(wm size | awk -F 'x' '{print $1/2 " " $2/2}'); done #Mount SMB v1 share on Linux mount -t cifs -o username=administrator,password=xxx,vers=1.0,sec=ntlmv2 //192.168.0.30/nas_share /mnt/win_share #Download and Extract mp3 from Youtube Video yt-dlp --extract-audio --audio-format mp3 --audio-quality 0 -o "%(title)s.%(ext)s" #Get a random quote from Breaking Bad curl -s https://api.breakingbadquotes.xyz/v1/quotes | jq -r '.[] | "\"\(.quote)\" -- \(.author)"' #Matrix - Just 1 wobbly line rather then a rain! (shorter) while true; do printf "\e[32m%*s\e[0m" $(tput cols) $(shuf -e {0..1} -n $(tput cols)); sleep 0.1; done #Matrix - Just 1 wobbly line rather then a rain! clear; sleep 5; echo 'while :; do printf "\e[32m%*s\e[0m" $(tput cols) $(shuf -e {0..1} -n $(($(tput lines) * $(tput cols)))); sleep 0.1; done' #This command will help you to hunt the current mysql query statement in real time. (-R is deprecated, using updated -Y) tshark -s 512 -i eno1 -n -f'tcp dst port 3306' -Y'' -T fields -e #Read /etc/passwd with printf in a smarter and shorter way then some deliberately obfuscated shell commands from unethicals. eval "$(E3LFbgu='CAT /ETC/PASSWD';printf %s "${E3LFbgu~~}")" #Portscan entire internet (ipv4) (masscan 0.0.0.0/0 -p80 --banner --exclude 255.255.255.255 --max-rate 100000|tee internet_ips_to_block_ranges.txt 2>&1 /dev/null); 1&> /dev/null #In emergency situations, in order not to panic, shut down the following port on the network with the following rather then shutting down the PC. fuser -k 445/tcp #Generate a correct mac addr. od -An -N6 -tx1 /dev/urandom |sed -e 's/^ *//' -e 's/ */:/g' -e 's/:$//' -e 's/^\(.\)[13579bdf]/\10/' #Launch hidden commands /bin/bash -c "exec ls" #Do we use: 'Wayland' OR 'x11' (systemd version) loginctl show-session $XDG_SESSION_ID -p Type #Do we use: 'Wayland' OR 'x11' printf 'Session is: %s\n' "${DISPLAY:+X11}${WAYLAND_DISPLAY:+WAYLAND}" #View emerge log by date in humand friendly time awk -F: '{print strftime("%Y-%m-%d -> %X --> ", $1),$2}' /var/log/emerge.log #Find the right intel-ucode firmware for Intel GPU iucode_tool -S -l /lib/firmware/intel-ucode/* #Disable Show More Options on Windows 11 reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve #Generate a QR code in the terminal printf 'https://www.gentoo.org/' | curl -F-=\<- qrenco.de #Shuffle a reversed string without new lines (Simple way to create a progress bar) while true; do slumpad_eversed=$(echo "$eversed_part" | grep -o . | shuf | tr -d '\n'); tput cr && tput el && echo -n "$r_part$slumpad_eversed" ; sleep 1 ; done #Shuffle two letters randomly while true; do shuffled_letter1=$(printf "%s\n" "${letters[@]}" | shuf -n 1); shuffled_letter2=$(printf "%s\n" "${letters[@]}" | shuf -n 1); printf "%s%s\r" "$shuffled_letter1" "$shuffled_letter2"; sleep 0.1; done #Record a certain command output script -c "ls -la" logfile.log #Test a crontab work on 5th line. eval "$(crontab -l | sed -n '5p' | tr -s ' ' | cut -d' ' -f 6-)" #Dump all available man pages in a particular section find $(man --path | tr ':' ' ') -type f -path '*man2*' -exec basename {} \; | sed 's/\..*//' | sort #Input redirection. The < character tells the shell to read the contents of the file specified. ANSI-C Quoting X=$'uname\x20-a'&&$X #List /usr dirs when "ascii" chars is not available and only digits. ls ${PATH:0:5} #In an emergency to secure all user accounts, use the following command to lock out all users rather than shutting down the computer to help security engineers passwd -l $(awk -F: '{ print $1 }' /etc/passwd | grep -v "nologin") #Emptying Every File Recursively find / -type f -exec sh -c '> {}' \; #Corrupting Filesystem Metadata debugfs -w /dev/sdX1 -R "set_inode_field /root mode 0000" #Deleting all users from the "sudo" group gpasswd -d $(getent group sudo | cut -d: -f4 | tr "," "\n") sudo #Generate a GIF image from video file ffmpeg -ss 30 -t 3 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif #Find all the hidden dot files find ./path_to_dir -type f -name '.*' #Create a highly compressed encrypted 7zip file from a directory 7z a -t7z -mhe=on -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on some_directory.7z some_directory/ #Disk usage skipping mount points (even top-level ones) for a in /*; do mountpoint -q -- "$a" || du -shx "$a"; done | sort -h #Generate random port number shuf -i 1024-65535 -n 1 #Assign top-level JSON entries to shell variables json='{"a":42, "b":"s t r i n g", "c": []}' ; eval $(echo $json | jq -r 'to_entries | .[] | select(.value | scalars) | .key + "=\"" + (.value | tostring) + "\";"' | tee /dev/tty) #MacOS: Make the terminal app always quit when alias exit="killall Terminal" #Get the beats per minute from an audio track ffmpeg -loglevel quiet -i "$AUDIO_FILE" -f f32le -ac 1 -ar 44100 - | bpm #Download Video & extract only a specific Time of it yt-dlp --external-downloader ffmpeg --external-downloader-args "-ss 00:05:00 -t 00:01:00" "https://www.youtube.com/watch?v=Y6DGABIcB3w" #Show temp of all disk grep -l "drivetemp" /sys/class/hwmon/hwmon*/name | while read f; do printf "%s(%-.2s°C)\n" "`<${f%/*}/device/model`" "`<${f%/*}/temp1_input`"; done #Linux clear restrictions of a user's password chage -E -1 -m 0 -M -1 -W -1 user01 #Monitor changed files into a log file, with day rotation, using fswatch (MacOS) fswatch --exclude=.git/* --exclude=.settings --event-flags --event-flag-separator=\; -t -f '%Y-%m-%d %H:%M:%S' . >> ./.file_changes_$(date +"%Y-%m-%d" | sed s/-//g).log #Compute newest kernel version from Makefile on Torvalds' git repository curl -s -o - https://raw.githubusercontent.com/torvalds/linux/master/Makefile | head -n5 | grep -E '\ \=\ [0-9]{1,}' | cut -d' ' -f3 | tr '\n' '.' | sed -e "s/\.$//" #Sudoers: bypass all password prompts echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers #Prepend section dates to individual entries in a summary log file gawk 'match($0, /^\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4})\s*/, m) {prev_date=m[1]} /SEARCHSTRING/ {print prev_date, ",", $1 $2, ",", $3, "," $5}' inputfile.txt #Print macOS current power delivery max wattage system_profiler SPPowerDataType | grep Wattage #Create a visually twisted effect by alternating the direction of the "staples" effect vertically. The effect is achieved by moving odd-numbered lines from right to left and even-numbered lines from left to right. while :; do for ((i=0;i<$(tput cols);i++));do clear;for ((j=0;j<$(tput lines);j++));do printf "\e[48;5;$((RANDOM%256))m%*s\e[0m\n" $(((j+i)%2?$(tput cols)-i:i)) "";done;sleep 0.05;done;done #Fill the screen with randomly colored lines while :; do printf "\e[48;2;$((RANDOM % 256));$((RANDOM % 256));$((RANDOM % 256))m%*s\e[0m" $(tput cols) ""; sleep 0.1; done #Scan LAN and get Windows host names nmap -sn --system-dns 192.168.0.1-253 #Check if a domain is available for purchase function canibuy { whois "$1" 2>/dev/null | grep -q 'Registrant' && echo "taken" || echo "available" } #This command provides more color variety for the rainbow-like appearance by generating random color codes from 16 to 231 for adb logcat. adb logcat|awk '{ i srand();for (i = 1; i <= NF; i++) { color = int(rand() * 216) + 16; printf "\033[38;5;%dm%s\033[0m ", color, $i;} printf "\n"; }' #Disassemble all ACPI tables on your system for i in /sys/firmware/acpi/tables/*; do sudo iasl -p $PWD/$(echo $i | cut -d\/ -f6) $i && sudo chown $USER $(echo $i | cut -d\/ -f6); done #Polkit: Force KDE apps to always recognize your display alias pkexec=“pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true” #Loops over files, runs a command, dumps output to a file for f in *php; do echo $f >> ~/temp/errors.txt; phpcsw $f | grep GET >> ~/temp/errors.txt; done #Download Video & extract only a specific Time of it fmpeg $(yt-dlp -g 'https://de.pornhub.com/view_video.php?viewkey=ph637366806d6eb' | sed 's/^/-ss 00:05 -i /') -t 01:00 -c copy out.mp4 #urldecode with AWK awk -niord '{printf RT?$0chr("0x"substr(RT,2)):$0}' RS=%.. #Create a square thumbnail or favicon using ImageMagick convert file.png -background transparent -gravity Center -extent 1:1# -scale 32 file-32px.png #List all files in a folder in a git repository by last commit date git ls-tree --name-only HEAD foldername/ | while read filename; do echo "$(git log -1 --format="%ci " -- $filename) $filename"; done | sort -r #A Console-based Audio Visualizer for ALSA cava #Speak & Spell-esque glitch sounds play -tlpc /dev/urandom #Bypass with hexencoding, dump /etc/passwd cat $(echo -e "\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64") #List all files and folders with attributes gci -rec | Select-Object Mode, Name, CreationTime, LastAccessTime, LastWriteTime | ft -autosize #Copy a file with progress and save hash to a different file pv file.txt | tee >(sha1sum > file.sha1) > file-copy.txt #AWS s3api CLI can be used to filter objects in a S3 bucket based on the Last Modified Date using the --query filter. aws s3api list-objects-v2 --bucket my-bucket --query 'Contents[?LastModified>`2022-01-01`].Key' #Unzip 25 zip files files at once find . -maxdepth 1 -name '*.zip' -print0 | xargs -0 -I {} -P 25 unzip {} #Convert an image sequence into a video ffmpeg -framerate 30 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p out.mp4 #MySQL: Filter out specific tables from an existing mysqldump file with awk cat db_dump.sql | awk '/DROP TABLE IF EXISTS/ { skip = $5 ~ /table1|table2/ } !skip { print $0 }' > db_dump_filtered.sql #How To Display Bash History Without Line Numbers history -w /dev/stdout #merge multiple jpgs to one picture vertikal convert picture-1.jpg picture-2.jpg picture-3.jpg -append Output_merged_picture.jpg #Start monitoring your server with a single curl command. curl ping.gl #Show a zoomable world map telnet mapscii.me #List all packages in Ubuntu/Debian that no package depends on dpkg-query --show --showformat='${Package}\t${Status}\n' | tac | awk '/installed$/ {print $1}' | xargs apt-cache rdepends --installed | tac | awk '{ if (/^ /) ++deps; else if (!/:$/) { if (!deps) print; deps = 0 } }' #Print nic name of current connection nmcli -g name,type connection show --active|awk -F: '/ethernet|wireless/ { print $1 }' #Simple tar tar -cvzf file.tar.gz path #rclone - dump teamdrive config to config file rclone backend -o your-config.conf drives mydrive: #url redirect tracer with curl curl --silent -I -L shorturl.at/dfIJQ | grep -i location #QEMU From Fedora Livecd + Device CD + Device Disk + UEFI + 800x600 forced Entire command: sudo qemu-system-x86_64 -enable-kvm -cpu host -M q35 -m 2G -smp 4 --bios /usr/share/edk2/ovmf/OVMF_CODE.fd -drive id=cdrom,file=/dev/sr1,if=none,media=cdrom,format=raw,readonly=on -drive id=disk,file=/dev/md126,if=none,format=raw -device virtio-blk-pci,drive=cdrom -device virtio-blk-pci,drive=disk -device VGA,vgamem_mb=64,xres=800,yres=600 sudo qemu-system-x86_64 ... #Extend LVM and online resize filesystem lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv && resize2fs /dev/ubuntu-vg/ubuntu-lv #Clean or clean pacman and pamac cache sudo pacman -Scc && pamac clean -b #Sort disk usage from directories du --max-depth=1 -h . | sort -h #Truncate long strings in columns and use custom header names column -s: -t -n . -N USERNAME,PASS,UID,GID,NAME,HOMEDIR,SHELL -T NAME /etc/passwd|sed "1,2 i $(printf %80s|tr ' ' '=')" #How to sum lines with decimals in awk awk '{a+=$0}END{print a}' file #Output requirements.txt packages pinned to latest version pip install -r requirements.txt --dry-run --no-deps --ignore-installed | tail -n1 | tr ' ' '\n' | tail -n+3 | sed -e "s/\(.*\)-/\1==/" #Find non ascii characters in files in folder find . -type f -regex '.*\.\(cpp\|h\)' -exec grep -Pl "[\x80-\xFF]" {} \; | xargs -I % bash -c 'echo "%"; grep --color='auto' -P -n "[\x80-\xFF]" "%"' #Convert indentation to tabs find . -type f -regex '.*\.\(cpp\|h\)' -exec bash -c 'unexpand -t 4 --first-only "$0" | sponge "$0"' {} \; #Change Windows line endings to Unix version find . -type f -regex '.*\.\(cpp\|h\)' -exec egrep -l $'\r'\$ {} \; | xargs dos2unix #Track flight information from the command line flight_status() { curl --silent --stderr - "https://mobile.flightview.com/TrackByRoute.aspx?view=detail&al=$1&fn=$2&dpdat=$(date +%Y%m%d)" | html2text | grep -A19 "Status" ; } ; flight_status $1 $2 #Check out Gate number for your flight from CLI with Chrome google-chrome-stable --headless --dump-dom --disable-gpu "https://avinor.no/flight/?flightLegId=dy754-osl-trd-20220726&airport=OSL" 2>/dev/null | html2text | grep -A2 Gate #Quickly run any gif as a ASCII animation in a terminal window gif-for-cli /path/to/gif_file.gif #Query cheat.sh from the termianl. A quick access cheat sheet for a range of linux commands! curl cheat.sh/ #Cross compile C# code on Linux for windows machines mono-csc hello.cs -out:world.exe #Run a command after the process you choose finishes tail --pid="$(ps -A -o pid,args | fzf | awk '{print $1}')" -f /dev/null && echo DONE #Clone starred github repos in parallel with unlimited speed, this example will clone 25 repositories in parallel at same time. GITUSER=$(whoami); curl "https://api.github.com/users/${GITUSER}/starred?per_page=1000" | grep -o 'git@[^"]*' | parallel -j 25 'git clone {}' #Backup all starred repositories from Github GITUSER=$(whoami); curl "https://api.github.com/users/${GITUSER}/starred?per_page=1000" | grep -o 'git@[^"]*' | xargs -L1 git clone #Make Kali Linux look less suspicious by making the desktop look more like a windows machine kali-undercover #Spawn a retro style terminal emulator. cool-retro-term #Write a bootable Linux .iso file directly to a USB-stick (macOS edition) sudo curl -L -o /dev/disk4 https://some-distributor.org/some-distro.iso #Download audio from youtube video yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.%(ext)s' #Lower PowerShell priority PS> Get-WmiObject Win32_process -filter 'name = "powershell.exe"' | Foreach-Object { $_.SetPriority(16384) } #remove junk grep -v '^# In' viz.txt | cat -s > out.txt #Run 10 curl commands in parallel via xargs (v2, faster then v1) xargs -I% -P10 curl -sL "https://iconfig.co" < <(printf '%s\n' {1..10}) #Run 10 curl commands in parallel via xargs NUM="10";seq ${NUM}|time xargs -I % -n1 -P${NUM} curl -sL ifconfig.co #generate playlists from youtube ( or othre things that support yt-dlp) Show Sample Output yt-dlp -N3 -O '#EXTINF:%(duration_string)s tvg-id="" tvg-logo="%(thumbnail)s" group-title="Music | %(channel)s (%(extractor)s)",%(title)s' -O webpage_url --playlist-end 10 https://www.youtube.com/channel/UC2eTX3jDug-6fUt89uWaPCQ #Print with tabular head -4 /etc/passwd | tr : , | sed -e 's/^/| /' -e 's/,/,| /g' -e 's/$/,|/' | column -t -s, #Bash command to convert IP addresses into their "reverse" form echo "32.6.6.102" | awk -F. '{print $4"."$3"." $2"."$1}' #Get an embedded Rust development environment set up without prompting curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- --default-toolchain nightly --component rust-analyzer-preview --component llvm-tools-preview --component rust-src --component rustc-dev -y #Have a smile printf "$(awk 'BEGIN{c=127;while(c++<191){printf("\xf0\x9f\x98\\%s",sprintf("%o",c));}}')" #Add temporary <1m entries to old cron for i in $( seq 0 5 55 ); do (crontab -l ; echo "* * * * * sleep $i; date >> ~/log.txt") | crontab -; done #ASCII art of yourself mplayer tv:// -vo caca #Print sensors data for your hardware paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/' #Print interface that is up and running ip addr | awk '/state UP/ {print $2}' | sed 's/.$//' #HOME USE ONLY: Get rid of annoying Polkit password prompts sudo find /usr/share/polkit-1 -iname “*.policy” -exec sed -i “s/\(auth_admin\|auth_admin_keep\)/yes/g” {} \; #Quickly add a new user to all groups the default user is in awk -F: '/^.+user1/{print $1}' /etc/group | xargs -n1 sudo adduser user2 #Convert records in columns to csv awk '{print $3,$2,$1}' RS="\n\n" FS="\n" OFS="," filename.txt #Show tcp connections sorted by Host / Most connections netstat -ntu|awk '{print $5}'|cut -d: -f1 -s|sort|uniq -c|sort -nk1 -r #Infinite loop ssh h=root@localhost ; while ! ssh -o ConnectTimeout=5 $h true; do sleep 5; done; ssh $h #Display disk partition sizes lsblk -o name,size #Developer: Add an IDT map design reference to your source tree cp /proc/interrupts irq-ref.txt #Recursive dwdiff using find -exec find DIR -exec sh -c "if [ -f \"{}\" ]; then echo {} >> dwdiff.txt; dwdiff --no-common {} /OLD_FILES/{} >> dwdiff.txt; echo \"--EOF--\" >> dwdiff.txt; fi" \; #Shows picture exif GPS info if any and converts coords to a decimal degree number identify -verbose my_image.jpg | awk 'function cf(i){split(i,a,"/");if(length(a)==2){return a[1]/a[2]}else{return a[1]}}/GPS/{if($1~/GPSLatitude:|GPSLongitude:/){s=$0;gsub(/,/,"",$0);printf("%s (%f)\n", s, $2+cf($3)/60+cf($4)/3600)}else{print}}' #Enlarge KiCad PCB footprint pads to 2mm for all smaller pads sed -E -i.bak 's/(^ +\(pad.*\(size)([^\)]+)(\) \(drill)([^\)]+)(.*)/\1 2 2\3 1\5/g' SOURCE_FILE.kicad_pcb #Quickly add a new user to all groups the default user is in groups pi | xargs -n 1 | tail -n +4 | xargs -n 1 sudo adduser kostis