Class Session: Wednesday Aug 29, 2018

Basics: Servers

Be sure to bring your laptop to this session.

Don't forget about making blog posts or other parts of your Value Added grade component.

Preparation for this Session

on servers

  1. How Web Servers Work by Marshall Brain, How Stuff Works
  2. In Web Design in a Nutshell , 3rd Edition, read parts of chapter 4, "A Beginner's Guide to the Server" Unix Directory Structures, p. 46 through File Naming Conventions, p. 50

glance over

top/reload prep panel

Server Links

linux emulator: This is pretend. Nothing you create here is saved. Refresh your browser and it will disappear.

Command Line Text Editing

Command Line Text editors let you edit text directly on the server; when you work on a file and save it, it is done. There is no need to upload it with an FTP program. So if you mess up a file online, it is messed up; There is no backup on your laptop. In some cases, this could make your entire web server go down, depending on what you are editing. So if you are editing an important system file that is on the server, you should first make a backup by using the cp command. For example: cp index.html index-bkup.html

These editors will work on the mac Terminal for the Mac System as well as Opal (linux). In other words, you can use terminal to edit your Mac System files, so make sure you don't get too ambitious too soon with your new linux skills. If you mess up something on opal, it's not a big deal; you don't have any system file permissions. If you mess up your Mac, you could really be in bad shape. However this is not likely if you stay in your Mac User Directory. The worst thing that you can do there is wipe out a lot of files with the rm -r remove command with the recursive flag.

The Windows command line editor is not linux, and it is not really DOS either, so you can't run linux commands on it.

To get some feel for linux capability on Windows, you can download gitbash for Windows, but it only has limited linux operability. If you want to try that, I know that it is not too difficult, because all of my Windows users in Fall 2017 set it up just fine. (I am not requiring it this semester because we are not using Carolina CloudApps for web hosting.) When installing, simply accept all of the default settings. This is totally optional.

It is possible to now install linux on Windows, but it is BETA mode, so don't take this on during this session of INLS 161 unless you are very motivated and technically comfortable with working with the Windows Command prompt. You will need to use the command line to set up Linux on Windows, and then, after setup, you could run Nano and Vim on Linux Subsystem for Windows. There is absolutely no reason to take this on for the purposes of this class.

Client Server Practice

rename hello.txt to by using the mv (move command)

Text Processing with awk

Below is a raw text file list of students listed by f_name, l_name, and then listed by fund-raising-collection totals for week one, two, three, and four.
See this file on my Google Docs Account

We will copy and paste this into a text file on the server using Nano, a command line text-editor. Then we will run a few awk text processing commands on the data and then demo some sorts. Sort(Unix) at Wikipedia

Bill Trumbell 56 56 56 67 
Sharon King 57 78 87 46 
Karen Spencer 69 34 459 37 
Sam Bostak 26 78 56 64 
Tommy Chan 36 4 86 45 
Sara Thompson 49 5 44 6 
Kim Jones 20 5 34 80 
Janet Smith 34 6 4 66 
JaeHo Lee 90 54 44 44 
Butch Williams 90 56 98 6 
Jeff Phillips 55 67 43 66 
Tammy Colsen 36 44 45 0 
Ben Stern 90 34 97 66 
Mala Kimbo 46 78 56 99 
Dan Swathmore 23 45 667 66 
Bruce Larsen 13 6 56 47 
Trudy Ruskin 90 25 24 6 
James Kenson 15 6 55 56 
Charles Donaldson 9 6 34 5 
Lewis Braun 245 67 45 5 
Clarence Arrens 98 32 55 34 
Jenna Hines 39 6 45 5 
George Davis 7 57 55 66 
Maria Lopez 24 86 58 55 
Terry George 23 56 34 12

How to follow along:

  1. Copy the text. Select only Bill through the 12 in the last row.
  2. Log into opal. You can do this in your home directory, so no need to cd.
  3. Type: nano students. This will launch the nano editor and create a file named students.
  4. Wait for me to demo how to use Nano. It does not work like a GUI text editor.
  5. After you paste the data and save the file, we can run some awk command on the data.

In unix/linux, space denote a new column. (It could be one space or 20 spaces.) Notice how JaeHo is not listed as Jae Ho, with a space. If we had a space (or spaces) between the name, we would not have well-structured columns.

In this first sample we are telling Linux we want to use the awk command and that we want to print out the second column of data in the students file. Obviously, this would not work had we not created a students file. Typing awk {'print $2'} and not designating a file will do nothing.

awk '{print $2}' students
awk '{print $2}' students | sort -k 1
awk '{print $2 ", " $1  ", " $3+$4+$5+$6}' students | sort -k 3rn

If you want to see how you can use awk to loop through a list of github users and generate a list of html links, you can go a bit deeper and check out this awk example on the class blog.

Sometimes, when you make a mistake, it will still work. Which one of these is the wrong syntax? (Compare them to the above examples.)

 1 awk '{print $1}' students


 2 awk {'print $1'} students 

Example 1 is correct syntax for awk; example 2 is wrong, but it works. So what's going on here?

The reason why both of these will work is because awk is a weakly typed language. Weakly typed languages are more forgiving. See this article on strong and weak typing.

Markdown Editors

Learning Markdown is very easy. Spend some time here:

Editor I use on my PC laptop :

If you install this app, it will not install in your Apps folder. If you want to click on a .md file and have it open with Mark Down Edit, click on a .md file and when prompted to set up an app, navigate to the app in this directory:


Other PC options I have tried:


  • MacDown (This is the Markdown editor I use on my laptop.)
  • Typora

Create multiple files with Curly Braces Magic

Quick links

opal login: ssh
opal password: ONYEN password


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Office hours by appointment.