Title: Intro to Unix for Smart People Part II
1Intro to Unix for Smart People Part II
2Unix graphics architecture
- The X Window System
- Or simply X
- But not X Windows
3X Window System Architecture
4Cut 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)
5Display 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
6Display manager simple scenario
Pretend this is an X terminal
/etc/inittab
fork/exec
startx
xdm
fork/exec (respawn)
init (pid 1)
wait for X server to start
display login / password prompt
xlogin
exec
User-specified X apps to start (xterm, etc.)
Start other required processes
xdm plays same role as getty (but graphical)
7Display 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
8Display manager complex scenario
xdm plays same role as telnetd (but graphical)
Broadcast Can someone manage me?
xdm listener
for each request, fork/exec xlogin
xlogin
display login / password prompt
exec
User-specified X apps to start (xterm, etc.)
9Other scenarios
- Multiple hosts, each running xdm
- Poor mans 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
10Window 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!
11twm window manager (the original!)
12IceWM (themeable)
13Metacity desktop (Ubuntu)
14Session 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
15Unix desktop
- Display manager
- Window manager
- Session manager
16SSH (poor mans VPN)
- Secure replacement for telnet
- Also port forwarding
ssh -l 123410.0.0.780 rasputin.lab49.com
10.0.0.7
Encrypted communication (compressed too!)
RASPUTIN
ssh client in addition to telnet session
accepts connections on port 1234
ssh server in addition to telnet daemon
relays client port 1234 to port 80 on 10.0.0.7
ssh provides a secure, encrypted TCP/IP proxy to
any computer reachable from the ssh server
17X 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
Encrypted communication (compressed too!)
RASPUTIN
ssh client in addition to telnet session acts
as a proxy X client for all apps started on
Rasputin
ssh server in addition to telnet daemon
creates a fake local X server and sets it to be
the default requests are encrypted, compressed,
and tunnelled back to the client
18Package 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
19Package 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 dont include all
necessary dependencies, it will refuse to install - But if you install using APT, it will quietly
install everything needed
20Package management with YUM (Yellowdog Updater
Modified)
- Provides an APT-like experience on top of RPM
21About /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 gt /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
22/proc/vmstat
nr_dirty 8 nr_writeback 0 nr_unstable
0 nr_page_table_pages 1040 nr_mapped
53684 nr_slab 11199 pgpgin 1436240 pgpgout
29582742 pswpin 23 pswpout 40 pgalloc_high
2789161 pgalloc_normal 53175006 pgalloc_dma
11 pgfree 56056660
23The comforts of home
- Xscreensaver
- XMMS (like Winamp)
- Xine / MPlayer (play videos)
- GRIP (rip CDs)
- Mozilla/Firefox/Opera
- Emacs
- Eclipse
- VNC (remote desktop)
24Closing thoughts
- In general Unix desktops are primitive compared
to other popular operating systems - (NeXT and Mac being notable exceptions)
- But its not just about features, ease of use,
and stability - (This better be good)
- Its 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)
25Unix 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
26Final closing thoughts (really)
- Windows
- Intelligent design
- Unix
- Mutation and natural selection