Skip to content

Commit

Permalink
initial commit for command line tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
dwbond committed Jan 15, 2013
0 parents commit a547d41
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
59 changes: 59 additions & 0 deletions 000-Introduction
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
THE COMMAND LINE
Or How I Wished I Had Learned Everything

Chapter One: Help! Where Am I?
- cd and ls
- less
- [[the ones that show information about your system]]
- a guided tour of Linux
Chapter Two: Commands
- date, cal, ping
- whatis, man
- how commands work
- type, which, file?
- wildcards
- the terminal
Chapter Three: Folders and Files
- mkdir, cp, mv, and rm
- links (ln)
Chapter Four: The Terminal
- wtf is this bullshit? and echo
Chapter Four: Programs and Programming
- opening a program
- programming--
- alias
Chapter Five: Networking

Chapter Six: I/O

Chapter Seven: Pipe Dreams

Chapter Eight:

Chapter Nine:

Chapter Ten:

And... this kind of stops with my knowledge of things...
for the rest of it $man bash

For most, program windows, clicking, and icons have been your entire experience with computers. (In technical terms, the is a "graphical interface".) Sure, you know of the command line, but it's a realm only for computer geniuses, the "hackers" of movies you've seen.

But the command line is not something that you should fear. As with any area, there are many levels of skill, but a basic understanding is within the grasp of most computer users. With it, not only will you be able to better understand how your computer works, but it's also far more powerful than anything you can do with your mouse.

The point of a graphical interface is to make computers less intimidating to first time and lay users. But that is not you! You are interested in the "behind the scenes" workings of the machines so vital to much of your life.

If you are a Windows user,

(it&e link)

If you are a Mac user, you're already set. Just open a terminal session (the command line interface) and type in ssh [email protected]

(it&e link)

If you're using Linux, you're all set to go. Open a terminal program of your choice.

For the moment, just copy verbatim. We will explore what the meaning of what you're typing further along.

A INTRODUCTION TO LINUX

53 changes: 53 additions & 0 deletions 001-Help-Where-Am-I
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
WHERE AM I?-- THE HOME DIRECTORY

Before you, you'll see your username, an at sign, and the name of the machine or server, here "mason.gmu.edu".

**note! this is not the server you're looking for-- change it to the correct one**

Then there will be a colon, a twiddle, and a dollar sign, followed by a flashing cursor.

Where am I? You're in your 'home directory', the section of the machine or server created escpecially for your username, here signified by the twiddle. All of your files are in the home directory. "Directory" is the more technical word we're going to use for "folder". Now how are you supposed to be able to see what's in your home directory?

At the command prompt, type "ls", an abbreviation for "list". Press enter.

Now you can see the files and folders in your directory. If you just see the command line come up again, it means your directory is empty. Folders are usually bolded, while files are usually normal text.

GETTING AROUND

Now to move around. You can't click on the listed folders to open them, so to move around, we're going to type "cd _FolderName_". "cd" is an abbreviation of "change directory".

How do I now move back? There are two different ways you can move around. In the example abovce, we made use of a "relative pathname". We were in one directory, and we moved to another directory inside. Another way of moving around is with an "absolute pathname", pointing the computer to the exact location of the directory we're looking for, from the very beginning, for example "cd ~/Documents/School/Fall2012/". With relative pathways, it's slightly less straightforward.

All directories have two hidden links, '.' and '..'. '.' is a reference to itself. You can see this by typing "cd .". ".." is a reference to the directory above the current one. Think of all of your directories like a huge upside-down tree. We begin at our home directory, (or even earlier, as we will get to shortly) and then proceed down through all the folders. '..' points to the directory immediately preceeding the current one. To go back one directory, we can type "cd ..". Note that we can go even further back by selecting the previous directory's link to the previous directory as well. For instance, imagining our current filesystem, after going via absolute pathway to "Fall2012", we could type "cd ../../ to get back to "Documents".

How do I know whether to use an absolute pathname or a relative pathname when navigating around? Use either, whichever one is shorter. Or, as a further shortcut, "cd" just by itself will return you to your home directory.

LESS IS MORE

There's an easy way to take a look at a file in the terminal without having to open it. You can use the command "less" to print out the whole thing right away. For example, if we had a file "text.html" in one of our directories, we could type "less text.html" and we'd see the entire contents of the file immediately in the terminal.

We learned in the introduction about what separates Linux as an operating system from Windows or any of Apple's, earlier in this chapter made reference to a level before the home directory. Let's go there now, and take a look. Type "cd /"

ROOT

Take a look at where you are by typing "ls". You'll see several directories; let's take a look at a couple of some of the most interesting.

bin/

boot/

dev/

etc/

home/

lib/

media/

root/

sys/

var/
35 changes: 35 additions & 0 deletions 002-Commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
COMMANDS

In the previous chapter, we started typing in the command line without really explaining what we were doing, only looking at the effects. While this was useful to get our bearings and see where we were, let's go back and take a closer look at commands.

Type some random mismash of characters into the command line. What do you see?

"command not found"

Just like a graphical interface, the command line accepts a number of commands, except solely through keyboard input. We learned "ls" and "cd" in the prior chapter to navigate around, but let's now begin learning some more useful commands, and start to explore how the terminal works.

A quick word on entering and editing commands. The terminal will remember your previous entires, so seeing what you've previously typed is as simple as pressing the up arrow to go back in history, and the down arrow to go forward. Use the left and right arrow keys to respectively move left and right on the line. The "home" and "end" keys will move the cursor to the beginning or end of the line.

It's important to note that ctrl+c, ctrl+x, and ctrl+v DO NOT mean copy, cut, and paste. Modern operating systems have changed their original meanings from the early days of computing which are still maintained here. If you want to copy, cut, or paste something in or to the command line, use the shift key as well. (ctrl+shift+c, etc)

One of the simplest commands is "date", returning the current date. Also try "cal", a neat little command that prints out a calendar of the current month, with the current day highlighted. "ping" can help you determine if you're connected to the internet; type "ping [website]" and see if packets of data are being fetched. After a few moments, ping will stop running and give a final diagnostic.

"ping", as well as "cd" earlier, demonstrate the structure of commands

date
cal
ping
whatis
man

man cal

man ls
ls -a
ls -l

how commands work

type
which
wildcards
5 changes: 5 additions & 0 deletions 003-Directories-and-Files
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdir
cp
mv
rm
ln
1 change: 1 addition & 0 deletions 004-The-Terminal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo, maybe?

0 comments on commit a547d41

Please sign in to comment.