commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Typing a word in terminal is easier than digging your phone out, opening your two-factor authentication app and typing the code in manually.
This alias copies the one-time code to your clipboard for 3 seconds (long enough to paste it into a web form), then restores whatever was on the clipboard beforehand.
This command works on Mac. Replace pbpaste/pbcopy with your distribution's versions.
- recompresses all gz files to bz2 files from this point and below in the directory tree
- output shows the size of the original file, and the size of the new file. Useful.
- conceptually easier to understand than playing tricks with awk and sed.
- don't like output? Use the following line:
for gz in `find . -type f -name '*.gz' -print`; do f=`basename $gz .gz` && d=`dirname $gz` && gunzip -c $gz | bzip2 - -c > $d/$f.bz2 && rm -f $gz ; done
It find out the mic recording level at the moment of run the command and if a noise level is higher it starts to record an mp3 file. The resulting file will have only the sounds not the silences.
Very quick! Based only on the content sizes and the character counts of filenames. If both numbers are equal then two (or more) directories seem to be most likely identical.
if in doubt apply:
diff -rq path_to_dir1 path_to_dir2
AWK function taken from here:
You need to be root to do this. So check the command before running it.
You enter the same password for
Enter LUKS passphrase:
Enter passphrase for /dev/loopn:
You can then copy the .img file to somewhere else.
Loop it it with losetup -f IMAGENAME.img and then mount it with a file manager (eg nemo) or run mount /dev/loopn /media/mountfolder
Acts similar to a mounted flash drive
You need to apt-get install python-sqlparse. This command simply formats a sql query and prints it out. It is very useful when you want to move a sql query from commandline to a shell script. Everything is done locally, so you don't need to worry about copying sql query to external websites.
hexdump could be used for conversion too!
echo defaults to include a newline character at the end of the string, which messes with the hash. If you suppress it with -n then it has the same effect as PHP's ?echo md5("string"), "\t-";? Even more, by using cut you get the exact same output, so it works as a drop-in replacement for the original command for this thread.
Useful to add a timestamp to every line printed to stdout.
You can use `-Ins` instead of `-Iseconds` if you want more precision.
Edit YYYY and MM at the beginning of the command with the year and month you want.
Note that `DD=$(printf "%02d" $d)` will pad single digit integers with a leading zero.
Substitute `echo $YYYY$MM$DD` at the end of the line with the command you want to launch, for instance
script.pl --yyyymmdd $YYYY$MM$DD
this command will add the following two lines into the ~/.bash_aliases:
alias exit='pwd > ~/.lastdir;exit'
[ -n "$(cat .lastdir 2>/dev/null)" ] && cd "$(cat .lastdir)"
or redirect it to the ~/.bashrc if you like
Donno, I find it usefull. You may also define an alias for 'cd ~' like - alias cdh='cd ~'
Pings all the hosts on 192.168.1.0/24 in parallel, so it is very fast. Alive host IP addresses are echoed to stdout as pings are responded to.
client$ while true; do read -n30 ui; echo $ui |openssl enc -aes-256-ctr -a -k PaSSw ; done | nc localhost 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-ctr -k PaSSw`; echo -e "Incoming: $decoded_so"; done
This will establish a simple encrypted chat with AES-256-CTR using netcat and openssl only.
More info here https://nixaid.com/encrypted-chat-with-netcat/
Use find's internal stat to get the file size then let the shell add up the numbers.
Repair each node in sequence. Make sure you change the IP replacements to match your environment
Pass the files path to finfo(), can be unix path, dos path, relative or absolute. The file is converted into an absolute nix path, then checked to see if it is in-fact a regular/existing file. Then converted into an absolute windows path and sent to "wmic". Then magic, you have windows file details right in the terminal. Uses: cygwin, cygpath, sed, and awk. Needs Windows WMI "wmic.exe" to be operational. The output is corrected for easy...
finfo "/cygdrive/c/Program Files/notepad.exe"
Generates a bash array and uses it to select a random image from ~/wallpapers.
Old drive with lots of music or unsorted drive? This command will play all mp3 files in a folder and after playing one song or pressing q, it will ask you if you want to delete the file.