Lecture 2
Lecture 2
1
Lecture summary
• Course introduction and syllabus
2
Operating systems
• What is an OS? Why have one?
• What is a Kernel?
3
Operating systems
• operating system: Manages activities and resources of a computer.
software that acts as an interface between hardware and user
provides a layer of abstraction for application developers
4
Unix
• brief history:
Multics (1964) for mainframes
Unix (1969)
K&R
Linus Torvalds and Linux (1992)
Courtesy XKCD.com
6
Linux
• Linux: A kernel for a Unix-like operating system.
commonly seen/used today in servers, mobile/embedded devices, ...
8
Things you can do in Linux
• Load the course web site in a browser
• Play MP3s
• Edit photos
• IM, Skype
9
Shell
• shell: An interactive program that uses user input to manage the
execution of other programs.
A command processor, typically runs in a text window.
User types commands, the shell runs the commands
Several different shell programs exist:
• bash : the default shell program on most Linux/Unix systems
• We will use bash
• Other shells: Bourne, csh, tsch
10
Why use a shell?
• Why should I learn to use a shell when GUIs exist?
faster
work remotely
programmable
customizable
repeatable
11
Shell commands
command description
12
Relative directories
directory description
. the directory you are in ("working directory")
13
Directory commands
command description
ls list files in a directory
pwd print the current working directory
cd changes the working directory
mkdir create a new directory
rmdir delete a directory (must be empty)
14
Shell commands
• many accept arguments or parameters
example: cp (copy) accepts a source and destination file path
• for many commands that accept a file name argument, if you omit
the parameter, it will read from standard input (your keyboard)
16
Shell/system commands
command description
man or info get help on a command
clear clears out the output from the console
18
Mounting homedir on VM
•Create a directory in your home directory, called csehomedir:
cd
mkdir csehomedir
•Now to use that directory as a “link” to your CSE files on your VM:
sshfs username@attu: ~/csehomedir OR
sshfs [email protected]:/homes/iws/username ~/csehomedir/
•It is a good idea to back up your files from your VM regularly.
Actually keep your files on your CSE home directory
Regularly move files from your VM to another location
If you need to get a fresh VM image, you can save the files from your
old VM using this procedure: "My VM Seems Broken. How Do I Recover?"
19
My VM is Broken!
•If your VM is misbehaving, first try a reboot of the VM and also of
your machine. If that doesn’t work, often it is easiest just to get a
fresh VM image and start over (maybe you saved the .zip file you
downloaded previously?)
•BEFORE you delete your current copy of the VM, you can save the
files from your current copy of the VM using this procedure:
20
Exercise Solutions
• caution: the cp, rm, mv commands do not prompt for confirmation
easy to overwrite/delete a file; this setting can be overridden (how?)
• Use “-i” with the command, “interactive” to prompt before overwrite
• Exercise : Given several albums of .mp3 files all in one folder, move
them into separate folders by artist.
mkdir U2
mkdir PSY
mkdir JustinBieber
mv GangnamStyle.mp3 PSY/
mv Pride.mp3 U2/
21
Basic Emacs Commands
• C- = control key M- = meta/alt key
• read a file into Emacs: C-x C-f
• save a file back to disk: C-x C-s
• exit Emacs permanently: C-x C-c
• search forward: C-s search backward: C-r
• scroll to next screen: C-v scroll to previous screen: M-v
• Undo: C-x u
entity to move over backward forward
22
Basic Vim Commands
• :w Write the current file
• :wq Write the current file and exit.
• :q! Quit without writing
• To change into insert mode: i or a
Use escape to exit
• search forward /, repeat the search backwards: N
• Basic movement:
h l k j character left, right; line up, down (also arrow keys)
bw word/token left, right
ge e end of word/token left, right
0$ jump to first/last character on the line
• x delete
• u undo
23