Top Banner
LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23
55

LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Mar 27, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

LIS651 lecture 5origins of wotan

direct use of wotan

Thomas Krichel

2008-11-23

Page 2: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Early Computing History

• In the 1940s and 1950s, all computers were personal computers in the sense that a user would sign up to use the machine and then take over the whole machine for that period.

• The early 1960s were dominated by batch systems in which a user would submit a job on punched cards and wait, usually hours, before any printed output appeared.

Page 3: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Early Computing History

• To get around this unproductive environment, the concept of timesharing was invented by Dartmouth College and M.I.T.

• The M.I.T system CTSS (Compatible Time Sharing System) was an enormous success.

• M.I.T., Bell Labs, and General Electric created a second generation timesharing system named MULTICS (Multiplexed Information and Computing Service).

Page 4: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Early UNIX History

• At Bell Labs, Ken Thompson decided to write a stripped down version of MULTICS for the very small PDP-7 minicomputer which he called UNICS.

• Dennis Ritchie, also at Bell Labs, joined Thompson in further developments of what was now called UNIX.

• Together they ported the system the the larger and very popular PDP-11/20 and PDP-11/45 minicomputers.

Page 5: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Early UNIX History

• In 1974, Ritchie and Thompson published a paper about UNIX and received the prestigious ACM Turing Award.

• This publication stimulated many universities to request a copies of UNIX.

• Since Bell Labs, part of AT&T, was not allowed to be in the computer business, it licensed UNIX to universities.

• Result: UNIX was a hit on campus.

Page 6: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

UNIX Structure• The kernel is the core of the UNIX system,

controlling the system hardware and performing various low-level functions. The other parts of the UNIX system, as well as user programs, call on the kernel to perform services for them.

• The shell is the command interpreter for the UNIX system. The shell accepts user commands and is responsible for seeing that they are carried out.

Page 7: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

BSD UNIX

• One of the many universities that had received license for UNIX was the University of California at Berkeley.

• Aided by many government grants, Berkeley released an improved version named 1BSD (First Berkeley Software Distribution)

• BSD added many new features including a new visual editor (vi) and a new shell (csh).

Page 8: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Two UNIX Versions

• Because of these and other enhancements, many companies based their UNIX on Berkeley’s version as opposed to AT&T’s so-called System V.

• By the late 1980s, two different and somewhat incompatible versions of UNIX were in widespread use: 4.3 BSD and System V release 3.

Page 9: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

UNIX Standards

• In addition, every vendor added its own nonstandard enhancements.

• In an attempt to unify the troops, the IEEE Standards Board undertook the POSIX Project (POS for Portable Operating System) and IX to make it UNIX like.

• POSIX 1003.1 emerged as a common ground standard.

• 1003.1 is the intersection of System V and BSD. (a feature had to be on both to be included in the standard)

Page 10: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

GNU

• GNU is a project started by Richard M. Stallman (RMS) to write a completely free implementation of Unix available.

• GNU stands for “GNU is not Unix”• Most of Unix has been rewritten by him and

his friends. • Many other software packages have been

released for free. Stallman pioneered a particular concept of free software.

Page 11: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

free software according to RMS• Free software comes with four freedoms

– The freedom to run the software, for any purpose

– The freedom to study how the program works, and adapt it to your needs

– The freedom to redistribute copies so you can help your neighbor

– The freedom to improve the program, and release your improvements to the public, so that the whole community benefits

Page 12: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

the GNU public license

• Richard M. Stallman created the GNU public license.

• The license restricts the right of software users to add restrictions on the use of derivative products.

• The idea is that when you get free software, you can not restrict the freedom of users of derivative software.

Page 13: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

UNIX-like Systems• MINIX, by Andrew Tanenbaum, used a

microkernel design with only 1600 lines of C and 800 lines of assembler in its first version.

• In 1991, a Finnish student named Linus Torvalds released another UNIX clone named Linux. It is a UNIX kernel for Intel processors.

• FreeBSD is a competitor to Linux, started in 1993.

Page 14: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Linux

• Linux is a monolithic UNIX kernel.• Linux quickly grew in size and functionality. • Version 1, shipped in 1994, contained about

165,000 lines of code. • Version 2 in 1996 contained about 470,00 lines

of C and 8000 lines of assembler.• Linux is released under the GNU public license,

which, very basically means that anyone can copy and change it.

Page 15: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Linux Distributions

• Linux itself is free. It is aggregated with installation and management tools, and many other software packages, and made available for a small fee by various vendors on CD.

• These aggregates are known as distributions.

• The one used by wotan is called Debian. It packages Linux with GNU software almost excusively.

Page 16: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

communication with wotan

• For file editing and manipulation, we use putty.

• For file transfer, we use winscp.• Both are available on the web. • The protocol is ssh, the secure shell, based

public-key cryptography.

Page 17: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

installing putty

• Go to your favorite search engine to search for putty.

• If you have administrator rights install the installer version.

• Since you have already installed winscp, you should have no further problems.

Page 18: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

putty options

• In the window/translation choose UTF-8, always.

• Find out what the size of your screen is of screen that your are using for the font that you are using, and save that in your session.

• For wotan, the port is 22, ssh.• You can choose to disable the annoying

bell.

Page 19: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Diffie and Hellman (1978)

• Let P be the plaintext, C be the cyphertext. E() is the encryption key and D() is the decryption key.

• Then we have public key cryptography if– 1. D(E(P))=P– 2. D() can not be broken by chosen plaintext attack.– 3. Knowing E() will give you no clue about D().

• E() can then be made public and is referred to as the public key, D() is the private key.

• It is possible to find key pairs that have these properties.

Page 20: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

Authentication

• I want to securely login to a host machine. • I send the hast an encrypted message ``hey, I am

Thomas, my public key is 7ni820g=0...''• Machine then knows how to send me messages

that other people can not decode.• But it can not be sure that it was me who sent the

message. An intruder may have done that since me public key is public.

• This problem is solved by challenge/response

Page 21: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

challenge/response

• To find out if I am the person that I claim to be, the machine encodes a random number, and challenges me to decode that number.

• If I can decode the challenge, I must be the person whom I claim I am.

Page 22: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

key creation

• “ssh-keygen” is the command to use to create a key. Answer all questions with the <ENTER> key.

• “cd .ssh” and “ls -l” shows you the contents of the directory .ssh created in the first step.

• The file “id_rsa.pub” has your public key.

Page 23: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

authorized_keys

• In .ssh, you can maintain a file “authorized_keys” that contains the public keys of all users you authorize to access the account, one line per user.

• “cp id_rsa.pub authorized_keys” will authorize yourself. Then “ssh user@wotan” will allow you to login again as you on wotan.

• You can also create a public key with putty.

Page 24: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

issuing commands

• While you are logged in, you talk to the computer by issuing commands.

• Your commands are read by command line interpreter.

• The command line interpreter is called a shell.

• You are using the Bourne Again Shell, bash.

Page 25: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

bash features

• bash allows to browse the command history with the up/down arrow keys.

• bash allows to edit commands with the left/right arrow keys.

• You can complete command and file names with <TAB>.

• bash comes with a language of commands that allows to write batch files.

• “exit” is the command to leave the shell.

Page 26: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

environment variables

• These are variables used by the shell. • Two important ones are

– $HOME your home directory– $PATH the location where bash will search for

executable files.

• echo $HOME will show you your home directory.

• “env” is a command that can be used to see all environment variables.

Page 27: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

environment variables and PHP

• All environment variables can be accessed with $_ENV{'env'} in PHP, where env in the name of the environment variable.

• Example$home=$_ENV{'HOME'};

print "my home is $home.</br>";

Page 28: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

bash initialization

• Files that start with a dot are hidden. They are only seen with “ls -a”.

• .bashrc is a file written in bash language that is run every time bash is started.

• .bash_profile or .profile is run when the shell is started at login.

• You can customize these files.

Page 29: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

files, directories and links

• Files are continuous chunks data on disks that are required for software applications.

• Directories are files that contain other files. Microsoft calls them folders.

• In UNIX, the directory separator is “/”• The top directory is “/” on its own.

Page 30: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

home directory

• When you first log in to wotan you are placed in your home directory /home/username

• “cd” is the command that gets you back to the home directory.

• The home directory is also abbreviated as “~“• cd ~user gets you to the home of user user.• “cd ~” does what?

Page 31: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

~/public_html

• Is your web directory. I created it with “mkdir public_html” in your home directory.

• The web server on wotan will map requests to http://wotan.liu.edu/~user to show the file ~user/public_html/index.html

• The web server will map requests to http://wotan.liu.edu/~user/file to show the file ~user/public_html/file

• The server will do this by virtue of a configuration option.

Page 32: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

changing directory, listing files

• cd directory changes into the directory directory

• the current directory is “.”• its parent directory is “..”• ls lists files

Page 33: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

users and groups

• “root” is the user name of the superuser.• The superuser has all privileges.• There are other physical users, i.e. persons

using the machine• There are users that are virtual, usually

created to run a daemon. For example, the web sever in run by a user www-data.

• Arbitrary users can be put together in groups.

Page 34: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

reason to run things on wotan

• When your run PHP files as a web user, the web server runs the PHP file.

• The web server runs as a special user, often called www-data.

• This user is not allowed to create files.• Since file creation and manipulation is the

essence of digital librarianship, we need to run directly on the machine.

Page 35: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

permission model

• Permission of files are given– to the owner of the file– to the group of the file– and to the rest of the world

• A group is a grouping of users. Unix allows to define any number of groups and make users a member of it.

• The rest of the world are all other users who have access to the system. That includes www-data!

Page 36: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

listing files

• “ls” lists files• “ls -l” make a long listing. It contains

– elementary type and permissions (see next slide)

– owner– group– size– date – name

Page 37: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

first element in ls -l• Type indicator

– d means directory– l means link– - means ordinary file

• 3 letters for permission of owner• 3 letters for permission of group• 3 letters for permission of rest of the world• r means read, w means write, x means

execute• Directories need to be executable to get in

them.

Page 38: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

change permission: chmod

• usage: chmod permission file• file is a file• permission is three numbers, first for

owner, 2nd for group and 3rd rest of the world.

• Each number is sum of – 4 for read - 2 for write– 1 for execute - 0 for no permission

• Example: chmod 764 file

Page 39: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

general structure of commands

• commandname –flag --option• Where commandname is a name of a

command• flag can be a letter• Several letters set several flags at the same

time• An option can also be expressed with - -

and a word, this is more user-friendly than flags.

Page 40: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

example command: ls

• ls lists files• ls -l makes a long listing• ls -a lists all files, not only regular files but

some hidden files as well– all files that start with a dot are hidden

• ls -la lists all files is long listing • ls --all is the same as ls -a. --all is known as

a long listing.

Page 41: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

copying and removing files

• cp file copyfile copies file file to file copyfile. If copyfile is a directory, it copies into the directory.

• mv file movedfile moves file file to file movedfile. If movedfile is a directory, it moves into the directory.

• rm file removes file, there is no recycling bin!!

Page 42: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

directories and files

• mkdir directory makes a directory• rmdir directory removes an empty directory• rm -r directory removes a directory and all

its files• more file

–Pages contents of file, no way back• less file

–Pages contents of file, “u” to go back, “q” to quit

Page 43: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

soft links

• A link is a file that contain the address of another file. Microsoft call it a shortcut.

• A soft link can be created with the command

• ln -s file link_to_file where file is a file that is already there and link_to_file is the link.

Page 44: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

file transfer• You can use winscp to upload and

download files to wotan. • If uploaded files in the web directory remain

invisible, that is most likely a problem with permission. Refer back to permissions.

• chmod 644 * will put it right for the files• chmod 755 . (yes with a dot) will put it

right for the current directory • * is a wildcard for all files.• rm -r * is a command to avoid.

Page 45: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

editing

• There are a plethora of editors available. • For the neophyte, nano works best. • nano file edits the file file.• nano -w switches off line wrapping.• nano shows the commands available at the

bottom of the screen. Note that ^letter, where letter is a letter, means pressing CONTROL and the letter letter at the same time.

Page 46: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

emacs

• This is another editor that is incredibly rich and complex.

• Written by Richard M. Stallman, of GNU and GPL fame.

• Get an emacs cheat sheet of the web before you start it. Or look at next slide.

Page 47: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

emacs commands

(here ^ stands for the control character)• ^x^s saves buffer• ^x^c exits emacs• ^g escapes out of a troublesome situation• control+space sets the mark• ^w removes until the mark (cut)• ^y pastes

Page 48: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

common emacs/bash commands

• ^k kills until the end of the line or removes empty line

• ^y yank what has been killed (paste)• ^a get to the beginning of the line• ^e get to the end of the line• These commands also work in the shell.

Page 49: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

emacs modes

• Just like people get into different moods, emacs gets into different modes.

• One mode that will split your pants is the PHP mode.

• “emacs file.php” to edit the file file.php in PHP mode.

• Then look how emacs checks for completion of parenthesis, braces, brackets, and the ; and use the tab character to indent.

Page 50: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

copy and paste• Putty allows to copy and paste text

between windows and wotan.• On the windows machine, it uses the

windows approach to copy and paste• On wotan machine,

– you copy by highlighting with the mouse’ left button

– you paste using the middle button– if you don't have a middle button, use left and

right together

Page 51: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

creating a PHP file• To run PHP, edit a file with a name ending

in .php (not required, but useful). Make the first lines.#!/usr/bin/php

<?php

/* PHP code goes here */

?>

• The first line less Unix that it has to use PHP to run this file. The correct path to the PHP executable has to be given.

Page 52: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

running a PHP file

• You must chmod it executable by you, e.g.chmod 755 my_file.php

• where my_file.php is the name of the PHP file.

• Then you can run. But you have to give it the full path../my_file.php

Page 53: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

running mySQL• You can run mySQL in command line mode

in wotan. Typemysql -u user -p

• You will then be prompted for your password. The username and password are your mySQL user name and mySQL password, not your wotan user name and wotan password.

• Don’t forget the semicolon after each command!

Page 54: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

login to SQL without password

• You can create a special file .my.cnf in your home directory. In there, write something like# this is a file $HOME/.my.cnf

[client]

user = username

password = password

Page 55: LIS651 lecture 5 origins of wotan direct use of wotan Thomas Krichel 2008-11-23.

http://openlib.org/home/krichel

Thank you for your attention!

Please switch off machines b4 leaving!