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

List all execs in $PATH, usefull for grepping the resulting list
While it seems (to me at least) a little counter-intuitive to filter on name first, this requires less work for find, as it allows it to immediately discount any files that do not match the name directly from the directory listing on disk. Querying against file attributes requires reading the file attributes, which is performed for all files matching any name based predicates.

Print all open regular files sorted by the number of file handles open to each.
This command run fine on my Ubuntu machine, but on Red Hat I had to change the awk command to `awk '{print $10}'`.

calulate established tcp connection of local machine
If you want prepend/append text just wrap in echo: $echo Connected: `netstat -an|grep -ci "tcp.*established"`

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

List directories recursively showing its sizes using only ls and grep
ls -lhR Lists everithing using -l "long listing format" wich includes the space used by the folder. Displays it in -h "human readable form" (i.e. 2.2G, 32K), and -R recurses subfolders. grep -e using a regex, show lines containing the word "total" or a ":" at the end of the line (those with the name of the folder) only.

Simple Video Surveillance by email
This takes a picture (with the web cam) every 5 minutes, and send the picture to your e-mail. Some systems support mail -a "References: " so that all video surveillance emails are grouped in a single email thread. To keep your inbox clean, it is still possible to filter and move to trash video surveillance emails (and restore these emails only if you really get robbed!) For instance with Gmail, emails sent to me+trash@gmail.com can be filtered with "Matches: DeliveredTo:me+trash@gmail.com"

Preview of a picture in a terminal
This command allows you to see a preview of a picture via the terminal. It can be usefull when you are ssh'ing your server without X-forwarding. To have en example of the output you can get with this command see http://www.vimeo.com/3721117 Download at http://inouire.net/image-couleur.html Sources here: http://inouire.net/archives/image-couleur_source.tar.gz

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Install pip with Proxy
Installs pip packages defining a proxy


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: