Hide

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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

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

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged scan from sorted by
Terminal - Commands tagged scan - 9 results
scanimage -p --resolution 250 --mode Gray -x 215.9 -y 279.4 | pnmtops -imageheight 11 -imagewidth 8.5 | ps2pdf - output.pdf
2013-04-12 18:18:42
User: dbh
Functions: scanimage
Tags: pdf scan scanner
3

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
checkport() { sudo nmap -sS -p $1 $2 }
2011-12-13 11:46:15
Functions: sudo
Tags: nmap scan port
0

Check to see if a port is open or closed on a given host.

arp-scan -I eth0 -l | perl -ne '/((\d{1,3}\.){3}\d{1,3})/ and $ip=$1 and $_=`nmblookup -A $ip` and /([[:alnum:]-]+)\s+<00>[^<]+<ACTIVE>/m and printf "%15s %s\n",$ip,$1'
pdftk A=odd.pdf B=even.pdf shuffle A1-end Bend-1S output duplex.pdf
2011-02-25 15:00:09
User: till
5

Joins two pdf documents coming from a simplex document feed scanner. Needs pdftk >1.44 w/ shuffle.

nmap -v -sP 192.168.0.0/16 10.0.0.0/8
2010-07-14 19:53:02
User: anapsix
6

nmap for windows and other platforms is available on developer's site: http://nmap.org/download.html

nmap is robust tool with many options and has various output modes - is the best (imho) tool out there..

from nmap 5.21 man page:

-oN/-oX/-oS/-oG : Output scan in normal, XML, s|

sudo arp-scan -I eth0 192.168.1.0/24
FOR /L %i IN (1,1,254) DO ping -n 1 10.254.254.%i | FIND /i "Reply">> c:\ipaddresses.txt
2010-06-29 21:02:21
Functions: ping
-8

documents all active ips on a subnet and saves to txt file.

for i in {21..29}; do nc -v -n -z -w 1 192.168.0.$i 443; done
2009-09-25 03:31:29
User: rez0r
9

Simple one-liner for scanning a range of hosts, you can also scan a range of ports with Netcat by ex.: nc -v -n -z -w 1 192.168.0.1 21-443

Useful when Nmap is not available:)

Range declaration like X..X "for i in {21..29}" is only works with bash 3.0+

gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=test.pdf multipageproject.pdf
2009-03-24 17:14:46
User: iain
Functions: gs
3

Xsane produces PDFs that are too large - particularly multipage PDFs. This command compresses them. If you do not use A4, remove the -sPAPERSIZE flag.