Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ●...

12
Linux Terminal System Conceptual Linux terminal Terminal API Terminal emulators Graphical user interfaces

Transcript of Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ●...

Page 1: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

Linux Terminal System

● Conceptual Linux terminal● Terminal API● Terminal emulators● Graphical user interfaces

Page 2: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

Conceptual Linux terminal

Application

Kernel

Mainframe

ModemModem ModemModem

Terminal

Keyboard

Display

User

Page 3: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

stdin/stdout● Low-level calls: read(), write(), fd's● High-level calls: fread(), fwrite(), FILE*'s● Formatted I/O: fscanf(), fprintf(), FILE*'s● Redirection: dup2(), pipes “|”, redir “>”

$ randomize < input | rot13 | tee log | rot13 | sort$ cat log

inputinput

randomizerandomize rot13rot13 teetee rot13rot13

loglog terminalterminalcatcat

sortsort

Page 4: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

Escape sequences & function keys

● Many incompatible escape sequences

and terminal capabilities● $TERM identifies terminal type● termcap/terminfo defines terminal types

Application

Application TerminalTerminal

Escape sequences“\e[2J” = clear

screen

Escape sequences“\e[2J” = clear

screenFunction key sequences“\e[A” = up arrow

key

Function key sequences“\e[A” = up arrow

key

Page 5: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

ioctls and termios● ioctls give very low-level access● termios standardizes interface● ioctls/termios can adjust canonical

(cooked) and non-canonical (raw)

modes● Linux terminal provides font, etc. ioctls● Serial ports have baud rate, etc. ioctls

Page 6: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

curses, ncurses, and S-Lang

● Wrapper libraries hide complexity of

terminal programming● Provides portable interface to many

terminal types● curses: cursor control library● ncurses: new curses● S-Lang: contains terminal control library

Page 7: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

Terminal emulators● Consumer computer systems have

integrated human interface hardware, so

terminal functionality must be emulated● Dumb terminal: works like a teletype● Linux vt100: VGA + keyboard + buzzer● GNU screen: display multiplexing● xterm: text terminals in graphical display

Page 8: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

X Window System● X server gives programs access to

keyboard, mouse, and display hardware● Client apps tell the server what to draw● User sits in front of X server

Mainframe

X app 1

X server

Kbd/VGA

UserMainframe

X app 2

Page 9: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

VNC: Virtual Network Computing

● Cross between GNU screen and X● User sits in front of VNC client (“viewer”)

Mainframe

gimp

Xvnc

Mainframe

wmaker

xterm

Workstation

XFree86

vncviewer

User

Page 10: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

Conclusion● Archetypical Linux terminal system● Program input and output● Terminal API, low- and high-level● Terminal emulators● Graphical user interfaces

Slides available online:

http://ioioio.net/school/terminal/slides.pdf

Page 11: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

GNU screen

sshmuttbash

screen

xterm xfree86 User

monitor

kbd

Workstation

Page 12: Linux Terminal System ● Conceptual Linux terminal ● Terminal API ● Terminal emulators ● Graphical user interfaces.

VPN over SSH

PPP0 ETH0

ETH1

PPP1 PPP1pppd

ssh sshd

pppd

firefox web browser

Corporate networkHome network

Internet / WAN