All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Show a config file without comments
Shows a file without comments (at least those starting by #) - removes empty lines - removes lines starting by # or "some spaces/tabs then #'" Useful when you want to quickly see what you have to customize on a freshly installed application without reading the comments that sometimes are a full 1000 lines documentation :) While posting, I saw this http://www.commandlinefu.com/commands/view/1041/display-contents-of-a-file-wo-any-comments-or-blank-lines But it's dirty and incomplete, to my mind My original goal was to remove lines like "\t*#" but I can't figure out how to do a egrep '\t' on a command-line. Two workarounds if needed: $egrep -v 'press control + V then TAB then #' /your/file or $egrep -v -f some_file /your/file #where some_file contains what you want to exclude, example a really inserted TAB

subtraction between lines
It's allways strange for me to see sed and awk in the same command line if you can avoid it

Get last sleep time on a Mac
Similarly for last wake time: $ sysctl -a | grep waketime

Quickly analyze apache logs for top 25 most common IP addresses.
This command is much quicker than the alternative of "sort | uniq -c | sort -n".

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Schedule a command while one is already running.
Useful when you have only one terminal session e.g. ssh. and want to queue up another command after the currently running has finished(in case if you forget to run that command). Originally used as ; python-updater when running emerge. When I have noticed that a package failed due to that command not run.

get you public ip address
Relies on ifconfig.me functioning. It's about as easy as it gets, and memorable to old geeks too.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Update twitter with Perl
Requires Net::Twitter. Just replace the double quoted strings with the appropriate info.

trace the system calls made by a process (and its children)
strace can be invaluable in trying to figure out what the heck some misbehaving program is doing. There are number of useful flags to limit and control its output, and to attach to already running programs. (See also 'ltrace'.)


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: