Ask HN: How to learn command line?

7 points by hella ↗ HN
I've done a decent amount of front-end coding (html,css,jquery) and some backend (php). But I never took the time to learn how to use the command line.

Should I? Where do I even begin?

16 comments

[ 3.1 ms ] story [ 51.0 ms ] thread
I personally believe that there is great value in learning how to use and be proficient with the command line. It is a different way of working from the GUI based systems that many computer users learn and primarily use. And it can be a very powerful and very quick way of working, as well.

I would say install a simple, stripped down Linux distro on a computer and try to use it for everything. Necessity is the best motivator to learning in my experience. You can start off with Gnome, but if you want to force yourself to learn the command line better, install something more lightweight (like enlightenment, or openbox) and then figure out how to configure it and try and do work from there.

If you don't have a box you can put Linux on and can use, find a super cheap Linux VPS (search around on lowendbox.com) and then follow a tutorial on setting up a simple server. Then you can do an email server, try using it as a torrentbox, etc. This may even be a better option, because it will be a place you can put up your other work. It's only a couple bucks a month, and once you've got things figured out, try doing more with it. Switch from Apache to nginx, for example.

The key is simply spending time on the command line, then you will be able to get comfortable with it. Also, there are many, many great tricks that you can learn if you know someone who is good at using Unix command lines and shells simply by watching over their shoulder. Some of the most valuable tidbits I have learned have been when someone saw me do something the hard way, then taught me a better way to do it (it took me a long time before I learned about tab completion, for example).

Should you is nearly a philosophical question, so for the moment I'll just assume you kind of want to. I strongly recommend The Linux Phrasebook if you regularly use Linux. If you use OSX, you might take a look at Peepcode's screencasts on the command line[2]. (Much of The Linux Phrasebook actually applies to OSX as well, but there will be occasional issues because Linux uses GNU versions of things that Mac uses BSD versions of. This can cause lots of small differences, though the underlying basics are pretty similar.)

[1] http://opensource.weblogsinc.com/2006/06/20/my-new-book-linu...

[2] http://peepcode.com/products/meet-the-command-line

If using Windows, then Powershell.
Nah, install cygwin and use bash so your skills are transferable. Linux skills last for years; Windows skills tend to last till the next version. And I say this coming from a Windows background.
Powershell gives you direct access to all .NET components and the ability to run C# [or any other CLR language] directly from the command line and in your scripts.

YMMV.

That's untrue. I haven't used Windows as my primary workstation in over two years (and it was an XP system then) and I can hop onto a Win7 box and interact using most of the same commands I internalized administrating Windows 3.11 boxes on LanMan networks in the mid-90s.

The real problem is that Windows skills generally are only transferrable to other versions of Windows whereas Unix command line tools - be they GNU or BSD - are. And even that's not entirely true. If there's a Windows command-line tool that you learn about and like I guarantee you it's based on a Unix command-line tool that has a man entry.

I'm not talking about just the operating system, I'm talking about the platform and the necessary services you'd need on a server. Configuring a windows server, setting up IIS, mail server, etc, are different from version to version. Linux is much more consistent, editing a few text files in /etc. Sure, you can jump into cmd and execute many of the commands that always worked on windows, but that's a very small set of commands compared to Linux.

I made the switch to Linux a few years ago for servers, only months ago for my primary workstation, and I'd never go back to Windows; though Windows with cygwin is close enough to Linux to make a very nice workstation.

>"I'd never go back to Windows"

That's not much of a reason to use Cygwin in lieu of Powershell.

Sure it is, it's how you make the transition to Linux easier.
With that I certainly do agree.
Necessity is the best teacher. Get a VPS from someone like Linode, invent a project and run it all yourself. You'll learn a ton just getting Apache set up and running.
Good advice.

I really only started working with the command line after I started working on a Django project about 3 or 4 years ago, and I was constantly frustrated by the inefficiencies of the GUI tools. I needed to script commands and repeat them over and over.

I think the comments here miss the bigger picture, which is that the command-line is the most direct and eloquent way to directly interface with a computer for many advanced tasks. The gist is that you tell the computer exactly what you want to do, in no uncertain terms, with supporting information, all in one fell swoop. After that, everything else is just syntax.
(comment deleted)
You shouldn't. The command-line is the less powerful tool you can use to interact with the system.

Learn a powerful scripting language, instead (Python, Lua, ecc.).

Oh, and since for basic tasks you will be using the command-line anyway, if you are using *nix, please use one designed to be used by humans, that is, Fish: http://en.wikipedia.org/wiki/Friendly_interactive_shell

(comment deleted)