What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world.
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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

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.

In a multiple PostgreSQL server environment knowing the servers version can be important. Note that psql --version returns just the local psql apps version which may not be what you want. This command dumps the PostgreSQL servers version out to one line. You may need to add more command line options to the psql command for your connection environment.

Useful if localhost is a small machine running BusyBox, which uses a slightly unusual format to set the date. Remotehost can be pretty much any Linux machine, including one running BusyBox. Uses UTC for portability.

This example is taken from Cygwin running on Win7Ent-64. Device names will vary by platform.

Both commands resulted in identical files per the output of md5sum, and ran in the same time down to the second (2m45s), less than 100ms apart. I timed the commands with 'time', which added before 'dd' or 'readom' gives execution times after the command completes. See 'man time' for more info...it can be found on any Unix or Linux newer than 1973. Yeah, that means everywhere.

readom is supposed to guarantee good reads, and does support flags for bypassing bad blocks where dd will either fail or hang.

readom's verbosity gave more interesting output than dd.

On Cygwin, my attempt with 'readom' from the first answer actually ended up reading my hard drive. Both attempts got to 5GB before I killed them, seeing as that is past any CD or standard DVD.

dd:

'bs=1M' says "read 1MB into RAM from source, then write that 1MB to output. I also tested 10MB, which shaved the time down to 2m42s.

'if=/dev/scd0' selects Cygwin's representation of the first CD-ROM drive.

'of=./filename.iso' simply means "create filename.iso in the current directory."

dev='D:' in Cygwin explicitly specifies the D-drive. I tried other entries, like '/dev/scd0' and '2,0', but both read from my hard drive instead of the CD-ROM. I imagine my LUN-foo (2,0) was off for my system, but on Cygwin 'D:' sort of "cut to the chase" and did the job.

f='./filename.iso' specifies the output file.

speed=2 simply sets the speed at which the CD is read. I also tried 4, which ran the exact same 2m45s.

retries=8 simply means try reading a block up to 8 times before giving up. This is useful for damaged media (scratches, glue lines, etc.), allowing you to automatically "get everything that can be copied" so you at least have most of the data.

The "proportional set size" is probably the closest representation of how much active memory a process is using in the Linux virtual memory stack. This number should also closely represent the %mem found in ps(1), htop(1), and other utilities.

Compute the md5 checksums for the contents of two mirrored directories, then sort and diff the results. If everything matches, nothing is returned. Otherwise, any checksums which do not match, or which exist in one tree but not the other, are returned. As you might imagine, the output is useful only if no errors are found, because only the checksums, not filenames, are returned. I hope to address this, or that someone else will!