top | item 4284688

Command line tools every web dev needs to know

232 points| countessa | 13 years ago |coderholic.com | reply

68 comments

order
[+] zalew|13 years ago|reply
quite relevant: http://www.commandlinefu.com a great collection of cli uses and abuses

one of my favorites is querying dns to get wiki excerpts

    dig +short txt bmw.wp.dg.cx
    "(BMW), is an independent German automobile manufacturing company founded in 1916. It also produces motorcycles, is the owner of the MINI brand and is the parent company of Rolls-Royce Motor Cars. http://en.wikipedia.org/wiki/BMW"
http://www.commandlinefu.com/commands/view/2829/query-wikipe...
[+] morsch|13 years ago|reply
I've got something like this in my .bashrc so I can access commandlinefu from within the shell:

  cmdfu(){ wget -qO - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext"; }
It's like man but for one-liners.
[+] benjaminwootton|13 years ago|reply
We are interviewing for experienced developers at the moment and the lack of general unix knowledge is really surprising.

A little bit of shell scripting goes a long way in automating away dev work.

[+] Derbasti|13 years ago|reply
Also, typing.

I am frequently amazed to see professional software developers with years of experience in the field, who only type using their two index fingers. You probably do not need to type 120 WPM to be an amazing programmer, but typing without looking at the keyboard is absolutely essential.

[+] zobzu|13 years ago|reply
I agree whole-fully. I know many "experts" in various areas such as programming, web dev, security, and a few others.

Rare are the ones who know how to use these basic commandline tools.

The last time I've shown ngrep to a sysadmin he was like "omagad amazing" - always feels nice :)

But, that's not really an obscure tool. I initially thought everyone knew that, like most know nmap.

Turns out most know nmap and ssh because they're really that well known (generally they don't know most options)

Makes me sad! Command's line easy and fun!

[+] lordlarm|13 years ago|reply
Another useful one; Fire up a instant web-server from local folder on http://localhost:8080:

> python -m SimpleHTTPServer

[+] dudus|13 years ago|reply
Note that it has changed in python3

  > python3 -m http.server
  Serving HTTP on 0.0.0.0 port 8000 ...

  > python3 -m http.server 8080
  Serving HTTP on 0.0.0.0 port 8080 ...
[+] bgaluszka|13 years ago|reply
Or if you use php (5.4 needed)

> php -S localhost:8080

[+] axitanull|13 years ago|reply
Also in case you need to use another port (such as 5000):

> python -m SimpleHTTPServer 5000

[+] agumonkey|13 years ago|reply
smtp server one liner :

    $ sudo python -m smtpd -n -c DebuggingServer localhost:25
[+] simfoo|13 years ago|reply
> With the following command we test google with 20 concurrent connections for 30 seconds

Even though this is Google and they probably don't have a problem with this, I don't think you should benchmark servers that don't belong to you. It's not nice and could be mistaken for a DOS attack.

[+] ihsw|13 years ago|reply
Google may actually give you a short-term IP ban (a day or so), so spamming their servers with spurious connections may not be in your best interest -- doubly so if you're at a workplace.
[+] lovskogen|13 years ago|reply
Yesterday I used the ipfw command to run our product in "slow motion" to spot loading order and if animations started at the right places. Discovered alot of stuff that needs fixing. The ipfw command is for trottling bandwidth, and great for product designers like myself :) I'm sure it has other uses as well.
[+] rada|13 years ago|reply
OS X has a useful Network Link Conditioner utility. It has built-in profiles such as lossy 3G connection, average wifi connection, good wifi connection etc.
[+] sirn|13 years ago|reply

    $ curl -I news.ycombinator.com
    HTTP/1.1 200 OK
    Content-Type: text/html; charset=utf-8
    Cache-Control: private
    Connection: close
Keep in mind that this will fire a HEAD request to the server which, depending on web server you use in development, may not return the exact header you'd get with GET (IIRC, Jetty used to do this).

I like to use something like this in such situation:

    $ curl -s -D /dev/stderr news.ycombinator.com >/dev/null
[+] k33l0r|13 years ago|reply
You can also use the -i option which prints out the headers and the response body (which is perhaps a bit too noisy).

    curl -i http://news.ycombinator.com
[+] ralph|13 years ago|reply
I rarely find I use curl's -s without its -S, e.g. -sS. It seems curl's design is flawed in its definition of -s; perhaps it's historic and it was too late to change it.
[+] jasomill|13 years ago|reply
Among (too) many other things, the OpenSSL "openssl" command does Base64 en/decoding, calculates MD5 and SHA* hashes, creates, displays, converts, and verifies certificates, certificate chains, and CRLs, and even works as a convenient "micro-CA" for testing purposes.
[+] bazzargh|13 years ago|reply
That ngrep tool is pretty nifty. Has anyone done something like that with dtrace? (I know about tcpsnoop - something at a higher level)
[+] ibotty|13 years ago|reply
swaks is another very nice tool for email-testing (isn't email also part of the web nowadays)
[+] justincormack|13 years ago|reply
Being able to use DNS tools is a requirement too.
[+] patrickod|13 years ago|reply
Another alternative to ifconfig.me is icanhazip.com The main difference being that icanhazip.com supports ipv6.
[+] kooshball|13 years ago|reply
if you use json a lot, this is super useful for prettifying stuff in command line.

echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool