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

Find out current working directory of a process
This is an alternative to another command using two xargs. If it's a command you know there's only one of, you can just use: $ ls -l /proc/$(pgrep COMMAND)/cwd

Writes ID3 tags using the file name as the title.
Assumes that the files are named as such: 01-Filename.mp3 If your files are named differently, change the number of periods in the sed 's/...\(.*\)/\1' bit to match the numbers of characters you need to cut off the front of the file. Note: This only writes the titles.

Ping all hosts on 192.168.1.0/24

Validate and pretty-print JSON expressions.
You can use a site like http://www.jsonlint.com/ or use the command line to validate your long and complex json data. This is part of the simplejson package for python http://undefined.org/python/#simplejson. Wrong json expression example: $ echo '{ 1.2:3.4}' | python -m simplejson.tool Expecting property name: line 1 column 2 (char 2)

pretend to be busy in office to enjoy a cup of coffee
Not as taxing on the CPU.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Open a Remote Desktop (RDP) session with a custom resolution.
Using a widescreen monitor, I often get annoyed that the RDP window is too high, or too narrow for what I want to display. In this example, I'm on a 1680 x 1050 display.

List all files modified by a command
Often you run a command, but afterwards you're not quite sure what it did. By adding this prefix/suffix around [COMMAND], you can list any files that were modified. . Take a nanosecond timestamp: YYYY-MM-DD HH:MM:SS.NNNNNNNNN $ date "+%F %T.%N" . Find any files that have been modified since that timestamp: $ find . -newermt "$D" . This command currently only searches below the current directory. If you want to look elsewhere change the find parameter, e.g. $ find /var/log . -newermt "$D"

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"

force a rescan on a host of scsi devices (useful for adding partitions to vmware on the fly)


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: