Linux Basics (Day 2)



Text Editors


Quick intro/history: ed editor Pros: low-bandwidth, installed pretty much everywhere, very fast and powerful for complicated and repetitive tasks Cons: Steep learning curve, different “modes” can be confusing at first Sublime and other desktop editors: nice for serious programming, but learn the basics of simple text editors even if you want to be a developer, you won't always be able to edit your code on your own desktop


Avoid Pico/Nano, Notepad++, SublimeText




Originally released 1976 name from Editor MACros for TECO editor, originally Tape Editor and COrrector at MIT in the '60s

But, along the way, I wrote a text editor, Emacs. The interesting idea about Emacs was that it had a programming language, and the user's editing commands would be written in that interpreted programming language, so that you could load new commands into your editor while you were editing. You could edit the programs you were using and then go on editing with them. -- Richard Stallman,




originally written for Amiga systems (Commodore PCs), 1988 vim released 1991 vimscript, Lua (as of Vim 7.3), Perl, Python, Racket, Ruby, Tcl (tool command language). vi written by Bill Joy in 1976, visual mode for line editor called ex line editors are from age of teleprinters, no cursors

How to choose



How to tell?

-- INSERT --                                          144,1    36%
-- VISUAL --                                          144,77   36%



Moving around in a file Search / replace Text manipulation, ie: cw, dw, c$, yy / p, x, .


Moving Around

h move one character to the left.
j move down one line.
k move up one line.
l move one character to the right.
0 move to the beginning of the line.
$ move to the end of the line.
w move forward one word.
b move backward one word.
G move to the end of the file.
gg move to the beginning of the file.
. move to the last edit.

Configuration / customization


there are many many options and pre-existing packages to make editing nice for sysadmins and developers

Some sets of Vim plugins and configurations are available

Use them for research on what's available to improve dev productivity

Learning Resources


Regular expressions

You should know basic substitution:


This is not shell globbing

Resources for learning:

Emacs Moving Around

C-f            forward one char (right)
C-b            backwards one char (left)
M-f            forward one word
M-b            backwards one word
C-n            forward one line (down)
C-p            backwards one line (up)
C-a            beginning of line
C-e            end of line
C-o            insert-newline and stay on current line
C-j            insert newline and indent
C-v            page down
M-v            page up
M-<            beginning of file
M->            end of file
M-g g <number> goto line <number>
C-s            forward search (C-s to keep searching)

Emacs Buffers

C-x b switch buffers (type a new name to open a new buffer)
C-x C-b list all buffers
C-x C-f find file (opens a new buffer for the file)
C-x k kill buffer
C-x 1 close all windows but the main one
C-x 2 split window horizontally
C-x 3 split window vertically
C-x o switch window

Emacs Modes

Major Modes

Minor Modes

Fun Emacs Magic

M-x eshell <RET> ;; yes, this gives a shell
M-x server-mode <RET> ;; and then use emacsclient
M-x compile ;; just "works" for most languages
M-x package-install ;; emacs has packages!

Emacs Cheat Sheet


Emacs Configuration

Emacs Resources

Editor questions?

$ vim testvim.txt            $ emacs testemacs.txt
<i>                          Hello world!
Hello world!                 <alt + x>
<esc>                        replace-regexp
:%s/[aeiou]//g               <enter>
<enter>                      [aeiou]
:wq                          <enter>
<enter>                      <ctrl + x> <ctrl + s>
                             <ctrl + x> <ctrl + c>




git, noun. Brit.informal. 1. an unpleasant or contemptible person.

Setting up Git

$ sudo yum install git
$ git config --global "My Name"
$ git config --global ""
$ git config --global core.editor "emacs"
$ git config --global push.default "current" # Or "nothing"

Using Git Locally

$ git init

$ git add <filename>

$ git commit -m "I did a thing!"


This initializes a git repo. Use man git-init for more info.

This puts <filename> into the staging area. It isn't committed yet. Use git diff to see what changes aren't yet in staging.

This actually makes the commit. Use git status to see what's in staging but not yet committed. Use git show or git log to see recent commits.

What Not To Do

Daily workflow


Pull -> Work -> Add changes -> Commit -> Push

Larger projects have more complex workflows


The picture is of the Git Flow branching model, and you'll probably see it every single time anyone explains Git branching and merging to you.


Ground Rules

Setting Up

You need:

SSH Key Generation

On OSX, Linux:

$ ssh-keygen -t rsa -b 4096

Make sure to add a passphrase.

On Windows, we will let openstack generate one for you during the process

Also see ssh_keys for more detailed instructions

Setting Up


UserName: ONID username Password: ID # (change this)

Changing your password

On Linux or OSX, install python-keystoneclient with pip:

$ pip install python-keystoneclient

Then use keystone to change your password:

$ keystone --os-username <username> --os-password <your id> \
  --os-auth-url \
  password-update --new-password <new password>

DO NOT Use a password you have used elsewhere

If you're using Windows, spin up a VM on Openstack, then follow the above instructions.

Setting Up


Setting Up


Next we need to set up a key pair. Click on Security (the page in this picture) and then on Key Pairs

Setting Up


Click on Import Key Pair if you already have an SSH key pair

Windows users click on Create Key Pair and download the private key

Setting Up


Setting Up


Setting Up


Setting Up


Setting Up


Setting Up