Hide

What's this?

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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

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.

Universal configuration monitoring and system of record for IT.
Hide

Stay in the loop…

Follow the Tweets.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

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:

Hide

News

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Hide

Credits

All commands from sorted by
Terminal - All commands - 12,144 results
grep enabled /sys/firmware/acpi/interrupts/*
2013-07-16 03:46:23
User: m33600
Functions: grep
0

Goto phase 2 to clobber the interrupt that is problematic.

:w !sudo tee %
Set-Mailbox -Identity John -DeliverToMailboxAndForward $false -ForwardingSMTPAddress manuel@contoso.com
# dstat
=() {python3 -c "from math import *;print($*)"}
openssl pkcs12 -export -in /dir/CERTIFICATE.pem -inkey /dir/KEY.pem -certfile /dir/CA-cert.pem -name "certName" -out /dir/certName.p12
find -name '*oldname*' -print0 | xargs -0 rename 's/oldname/newname/'
2009-07-27 00:44:06
Functions: find rename xargs
0

This is better than doing a "for `find ...`; do ...; done", if any of the returned filenames have a space in them, it gets mangled. This should be able to handle any files.

Of course, this only works if you have rename installed on your system, so it's not a very portable command.

echo "import this" | python
2009-08-15 09:42:36
User: loquitus
Functions: echo
0

Very very cool list of quotations and directives on pythonic programming. I love them and they are sure applicable in C++ too, and for most any programming, really.

Putty -d 8080 [server]
2009-10-15 06:54:58
User: felix001
0

Run this on a windows machine then add your localhost as a socks server for port 8080 within your web browser. Your traffic will now be proxying and sent via your server over ssh.

find -name 'foo*' | while read i; do echo "$i"; done
2010-07-16 15:35:27
User: imgx64
Functions: echo find read
0

Replace the echo command with whatever commands you want.

'read' reads a line from stdin and places the text in the variable, the stdin of the while loop comes from the find command.

Note that with simple commands, an easier way is using the '-exec' option of find. My command is useful if you want to execute multiple commands in the loop.

find <src-path-to-search> -name "<folder-name>" | xargs -i cp -avfr --parent {} /<dest-path-to-copy>
2010-11-22 10:58:42
User: crxz0193
Functions: cp find xargs
0

This command will a particular folder-name recursively found under the src-path-to-search to the dest-path-to-copy retaining the folder structure

N=10; echo "($N*($N+1)*(2*$N+1))/6" | bc
2011-02-15 20:02:57
Functions: echo
0

Simplified the series to a polynomial and send it to bc

netstat -nut | sed '/ESTABLISHED/!d;s/.*[\t ]\+\(.*\):.*/\1/' | sort -u
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898
systemctl --failed | head -n -6 | tail -n -1
grep -H voluntary_ctxt /proc/*/status |gawk '{ split($1,proc,"/"); if ( $2 > 10000000 ) { printf $2 " - Process : "; system("ps h -o cmd -p "proc[3]) } }' | sort -nk1,1 | sed 's/^/Context Switches: /g'
2012-09-01 19:43:47
User: jperkster
Functions: gawk grep printf sed sort
0

This command will find the highest context switches on a server and give you the process listing.

knife ec2 server create -r role[base],role[webserver] -E development -I ami-2a31bf1a -i ~/.ssh/aws-west.pem -x ec2-user --region us-west-2 -Z us-west-2b -G lamp --flavor t1.micro -N chef-client1 --no-host-key-verify
2012-11-06 00:08:18
User: rwilson04
0

creates an ec2 instance, bootstraps with chef

pathrm() { PATH=`echo $PATH | sed -re 's#(:|^)cde($|:)#:#g;s#^:##g;s#:$##g'`; }
echo "disable" > /sys/firmware/acpi/interrupts/gpeXX
2013-07-16 03:53:20
User: m33600
Functions: echo
0

change gpeXX by the culprit you discovered on phase 1

In case of this example, the culprit is the biggest number, ie, gpe1C

/sys/firmware/acpi/interrupts/ff_gbl_lock: 0 enabled

/sys/firmware/acpi/interrupts/gpe01: 0 enabled

/sys/firmware/acpi/interrupts/gpe06: 0 enabled

/sys/firmware/acpi/interrupts/gpe17: 2 enabled

/sys/firmware/acpi/interrupts/gpe18: 0 enabled

/sys/firmware/acpi/interrupts/gpe1C: 19 enabled

This procedure,if solved this universal issue all linix distros are experimenting for more than 2 years, may be included at startup, via cron. But try first commandline.

bind -P | grep -v "is not" | sed -e 's/can be found on/:/' | column -s: -t
2013-12-19 12:30:19
User: leni536
Functions: column grep sed
0

Shows all available keyboard bindings in bash. Pretty printing.

net user user_name new_password /domain
powershell -Command "while (\$true){Try{\$process=Get-Process firefox -ErrorAction Stop}Catch [Microsoft.PowerShell.Commands.ProcessCommandException]{break;}if (\$process) {\$whateva=\$process.CloseMainWindow()}else {break;}Start-Sleep -m 500}"
2014-07-04 11:06:22
User: adanisch
0

This command will loop until the process no longer exists, calling closemainwindow() this is as if the user clicked the close window x in the upper right hand corner and gives the user an opportunity to save work in many applications like notepad and other things. The $'s are escaped for Cygwin, if you want to run the same command from the RUN box or cmd.exe shell then just unescape the $'s:

powershell -Command "while ($true){Try{$process=Get-Process calc -ErrorAction Stop}Catch [Microsoft.PowerShell.Commands.ProcessCommandException]{break;}if ($process) {$whateva=$process.CloseMainWindow()}else {break;}Start-Sleep -m 500}"

setxkbmap -option caps:backspace
2014-10-27 22:53:39
User: lgarron
0

The internet is full of advice about how to change the caps lock key into a backspace key (a useful practice that originated with Colemak), but a lot of instructions are complicated or outdated.

After *lots* of searching for something that still worked on Ubuntu 14.04, I finally found that this simple command is sufficient and takes effect immediately.

(Found at: http://www.howtogeek.com/194705/how-to-disable-or-reassign-the-caps-lock-key-on-any-operating-system/ )

in bash hit "tab" twice and answer y
rcsdiff -y myfile
2010-06-14 15:49:42
User: dbh
0

Use -W to adjust the width of the output, and --suppress-common-lines to show only the lines that have been changed.