top | item 10245033

Learn Enough Command Line to Be Dangerous (Draft)

137 points| hkailahi | 10 years ago |learnenough.com

59 comments

order
[+] atbattag|10 years ago|reply
When introducing kill, don't use -9. Not a good way for a beginner to learn kill. Guess you weren't kidding with "Learn Enough Command Line to Be Dangerous". Understood that it's a draft. Coming together nicely.
[+] rawdisk|10 years ago|reply
kill -15 $pid || kill -2 $pid || kill -1 $pid || kill -9 $pid

I could be wrong but I think beginners learn about -9 because beginners are more likely to start processes that they change their mind about and then cannot stop. Nothing wrong with this in the spirit of experimentation.

For more advanced users more familiar with the processes they start, I would guess -15 should be sufficient most of the time.

[+] mhartl|10 years ago|reply
Could you expand on this? In my experience, kill frequently fails without -9, so I basically always include it (and it's never bitten me). I'm open to suggestions, though, so if you have a recommendation for a better way I'd appreciate the feedback. (Feel free to shoot me an email at the address in my profile.)
[+] natch|10 years ago|reply
Nicely done! Feedback, since it's a draft: There's a lot of introductory verbiage at the beginning. I wonder if this could be condensed or put off in a sidebar.

On OS X, for some languages at least, if the user has installed additional keyboard input languages, then Command-space may be taken over for switching input language, and thus the instructions for opening a terminal with Spotlight would not work.

Looked through some of the explanations and things such as the walkthrough of Ctrl-C are very well done for true beginner level readers.

[+] mhartl|10 years ago|reply
Thanks for the feedback. The reason for the verbiage is that this is the first of eight planned prerequisite tutorials [1], so Learn Enough™ Command Line to Be Dangerous is setting the stage for all the others as well. The introduction to each future tutorial will be focused exclusively on the content of that one document. I'll definitely look at putting some of the intro into a sidebar, though; that might work well.

Regarding Command-space, I've added a clarification regarding ways to start Spotlight. Thanks again for the helpful suggestions.

[1]: http://learnenough.com/

[+] BWStearns|10 years ago|reply
My cmd + space is actually somehow bound to both, so to search I do:

cmd + space ; esc ; cmd + space

Every once in a while I debate uncolliding them, but for some reason I get a mild kick out of occasionally unexpectedly seeing cyrillic dump out on the command line.

[+] BWStearns|10 years ago|reply
What a great tutorial. This was definitely an underserved portion of the learning process. Also, learned `cd -` and I think my days will be ever so slightly but definitely better for it. Thanks for sharing!

Also definitely go into why `rm -rf` is such a dangerous command, by that stage in the tutorial the reader has likely begun feeling confident experimenting but has yet to encounter anything really dangerous.

[+] digi_owl|10 years ago|reply
There are times i wish rm had a dry run kind of switch, where it would list out all the files that would be affected before asking for approval.
[+] eponeponepon|10 years ago|reply
The point in the introduction about people who work with developers needing to be familiar with the console is hugely important, in my opinion. It's the one bridge, short of someone having actual previous coding experience, that really makes my life easier at work. It also makes people feel, or so I observe, more confident and in control of their workstation.
[+] mhartl|10 years ago|reply
Indeed, I hope that the three-tutorial sequence covering the command line, text editors, and Git will be a useful package for the works-with-developers crowd.
[+] SebKba|10 years ago|reply
I really like the format and styling! It's broken up nicely with the images you added and the commands are kept to the really important ones. The summaries at the end of each chapter is great as takeaway. Maybe you could create a cheat sheet of the combination of summaries?

I'm looking forward to the Git edition of this series.

[+] mhartl|10 years ago|reply
Maybe you could create a cheat sheet of the combination of summaries?

Cool, that's a great idea. It should be easy to extract all the relevant tables and put them into a single document. Thanks!

[+] vram22|10 years ago|reply
For people who would like to go further, and explore writing command line tools (instead of only using them), in C [1], for Linux [2], this post and the linked article in it, by me, may be of help:

Developing a Linux command-line utility:

http://jugad2.blogspot.in/2014/09/my-ibm-developerworks-arti...

[1] In C, but the utility development guidelines described in the article mostly apply to other languages like Python and Ruby too, since the main principles are the same.

[2] It may compile and run on Mac OS X too, since it is a Unix, but I haven't tested it on that platform.

[+] pagade|10 years ago|reply
Under 'less' commands - can suggest 'g' instead of '1G'.
[+] mhartl|10 years ago|reply
Heh, I've been using 1G for so long I didn't realize g works, too. I'll think about mentioning it. Of course, one advantage of 1G is that it generalizes to values of n other than 1.
[+] erokar|10 years ago|reply
I really wish developers today (in the 2000s, for Christ's sake) didn't have to deal with such a horrible UI.

The Unix Hater's Hanbook says it well: "The original Unix solved a problem and solved it well, as did the Roman numeral system, the mercury treatment for syphilis, and carbon paper. And like those technologies, Unix, too, rightfully belongs to history. It was developed for a machine with little memory, tiny disks, no graphics, no networking, and no power."

Bu since wee seem to be stuck with Unix, I guess we need any guidance we can get.

[+] pakled_engineer|10 years ago|reply
Feel free to abstract away the entire shell. The shell is merely a command-driven REPL that interacts with the kernel API, rewrite the shell however you want with an embedded interpreter like how Emacs eshell works (learn one shell, works across every OS Emacs is ported to).

Can also just script shell commands and create levels of abstraction to suit whatever simple layer of abstraction suits you. This is what things like Nautilus File Manager do to manipulate files with a mouse.

[+] el_benhameen|10 years ago|reply
I enjoy Unix and the Unix philosophy, but I'm legitimately interested: what would a better system look like to you?
[+] roghummal|10 years ago|reply
I'm just riffing here but maybe the reason we're stuck on *nix is because it came from a time before The Cloud, subscription software, sharecropper software, etc. It was made to make you more productive; Not to make you #<whatever> of #<whatever> user of Super.os.

OSes weren't worth a whole lot; Money was made on the hardware and the applications. How do you make people productive? Give them an OS that enables productivity.

Unix succeeded because AT&T didn't recognize the value of what they had.

[+] liveoneggs|10 years ago|reply
demonstrate your improvement
[+] rav|10 years ago|reply
Why is 1,060 KB of JavaScript required to display this wonderful text page? Is there a way to read just the text without any interactive elements?
[+] mhartl|10 years ago|reply
The Learn Enough tutorials use the Softcover system (http://softcover.io/), which stores the HTML on S3 and uses JavaScript to pull it in dynamically. The flexibility and convenience of Softcover come at the price of a little extra JavaScript—a price that, from my perspective, is well worth paying.
[+] meeper16|10 years ago|reply
What has the world come to where the command line is something foreign to a software developer? Throw me on an island with a few unprovisioned *inux boxes and I'm all set.
[+] mhartl|10 years ago|reply
What has the world come to where the command line is something foreign to a software developer?

What in the world are you talking about? The whole point of this tutorial is to teach command-line basics as a first step toward becoming a software developer. From the tutorial:

Many programming tutorials either gloss over the command line or assume you already know it. But understanding the basics of the command line is absolutely essential to becoming a skilled developer. Indeed, if you look at the desktop of an experienced computer programmer, even on a system with a polished graphical user interface like Macintosh OS X, you are likely to find a large number of “terminal windows”, each containing a series of commands at a command line (Figure 1). Proficiency at the command line is also useful for anyone who needs to work with developers, such as product managers, project managers, and designers. Making this valuable skill accessible to as broad an audience as possible is the goal of Learn Enough™ Command Line to Be Dangerous.

[+] JasperBall|10 years ago|reply
A different type of world?
[+] Roadgazer|10 years ago|reply
I understand this thing is aimed to create super power perception within tech novice ppl when some command line is learned, but, seriously, this new fashion of claiming that if you wrote couple lines of code means you are software guru now, is absurd.
[+] 01Michael10|10 years ago|reply
Who claimed this? You totally missed the point of these tutorials. It's "Learn Enough Command Line to Be Dangerous" NOT "Learn Everything About the Command Line to Be a Guru".
[+] bittercynic|10 years ago|reply
What do you have to do to get at the content?
[+] mhartl|10 years ago|reply
You should just be able to scroll down. If that doesn't work, send an email to the address in my profile with details on exactly what's confusing you. For future iterations of the UI, I'm looking at adding access to the table of contents as well.

Update: You probably just need to enable JavaScript, as the Learn Enough tutorials use the Softcover system (http://softcover.io/), which stores the HTML on S3 and uses JavaScript to pull it in dynamically.

By the way, the other replies to this comment refer to Mark Bates's Conquering the Command Line [1], which is a completely different product.

[1]: http://conqueringthecommandline.com/book

[+] kazinator|10 years ago|reply
Maybe whip up some curl commands in a command line, post-processed with sed and awk.

I enabled JS from a couple of domains, then gave up and backbuttoned out.

[+] 101914|10 years ago|reply
Use the command line to get the URLs for each chapter?

  Go to conqueringthecommandline.com/book
  Save the page source
  Insert the filename into the script below
  Alternatively, omit filename and pipe the source of the page to the script 

  Works with BSD sed as well as GNU sed; first lesson: portability

   a=$(printf '\004')
   sed 's/s3_url/'"$a"'&/' \
   |tr '\004' '\012' \
   |exec sed '
   s/\\u0026/\&/g;
   s/.*s3_url.:.//g;
   s/\".*//g;
   /https:.*Amz/!d;
   ' filename
I do not recommend this "book". Look at the hoops they make readers jump through. Try grymoire.com; much better and no Javascript required
[+] unknown|10 years ago|reply

[deleted]

[+] mhartl|10 years ago|reply
Who is this book for if not for programmers?

As noted in the introduction, it's aimed at complete beginners:

[T]his tutorial is aimed at complete beginners, so it assumes no prerequisites other than general computer knowledge (how to launch an application, how to use a web browser, etc.). Among other things, it doesn’t assume you know how to use a text editor (or even what that is), and as far I as know Learn Enough™ Command Line to Be Dangerous is unique in this respect. Indeed, this tutorial doesn’t even assume you know what a command line is, so if you’re confused about the title, you’re still in the right place.

[+] dcgoss|10 years ago|reply
Have you ever considered that not everyone emerges from the womb with detailed knowledge of the command line? Obviously this isn't meant for seasoned veterans, but if you're learning/new and have no idea what you're doing this could be a big help.