intro to unix for smart people part ii

26
Intro to Unix for Smart People Part II Joe Morrison, Lab49

Upload: yepa

Post on 07-Jan-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Intro to Unix for Smart People Part II. Joe Morrison, Lab49. Unix graphics architecture. The X Window System Or simply X But not “X Windows”. X Window System Architecture. Cut and paste in X. Open protocol (ICCCM) When user does a CUT - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Intro to Unix for Smart People Part II

Intro to Unix for Smart People Part II

Joe Morrison, Lab49

Page 2: Intro to Unix for Smart People Part II

Unix graphics architecture

The X Window System Or simply X But not “X Windows”

Page 3: Intro to Unix for Smart People Part II

X Window System Architecture

Page 4: Intro to Unix for Smart People Part II

Cut and paste in X Open protocol (ICCCM) When user does a CUT

App sends a message to X: My Window now owns selection PRIMARY When user does a PASTE

App sends a message to X: Please paste selection PRIMARY into my attribute foo

X sends owning app a SelectionRequest event Owning app sends a ChangeProperty request to X to push data Owning app sends a SelectNotify request to X to forward to requestor Requestor can now read the data by sending X a GetProperty request

Benefits Works cleanly with apps and X server on different network nodes Allows format negotiation Works even if apps cannot communicate with each other directly Allows interesting enhancements (xclipboard app can watch for events

and take long-term ownership of selected items)

Page 5: Intro to Unix for Smart People Part II

Display manager – simple scenario

Simple scenario – one computer with graphics capability Display manager runs first Starts X server Runs a graphical “login” program Graphical equivalent of “getty”

Page 6: Intro to Unix for Smart People Part II

Display manager – simple scenario

init (pid = 1)

/etc/inittab

xdm

xlogin

User-specified X apps to start (xterm, etc.)

fork/exec(respawn)

wait for X server to start

exec

Start other required processes

startxfork/exec

display login /password prompt

Pretend this is an X terminal

xdm plays same role as getty (but graphical)

Page 7: Intro to Unix for Smart People Part II

Display manager – complex scenario

More complex scenario – multiple X terminals, one host X terminal broadcasts “manage me!” Display manager responds by forking a

process to run graphical “login” over the network

Graphical equivalent of telnet daemon Support hordes of developers with dumb

terminals and one giant server

Page 8: Intro to Unix for Smart People Part II

Display manager – complex scenario

xdm listenerBroadcast:Can someonemanage me?

for each request,fork/exec xlogin

display login /password prompt

xlogin

User-specified X apps to start (xterm, etc.)

exec

xdm plays same role as telnetd (but graphical)

Page 9: Intro to Unix for Smart People Part II

Other scenarios Multiple hosts, each running xdm

Poor man’s load balancing Large group of X terminals serviced by a small

number of hosts Each X terminal is managed by whichever xdm

answers first (usually the least loaded) INDIRECT mode

X terminals do not broadcast Instead they contact a primary xdm Primary xdm delegates to secondary xdm

according to desired configuration

Page 10: Intro to Unix for Smart People Part II

Window managers Ordinary processes running in background Register with X server to receive notifications when

applications start, open windows, etc. Get to meddle

Relocate new application windows Draw ornamentation around windows (resize grips,

title bar) Handle visual interaction for resizing, moving,

minimizing, maximizing windows, etc. Send application resize/move instructions

Get to decide Start menu? Icons? Docks? Button bars?

Can be changed on the fly! You can write one!

Page 11: Intro to Unix for Smart People Part II

twm window manager (the original!)

Page 12: Intro to Unix for Smart People Part II

IceWM (themeable)

Page 13: Intro to Unix for Smart People Part II

Metacity desktop (Ubuntu)

Page 14: Intro to Unix for Smart People Part II

Session managers

Responsible for saving/restoring application state

Standard protocol for communication between window manager and session manager

Enables window manager to offer services like “logout and save session”

Page 15: Intro to Unix for Smart People Part II

Unix desktop =

Display manager + Window manager + Session manager

Page 16: Intro to Unix for Smart People Part II

SSH (poor man’s VPN)

Secure replacement for telnet Also – port forwarding

ssh -l 1234:10.0.0.7:80 rasputin.lab49.com

RASPUTINEncrypted communication (compressed too!)

ssh client – in addition totelnet session – acceptsconnections on port 1234

ssh server – in additionto telnet daemon – relaysclient port 1234 toport 80 on 10.0.0.7

10.0.0.7

ssh provides a secure, encrypted TCP/IP proxyto any computer reachable from the ssh server

Page 17: Intro to Unix for Smart People Part II

X over SSH If you can SSH to a Unix machine, you can run

any X application on that machine and have it display on yours (regardless of firewalls)

ssh -X rasputin.lab49.com

RASPUTINEncrypted communication (compressed too!)

ssh client – in addition totelnet session – acts as aproxy X client for all appsstarted on Rasputin

ssh server – in additionto telnet daemon – createsa fake local X server andsets it to be the default;requests are encrypted,compressed, and tunnelledback to the client

Page 18: Intro to Unix for Smart People Part II

Package management with RPM(Redhat Package Manager) Both a Unix app (manages all installed packages) and a file format Maintains a database of installed apps

Knows which RPM each file belongs to Knows what the md5sum of each file should be

To install an application rpm –ivh myapp-1.3.2.i386.rpm Checks dependencies, installs all files, runs postinstall scripts, etc.

To remove rpm –e myapp The RPM system remembers which files belong to myapp – always removes cleanly Application does not need to cooperate (badly written app cannot screw up RPM) Removing an application never results in a different application being uninstallable

To list files in an RPM rpm –ql myapp

To get general info about an RPM rpm –qi myapp

To find out which RPM owns a particular file rpm –qf /usr/bin/emacs

To check whether an application has been damaged rpm –qV myapp

Page 19: Intro to Unix for Smart People Part II

Package management with APT (Advanced Package Tool) Rather than operating on individual files,

APT is based on repositories so it knows about all packages and their dependencies

Like RPM but more holistic view of your system

If you install an RPM and don’t include all necessary dependencies, it will refuse to install

But if you install using APT, it will quietly install everything needed

Page 20: Intro to Unix for Smart People Part II

Package management with YUM (Yellowdog Updater Modified)

Provides an APT-like experience on top of RPM

Page 21: Intro to Unix for Smart People Part II

About /proc The /proc pseudo filesystem is a real time, memory resident

file system that tracks the processes running on your machine and the state of your system

The contents of the /proc filesystem areused by many utilities which grab the data from the particular /proc directory and display it

You can also write to the /proc filesystem, e.g. writing to the /proc/sys directory enables you to change kernel parameters echo 1 > /proc/sys/net/ipv4/ip_forward

Examples cat /proc/vmstat cat /proc/1234/cmdline cat /proc/meminfo

The contents of /proc need to be standardized – too many utilities count on the format of /proc files

Page 22: Intro to Unix for Smart People Part II

/proc/vmstat

nr_dirty 8nr_writeback 0nr_unstable 0nr_page_table_pages 1040nr_mapped 53684nr_slab 11199pgpgin 1436240pgpgout 29582742pswpin 23pswpout 40pgalloc_high 2789161pgalloc_normal 53175006pgalloc_dma 11pgfree 56056660…

Page 23: Intro to Unix for Smart People Part II

The comforts of home Xscreensaver XMMS (like Winamp) Xine / MPlayer (play videos) GRIP (rip CDs) Mozilla/Firefox/Opera Emacs Eclipse VNC (remote desktop)

Page 24: Intro to Unix for Smart People Part II

Closing thoughts In general Unix desktops are primitive compared to

other popular operating systems (NeXT and Mac being notable exceptions)

But it’s not just about features, ease of use, and stability (This better be good)

It’s also about internal interfaces Make OS reusable in more contexts Create a breeding ground for improvements

For example Accessibility (rewrite the window manager) Embedded systems (replace /etc/inittab)

Page 25: Intro to Unix for Smart People Part II

Unix versus Windows

Windows: Best platform for creating end-user applications

Unix: Best set of building blocks for general purpose, secure, multi-user, multi-process computing

Page 26: Intro to Unix for Smart People Part II

Final closing thoughts (really)

Windows Intelligent design

Unix Mutation and natural selection