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

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"

list human readable files
include in the list human readable hidden files too: $ file .* *|grep 'ASCII text'|sort -rk2 more reliable command: $ ls|xargs file|grep 'ASCII text'|sort -rk2 and include hidden files: $ ls -a|xargs file|grep 'ASCII text'|sort -rk2

Don't save commands in bash history (only for current session)
Unsetting HISTFILE avoid getting current session history list saved.

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"

Top ten (or whatever) memory utilizing processes (with children aggregate) - Can be done without the multi-dimensional array

Using numsum to sum a column of numbers.
if you, like me, do not have the numsum, this way can do the same.

Split File in parts
Split File in 19 MB big parts, putting parts together again via cat Nameforpartaa Nameforpartab Nameforpartac >> File

Retry the previous command until it exits successfully
Repeat the previously used command (!!) until it exits with a success code (0). To put a delay between attempts you could do something like $ until !!; do sleep 5; done to wait 5 seconds after each attempt.

Get line count for any file ending with extension recursively rooted at the current directory.

list files in mtime order
Simple but useful; list files in the current directory in mtime order. Useful if you've been working on something and then take a day or two off.


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: