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

Changing the terminal title to the last shell command
Found the same command for zsh in http://www.davidpashley.com/articles/xterm-titles-with-bash.html - changed it a bit so that the behaviour is the same

shutdown if wget exit

Show the 1000*1000 and 1024*1024 size of HDs on system

Creates PodFeeds.txt, a file that lists the URLs of rhythmbox podcasts from the rhythmdb.xml file.
The first grep any line with pod-feed in it plus the following five lines. The second grep throws out any line not containing . sed removes the leading four spaces then and the trailing . Using a colon as sed's separating character avoids having to escape the /. Works ok with Mythbuntu 9.04 (used mostly as a three line bash script).

Query well known ports list
Uses the file located in /etc/services

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"

Quick case-insenstive partial filename search
This is a simple command, but extremely useful. It's a quick way to search the file names in the current directory for a substring. Normally people use "ls *term*" but that requires the stars and is not case insensitive. Color (for both ls and grep) is an added bonus.

Output requirements.txt packages pinned to latest version
Given a requirements.txt file with unpinned package names, output the packages pinned to the latest version. Handy to copy/paste back into your requirements.txt when you start a new project. Note that this will download packages but not install them.

Save your open windows to a file so they can be opened after you restart
This will save your open windows to a file (~/.windows). To start those applications: $ cat ~/.windows | while read line; do $line &; done Should work on any EWMH/NetWM compatible X Window Manager. If you use DWM or another Window Manager not using EWMH or NetWM try this: $ xwininfo -root -children | grep '^ ' | grep -v children | grep -v '' | sed -n 's/^ *\(0x[0-9a-f]*\) .*/\1/p' | uniq | while read line; do xprop -id $line _NET_WM_PID | sed -n 's/.* = \([0-9]*\)$/\1/p'; done | uniq -u | grep -v '^$' | while read line; do ps -o cmd= $line; done > ~/.windows

Extract audio stream from an video file using mencoder
This command extracts the audio stream of the video in $file and stores it in a file where the original suffix is changed to .mp3


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: