Skip to content

Linux One-liners

Who doesn’t love a good Linux one-liner? To me they are the epitome of skill. They represent the ability to not only know what command needs to happen but how to initiate this in a very efficient way. For example one of my favorite commands I am telling people all of the time is

sudo !!

or “sudo bang bang”. This command runs the last command run but with sudo in front of it. We have all had those moments where we want to edit a file but we’re hit with a permissions error of not being root. Instead of re-typing the full command again, just hit ‘sudo !!’ and you’re golden. For more great one-liners check out this great resource at linuxcommandlibrary.com. Here are a few more useful Linux one-liners.

Remove all spaces from all files in current folder
>_ rename 's/ //g' *
Find Duplicate Files (based on size first, then MD5 hash)
>_ fdupes -r .
Fix Ubuntu's Broken Sound Server
>_ sudo killall -9 pulseaudio; pulseaudio >/dev/null 2>&1 &
A function to find the fastest free DNS server
>_ timeDNS() { parallel -j0 --tag dig @{} "$*" ::: 208.67.222.222 208.67.220.220 198.153.192.1 198.153.194.1 156.154.70.1 156.154.71.1 8.8.8.8 8.8.4.4 | grep Query | sort -nk5; }
Number of open connections per ip.
>_ netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Submit command & rewrite orginal command
>_ <ctrl>+o

Published inFunLinux

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *