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

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"

Silently ensures that a FS is mounted on the given mount point (checks if it's OK, otherwise unmount, create dir and mount)
In my example, the mount point is /media/mpdr1 and the FS is /dev/sdd1 /mountpoint-path = /media/mpdr1 filesystem=/dev/sdd1 Why this command ? Well, in fact, with some external devices I used to face some issues : during data transfer from the device to the internal drive, some errors occurred and the device was unmounted and remounted again in a different folder. In such situations, the command mountpoint gave a positive result even if the FS wasn't properly mounted, that's why I added the df part. And if the device is not properly mounted, the command tries to unmount, to create the folder (if it exists already it will also work) and finally mount the FS on the given mount point.

Adding Prefix to File name
Adding course name prefix to lecture pdfs

Go to parent directory of filename edited in last command

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"

Scan a document to PDF
Adjust the --resolution and --mode as required (if these options are available for your scanner). The size options (-x, -y, -imageheight, -imagewidth) are for US letter paper. For A4, I think the command would be: $scanimage -p --resolution 250 --mode Gray -x 210 -y 297 | pnmtops -imageheight 11.7 -imagewidth 8.3 | ps2pdf - output.pdf

search string in _all_ revisions

check open ports without netstat or lsof

Remove all but one specific file

ps with parent/child process tree
Shows a tree view of parent to child processes in the output of ps (linux). Similar output can be achieved with pstree (also linux) or ptree (Solaris).


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: