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

get useful statistics from tcpdump (sort by ip)
We can get useful statistics from tcpdump with this simple command. Thanks "Babak Farrokhi" to teaching me this ;)

List only executables installed by a debian package
I wanted to view only executables installed by a package. This seemed to work. There's got to be easier way, please share. Note: (1) Replace iptables with the package name of your interest (2) The command will trash any existing environment variable named 'lst' (3) Instead if you are interested in viewing just .ko or .so files installed by this package, then that would be easy: $ dpkg -L iptables | grep "\.[sk]o$"

Mac OS-X-> copy and paste things to and from the clipboard from the shell
Copies whatever is piped to the pbcopy command to the clipboard. pbpaste ... well pastes whats on the clipboard.

resize all JPG images in folder and create new images (w/o overwriting)
Convert all jpegs in the current directory into ~1024*768 pixels and ~ 150 KBytes jpegs

Advanced python tracing
Trace python statement execution and syscalls invoked during that simultaneously

Perl Simple Webserver
First we accept a socket and fork the server. Then we overload the new socket as a code ref. This code ref takes one argument, another code ref, which is used as a callback. The callback is called once for every line read on the socket. The line is put into $_ and the socket itself is passed in to the callback. Our callback is scanning the line in $_ for an HTTP GET request. If one is found it parses the file name into $1. Then we use $1 to create an new IO::All file object... with a twist. If the file is executable("-x"), then we create a piped command as our IO::All object. This somewhat approximates CGI support. Whatever the resulting object is, we direct the contents back at our socket which is in $_[0].

Execute matlab sentences from command line
Execute matlab sentences in shell script: for var in `seq 0 0.2 1` ; do echo "my_function($var);" | matlab -nodisplay done

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"

Capitalize first letter of each word in a string
I find it useless but definitely simpler than #9230

Selecting a random file/folder of a folder
Also looks in subfolders


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: