Many students don’t know how to use the basics of the command line interface, and it was getting in the way of their learning. This book is designed to be something they can complete in about a day to a week and then get enough skill at the command line to graduate to other books.
This book isn’t a book about master wizardry system administration. It’s just a quick introduction to get newbies going.
This book is a crash course in using the command line to make your computer perform tasks. As a crash course, it’s not as detailed or extensive as my other books. It is simply designed to get you barely capable enough to start using your computer like a real programmer does. When you’re done with this book, you will be able to give most of the basic commands that every shell user touches every day. You’ll understand the basics of directories and a few other concepts.
The only piece of advice is this:
Shut up and type all of this in.
Sorry to be mean, but that’s what you have to do. If you have an irrational fear of the command line, the only way to conquer an irrational fear is to just shut up and fight through it.
You are not going to destroy your computer. You are not going to be thrown into some jail at the bottom of Microsoft’s Redmond campus. Your friends won’t laugh at you for being a nerd. Simply ignore any stupid weird reasons you have for fearing the command line.
Why? Because if you want to learn to code, then you must learn this. Programming languages are advanced ways to control your computer with language. The command line is the baby little brother of programming languages. Learning the command line teaches you to control the computer using language. Once you get past that, you can then move on to writing code and feeling like you actually own the hunk of metal you just bought.
The best way to use this book is to do the following:
Just keep going through this process of doing an exercise, writing down questions you have, then going back through and answering the questions you can. By the time you’re done, you’ll actually know a lot more than you think about using the command line.
I’m warning you ahead of time that I’m going to make you memorize things right away. This is the quickest way to get you capable at something, but for some people memorization is painful. Just fight through it and do it anyway. Memorization is an important skill in learning things, so you should get over your fear of it.
Here’s how you memorize things:
There’s other techniques, like you can write what you need to learn on a sheet of paper, laminate it, then stick it to the wall of your shower. While you’re bathing drill the knowledge without looking, and when you get stuck glance at it to refresh your memory.
If you do this every day, you should be able to memorize most things I tell you to memorize in about a week to a month. Once you do, nearly everything else becomes easier and intuitive, which is the purpose of memorization. It’s not to teach you abstract concepts, but rather to ingrain the basics so that they are intuitive and you don’t have to think about them. Once you’ve memorized these basics they stop being speed bumps preventing you from learning more advanced abstract concepts.
I (Zed A. Shaw) own the copyright on this book. You are free to give it to anyone you want, as long as you don’t modify it and you don’t make any money from the distribution of the book.
In this book you will be instructed to do three things:
For this first exercise you’ll be expected to get your Terminal open and working so that you can do the rest of the book.
Get your terminal, shell, PowerShell working so you can access it quickly and know that it works.
For Mac OSX you’ll need to do this:
Now you have your Terminal open and it’s in your Dock so you can get to it.
I’m assuming that if you have Linux then you already know how to get at your terminal. Look through the menu for your window manager for anything named “Shell” or “Terminal”.
On Windows we’re going to use PowerShell. People used to work with a program called cmd.exe, but it’s not nearly as usable as PowerShell. If you have Windows 7 or later, do this:
If you don’t have Windows 7, you should seriously consider upgrading. If you still insist on not upgrading then you can try installing ithttp://www.microsoft.com/download/en/details.aspx?displaylang=en&id=16818 . You are on your own, though, since I don’t have Windows XP, but hopefully the PowerShell experience is the same.
You learned how to get your terminal open so you can do the rest of this book.
If you have that really smart friend who already knows Linux, ignore them when they tell you to use something other than bash. I’m teaching you bash. That’s it. They will claim that zsh will give you 30 more IQ points and win you millions in the stock market. Ignore them. Your goal is to get capable enough and at this level it doesn’t matter which shell you use.
The next warning is stay off IRC or other places where “hackers” hang out. They think it’s funny to hand you commands that can destroy your computer. The command rm -rf / is a classic that you must never type. Just avoid them. If you need help, make sure you get it from someone you trust and not from random idiots on the internet.
This exercise has a large “do more” part. The other exercises are not as involved as this one, but I’m having you prime your brain for the rest of the book by doing some memorization. Just trust me, this will make things silky smooth later on.
Take this list of commands and create index cards with the names on the left on one side, and the definitions on the other side. Drill them every day while you do this book for just 15 minutes or so.
If you’re using Windows then here’s your list of commands:
Drill, drill, drill! Drill until you can say these phrases right away when you see that word. Then drill the inverse, so that you read the phrase and know what command will do that. You’re building your vocabulary by doing this, but don’t spend so much time you go nuts and get bored.