Intro to the Command Line

Decide to be awesome. 7 October 2010. Baltimore Node.

Intro to the Command Line

Introduction

Principles

Basic Commands

Essentials

System Information Commands

File & Directory Commands

Input / Output Commands

Communication

Processes

Other Stuff

Tools

Programming Languages

Using the Terminal

Save on typing

BONUS: Pretty it up

BONUS: Scripting

Further Reading

Introduction

For the novice, commands-line interface commands can appear daunting:

sudo gobbledegook blah_blah -w -t -f

aWkward/ComBinationOf/mixedCase/underscores_strokes/and.dots

However, it is important to note that even experienced users often cut and paste commands (from a guide or manual) into the command-line terminal; they do not memorize them.

It is important, of course, to know how to use the command-line terminal - and anyone who can manage typing, backspacing, and cutting and pasting can manage the command-line terminal (it is not more difficult than that).

from “Using The Terminal” - https://help.ubuntu.com/community/UsingTheTerminal

Principles

Basic Commands

Essentials

man

sudo

locate

System Information Commands

du -s

ifconfig

whereis

which

File & Directory Commands

cd

cp [-Rv]

ln [-s]

ls [-alsh]

mkdir [-p]

mv

pwd

rm [-rf]

Input / Output Commands

streams: 2>&1, >, >>, <, |

$()

cat

echo

grep

head

less

more

tail

wc

Communication

curl

ping

rsync

scp

sftp

ssh

wget

Processes

&

Ctrl-z

disown

bg

fg

jobs

ps

ps aux

top

Other Stuff

Tools

nano

vim

emacs

screen

Programming Languages

Ruby

Python

Perl

Using the Terminal

Save on typing

BONUS: Pretty it up

Colors! Start with \e[ then a color code (40's for backgrounds, 30's for foregrounds, mix it up with ;'s), then the letter m. Return to default with \e[0m.

For example:

echo -e "\e[41m\t\e[47m\t\e[44m\t\e[40;33m\tTHESE COLORS DON'T RUN\e[0m"

Copy and paste that fine fellow and absorb an eyeful.

BONUS: Scripting

This is way too deep for a "finding your way around" class. Besides, you should use Ruby (or Python or Perl) if it's anything complex. Seriously, Bash is good for one liners, but if you’re going to have to maintain it, unless you have compelling reasons to the contrary, use a “real” scripting language. Preferably an object oriented one with a healthy standard library.

Ruby - http://mislav.uniqpath.com/poignant-guide/

Python - http://learnpythonthehardway.org/index

Perl - http://perldoc.perl.org/perlintro.html

Further Reading

“Introduction to Command Line Linux” - http://www.physics.ubc.ca/mbelab/computer/linux-intro/html/index.html

“Advanced Bash Scripting” - http://tldp.org/LDP/abs/html/index.html

“In the Beginning was the Command Line” - http://www.cryptonomicon.com/beginning.html

This is Creative Commons Licensed. http://creativecommons.org/licenses/by-nc/3.0/