zoukankan      html  css  js  c++  java
  • linux

    http://en.wikipedia.org/wiki/System_console

    System console


    Knoppix system console showing the boot process

     The system consolecomputer consoleroot consoleoperator's console, or simply console is the text entry and display device for system administration messages, particularly those from the BIOS or boot loader, the kernel, from the init system and from the system logger. It is a physical device consisting of a keyboard and a screen, and traditionally is a text terminal, but may also be a graphical terminal. System consoles are generalized to computer terminals, which are abstracted respectively by virtual consoles and terminal emulators. Today communication with system consoles is generally done abstractly, via the standard streams (stdinstdout, and stderr), but there may be system-specific interfaces, for example those used by the system kernel.

    History[edit]

    Prior to the development of alphanumeric CRT system consoles, some computers such as the IBM 1620 had console typewriters and front panels while the very first programmable computer, the Manchester SSEM, used a combination of electromechanical switches and a CRT to provide console functions—the CRT displaying memory contents in binary by mirroring the machine's Williams-Kilburn tube CRT-based RAM.

    On traditional minicomputers,[dubious ] the console was a serial console, an RS-232 serial link to a terminal such as a DEC VT100. This terminal was usually kept in a secured room since it could be used for certain privileged functions such as halting the system or selecting which media to boot from. Largemidrange systems, e.g. those from Sun MicrosystemsHewlett-Packard and IBM, still use serial consoles. In larger installations, the console ports are attached to multiplexers or network-connected multiport serial servers that let an operator connect a terminal to any of the attached servers. Today, serial consoles are often used for accessing headless systems, usually with a terminal emulator running on a laptop. Also, routers, enterprise network switches and other telecommunication equipment have RS-232 serial console ports.

    On PCs and workstations, the computer's attached keyboard and monitor have the equivalent function. Since the monitor cable carries video signals, it cannot be extended very far. Often, installations with many servers therefore use keyboard/video multiplexers (KVM switches) and possibly video amplifiers to centralize console access. In recent years, KVM/IP devices have become available that allow a remote computer to view the video output and send keyboard input via any TCP/IP network and therefore the Internet.

    Some PC BIOSes, especially in servers, also support serial consoles, giving access to the BIOS through a serial port so that the simpler and cheaper serial console infrastructure can be used. Even where BIOS support is lacking, some operating systems, e.g. FreeBSD and Linux, can be configured for serial console operation either during bootup, or after startup.

    It is usually possible to log in from the console. Depending on configuration, the operating system may treat a login session from the console as being more trustworthy than a login session from other sources.

    man console

    A Linux system has up to 63 virtual consoles (character devices with major number 4 and minor number 1 to 63), usually called /dev/ttyn with 1 ≤ n ≤ 63. The current console is also addressed by /dev/console or /dev/tty0, the character device with major number 4 and minor number 0. The device files /dev/* are usually created using the script MAKEDEV, or using mknod(1), usually with mode 0622 and owner root.tty.

    Before kernel version 1.1.54 the number of virtual consoles was compiled into the kernel (in tty.h: #define NR_CONSOLES 8) and could be changed by editing and recompiling. Since version 1.1.54 virtual consoles are created on the fly, as soon as they are needed.

    Common ways to start a process on a console are: (a) tell init(8) (in inittab(5)) to start a mingetty(8) (or agetty(8)) on the console; (b) ask openvt(1) to start a process on the console; (c) start X -- it will find the first unused console, and display its output there. (There is also the ancient doshell(8).)

    Common ways to switch consoles are: (a) use Alt+Fn or Ctrl+Alt+Fn to switch to console n; AltGr+Fn might bring you to console n+12 [here Alt and AltGr refer to the left and right Alt keys, respectively]; (b) use Alt+RightArrow or Alt+LeftArrow to cycle through the presently allocated consoles; (c) use the program chvt(1).(The key mapping is user settable, see loadkeys(1); the above mentioned key combinations are according to the default settings.)

    The command deallocvt(1) (formerly disalloc) will free the memory taken by the screen buffers for consoles that no longer have any associated process.

    Properties
    Consoles carry a lot of state. I hope to document that some other time. The most important fact is that the consoles simulate vt100 terminals. In particular, a console is reset to the initial state by printing the two characters ESC c. All escape sequences can be found in console_codes(4).

    FILES
    /dev/console
    /dev/tty*

    http://en.wikipedia.org/wiki/Virtual_console

    Virtual console

    From Wikipedia, the free encyclopedia
     

    Virtual console showing Knoppixboot messages

    virtual console (VC) – also known as a virtual terminal (VT) – is a conceptual combination of the keyboard and display for a computer user interface. It is a feature of some operating systems such as BSDLinux, and UnixWare in which thesystem console of the computer can be used to switch between multiple virtual consoles to access unrelated user interfaces. Virtual consoles date back at least to Xenix in the 1980s.[1]

    Usually in Linux (see Linux console), the first six virtual consoles provide a text terminal with a login prompt to a Unix shell. The graphical X Window System starts in the seventh virtual console. In Linux, the user switches between them with the key combination Alt plus a function key – for example Alt+F1 to access the virtual console number 1. Alt+Left arrowchanges to the previous virtual console and Alt+Right arrow to the next virtual console. To switch from the X Window System,Ctrl+Alt+function key works. (Note that users can redefine these default key combinations.)

    The need for virtual consoles has lessened now that most applications work in the graphical framework of the X Window System, where each program has a window and the text mode programs can be run in terminal-emulator windows. If severalsessions of the X Window System are required to run in parallel, such as in the case of fast user switching or when debugging X programs on a separate X server, each X session usually runs in a separate virtual console. GNU Screen is a program that can change between several text-mode programs in one textual login.

    Interface[edit]

    The virtual consoles are represented by device special files /dev/tty1, /dev/tty2, etc. There are also special files /dev/console, /dev/tty and /dev/tty0. (Compare the devices using the patterns vcs ("virtual console screen") and vcsa ("virtual console screen with attributes") such as /dev/vcs1 and/dev/vcsa1.[2] ) The virtual consoles can be configured in the file /etc/inittab read by init -- typically it starts the text mode login process getty for several virtual consoles. X Window System can be configured in /etc/inittab or by an X display manager. A number of Linux distributions use systemd instead ofinit, which also allows virtual console configuration. Programs used to access the virtual consoles typically include:

    • chvt to switch the current virtual console
    • openvt to run a program on a new virtual console
    • deallocvt to close a currently unused virtual console.

    The program startx starts the X Window System on a new virtual console. There are also other graphical programs that can start from the console, such as LinuxTVand MPlayer.

    Programs can access the virtual consoles by the device special files. In text mode, writing to the file displays text on the virtual console and reading from the file returns text the user writes to the virtual console. As with other text terminals, there are also special escape sequencescontrol characters andtermios functions that a program can use, most easily via a library such as ncurses. For more complex operations, the programs can use console and terminal special ioctl system calls. Graphical programs can use libraries such as DirectFBDRISDL or the earlier SVGALib.

    Unix systems[edit]

    Unix workstations, such as those manufactured by Sun or Silicon Graphics, did not include virtual consoles. The only purpose of a console would be to fix the system so that the graphical environment could start.

    Sun Niagara-based servers running virtualization with Logical Domains get virtual console services from the Control domain.

    http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-20.html

    20. Screen dumps

    setterm -dump N will dump the contents of the screen of /dev/ttyN to a file screen.dump in the current directory. See setterm(1).

    The current contents of the screen of /dev/ttyN can be accessed using the device /dev/vcsN (where `vcs' stands for `virtual console screen'). For example, you could have a clock program that displays the current time in the upper right hand corner of the console screen (see the program vcstime in kbd-1.04.tar.gz). Just dumping the contents goes with cat /dev/vcsN. These device files /dev/vcsN do not contain newlines, and do not contain attributes, like colors. From a program it is usually better to use/dev/vcsaN (`virtual console screen with attributes') instead - it starts with a header giving the number of rows and columns and the location of the cursor. See vcs(4).

    man vcs

    NAME
    vcs, vcsa - virtual console memory

    DESCRIPTION
    /dev/vcs0 is a character device with major number 7 and minor number 0, usually of mode 0644 and owner root.tty. It refers to the memory of the currently displayed
    virtual console terminal.

    /dev/vcs[1-63] are character devices for virtual console terminals, they have major number 7 and minor number 1 to 63, usually mode 0644 and owner root.tty.
    /dev/vcsa[0-63] are the same, but using unsigned shorts (in host byte order) that include attributes, and prefixed with four bytes giving the screen dimensions and
    cursor position: lines, columns, x, y. (x = y = 0 at the top left corner of the screen.)

    When a 512-character font is loaded, the 9th bit position can be fetched by applying the ioctl(2) VT_GETHIFONTMASK operation (available in Linux kernels 2.6.18 and
    above) on /dev/tty[1-63]; the value is returned in the unsigned short pointed to by the third ioctl(2) argument.

    These devices replace the screendump ioctl(2) operations of console(4), so the system administrator can control access using file system permissions.

    The devices for the first eight virtual consoles may be created by:

    for x in 0 1 2 3 4 5 6 7 8; do
    mknod -m 644 /dev/vcs$x c 7 $x;
    mknod -m 644 /dev/vcsa$x c 7 $[$x+128];
    done
    chown root:tty /dev/vcs*

    No ioctl(2) requests are supported.

    FILES
    /dev/vcs[0-63]
    /dev/vcsa[0-63]

    VERSIONS
    Introduced with version 1.1.92 of the Linux kernel.

    EXAMPLE
    You may do a screendump on vt3 by switching to vt1 and typing cat /dev/vcs3 >foo. Note that the output does not contain newline characters, so some processing may
    be required, like in fold -w 81 /dev/vcs3 | lpr or (horrors) setterm -dump 3 -file /proc/self/fd/1.

    The /dev/vcsa0 device is used for Braille support.

    This program displays the character and screen attributes under the cursor of the second virtual console, then changes the background color there:

    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <linux/vt.h>

    int
    main(void)
    {
    int fd;
    char *device = "/dev/vcsa2";
    char *console = "/dev/tty2";
    struct {unsigned char lines, cols, x, y;} scrn;
    unsigned short s;
    unsigned short mask;
    unsigned char ch, attrib;

    fd = open(console, O_RDWR);
    if (fd < 0) {
    perror(console);
    exit(EXIT_FAILURE);
    }
    if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
    perror("VT_GETHIFONTMASK");
    exit(EXIT_FAILURE);
    }
    (void) close(fd);
    fd = open(device, O_RDWR);
    if (fd < 0) {
    perror(device);
    exit(EXIT_FAILURE);
    }
    (void) read(fd, &scrn, 4);
    (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
    (void) read(fd, &s, 2);
    ch = s & 0xff;
    if (attrib & mask)
    ch |= 0x100;
    attrib = ((s & ~mask) >> 8);
    printf("ch='%c' attrib=0x%02x ", ch, attrib);
    attrib ^= 0x10;
    (void) lseek(fd, -1, 1);
    (void) write(fd, &attrib, 1);
    exit(EXIT_SUCCESS);
    }

    man chvt

    NAME
    chvt - change foreground virtual terminal

    SYNOPSIS
    chvt N

    DESCRIPTION
    The command chvt N makes /dev/ttyN the foreground terminal. (The corresponding screen is created if it did not exist yet. To get rid of unused VTs, use deal-
    locvt(1).) The key combination (Ctrl-)LeftAlt-FN (with N in the range 1-12) usually has a similar effect.

    http://www.linuxdevcenter.com/cmd/cmd.csp?path=c/chvt

    Switch to virtual terminal N (that is, switch to /dev/ttyN). If you have not created /dev/ttyN, it will be created when you use this command. There are keyboard shortcuts for this functionality as well. From a graphical desktop, you can press Ctrl-Alt-F1 through F12 to switch to different virtual terminals. In text mode, you can skip the Ctrl key and just use Alt-F1 through F12. To switch back to graphical mode, use Alt-F7.

    http://en.wikipedia.org/wiki/Teleprinter

    Teleprinter

    From Wikipedia, the free encyclopedia
      (Redirected from Teletypewriter)
     
    For the telecommunications system consisting of teleprinters connected by radio, see Radioteletype.

     
    Teletype machines in use duringWorld War II

     
    Teletype Model 33 ASR teleprinter, with punched tapereader and punch, usable as acomputer terminal

    teleprinter (teletypewriterTeletype or TTY) is an electromechanical typewriter that can be used to send and receive typed messages from point to point and point to multipoint over various types of communications channels. They were adapted to provide a user interface to early mainframe computers and minicomputers, sending typed data to the computer and printing the response. Some models could also be used to create punched tape for data storage (either from typed input or from data received from a remote source) and to read back such tape for local printing or transmission.

    Teleprinters could use a variety of different communication media. These included a simple pair of wires, dedicated non-switched telephone circuits (leased lines), switched networks that operated similarly to the public telephone network (telex), and radio and microwave links (TOR). A teleprinter attached to a modem could also communicate through standard switched public telephone lines. This latter configuration was often used to connect teleprinters to remote computers, particularly in time-sharing environments.

    Teleprinters have largely been replaced by fully electronic computer terminals which usually use a computer monitor instead of a printer (though the term "TTY" is still occasionally used to refer to them, such as in Unix systems). Teleprinters are still widely used in the aviation industry (AFTN and airline teletype system), and variations called Telecommunications Devices for the Deaf (TDDs) are used by the hearing impaired for typed communications over ordinary telephone lines.

    Teleprinters in computing[edit]

    Computers used teleprinters for input and output from the early days of computing. Punched card readers and fast printers replaced teleprinters for most purposes, but teleprinters continued to be used as interactive time-sharing terminals until video displays became widely available in the late 1970s.

    Users typed commands after a prompt character was printed. Printing was unidirectional; if the user wanted to delete what had been typed, further characters were printed to indicate that previous text had been cancelled. When video displays first became available the user interface was initially exactly the same as for an electromechanical printer; expensive and scarce video terminals could be used interchangeably with teleprinters. This was the origin of the text terminaland the command line interface.


     
    A Teletype Model 33 ASR with paper tape reader and punch, as used for modem-based computing

    Paper tape was sometimes used to prepare input for the computer session off line and to capture computer output. The popularTeletype Model 33 used 7-bit ASCII code (with an eighth parity bit) instead of Baudot. The common modem communications settings, Start/Stop Bits and Parity, stem from the Teletype era.

    In early operating systems such as Digital's RT-11, serial communication lines were often connected to teleprinters and were given device names starting with tt. This and similar conventions were adopted by many other operating systems. Unix andUnix-like operating systems use the prefix tty, for example /dev/tty13, or pty (for pseudo-tty), such as /dev/ptya0. In many computing contexts, "TTY" has become the name for any text terminal, such as an external console device, a user dialing in to the system on a modem on a serial port device, a printing or graphical computer terminal on a computer's serial port or the RS-232 port on a USB-to-RS-232 converter attached to a computer's USB port, or even a terminal emulator application in the window system using a pseudo terminal device.

    Teleprinters were also used to record fault printout and other information in some TXE telephone exchanges.

    http://en.wikipedia.org/wiki/Computer_terminal

    Computer terminal

    From Wikipedia, the free encyclopedia
      

     
    The DEC VT100, a widely emulated computer terminal

    computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system. Early terminals were inexpensive devices but very slow compared topunched cards or paper tape for input, but as the technology improved and video displays were introduced, terminals pushed these older forms of interaction from the industry. A related development was timesharing systems, which evolved in parallel and made up for any inefficiencies of the user's typing ability with the ability to support multiple users on the same machine, each at their own terminal.

    The function of a terminal is confined to display and input of data; a device with significant local programmable data processing capability may be called a "smart terminal" or fat client. A terminal that depends on the host computer for its processing power is called a "dumb terminal" or thin client. A personal computer can run terminal emulator software that replicates the function of a terminal, sometimes allowing concurrent use of local programs and access to a distant terminal host system.

    History[edit]


     
    Teletype Model 33 ASR teleprinter, usable as a terminal

    The terminal of the first working programmable, fully automatic digital [1] Turing-complete[2] computer, the Z3, had a keyboard and a row of lamps to show results.[3][dubious ]

    Hard-copy terminals[edit]

    Early user terminals connected to computers were electromechanical teleprinters/teletypewriters (TeleTYpewriter, TTY), such as the Teletype Model 33 ASR, originally used for telegraphy or the Friden Flexowriter. Later printing terminals such as the DECwriter were developed. However printing terminals were limited by the speed at which paper could be printed, and for interactive use the paper record was unnecessary.

    By the early 1970s,[citation needed] many[who?] in the computer industry realized that an affordable video data entry terminal could supplant the ubiquitous punched cards and permit new uses for computers that would be more interactive. The problem was that the amount of memory needed to store the information on a page of text was comparable to the memory in low endminicomputers then in use. Displaying the information at video speeds was also a challenge and the necessary control logic took up a rack worth of pre-integrated circuit electronics. One company[who?] announced plans to build a video terminal for $15,000 and attracted a large backlog of orders, but folded when their engineering plans, which included fabricating their own ICs, proved too ambitious[citation needed]. Another approach involved the use of the storage tube, a specialized CRT developed by Tektronix that retained information written on it without the need to refresh.

    The Datapoint 3300 from Computer Terminal Corporation was announced in 1967 and shipped in 1969, making it one of the earliest stand-alone display-based terminals. It solved the memory space issue mentioned above by using a digital shift-register design, and using only 72 columns rather than the later more common choice of 80.

    Early VDUs[edit]

    Early video computer displays were sometimes nicknamed "Glass TTYs" ("glass Teletypes") or "Visual Display Units" (VDUs), and used individual logic gates, with no CPU or very primitive LSI chips, yet quickly became extremely popular Input-Output devices on many different types of computer system once several suppliers gravitated to a set of common standards:

    • ASCII character set (rather than, say, EBCDIC or anything specific to one company), but early/economy models often supported only capital letters (such as the original ADM-3, the Data General model 6052 - which could be upgraded to a 6053 with a lower-case character ROM - and the Heathkit H9)
    • RS-232 serial ports (25-pin, ready to connect to a modem, yet some manufacturer-specific pin usage extended the standard, e.g. for use with 20-mA current loops)
    • 24 lines (or possibly 25 - sometimes a special status line) of 80 characters of text (sometimes with two character width settings).
    • Some type of blinking cursor that can be positioned (with arrow keys and/or "home" and other direct cursor address setting codes).
    • Implementation of at least 3 control codes: Carriage Return (Ctrl-M), Line-Feed (Ctrl-J), and Bell (Ctrl-G), but usually many more, such as Escape sequencesto provide underlining, dim and/or reverse-video character highlighting, and especially to clear the display and position the cursor.

    The great variations in the latter feature gave rise to software that identified and grouped terminal types so the system software would correctly display input forms using the appropriate control codes; In Unix-like systems the termcap or terminfo files, the stty utility, and the TERM environment variable would be used; in Data General's Business BASIC software, for example, at login-time a sequence of codes were sent to the terminal to try to read the cursor's position or the 25th line's contents using a sequence of different manufacturer's control code sequences, and the terminal-generated response would determine a single-digit number (such as 6 for Data General Dasher terminals, 4 for ADM 3A/5/11/12 terminals, 0 or 2 for TTY's with no special features) that would be available to programs to say which set of codes to use.

    During the late 1970s and early 1980s, there were dozens of manufacturers of terminals, including Lear-SieglerData GeneralDECHazeltine Corporation,Heath/ZenithHewlett PackardIBMTelevideo, and Wyse, many of which had incompatible command sequences (although many used the early ADM-3 as a starting point).

    "Intelligent" terminals[edit]

    An "intelligent" terminal does its own processing, usually implying a microprocessor is built in, but not all terminals with microprocessors did any real processing of input: the main computer to which it was attached would have to respond quickly to each keystroke. The term "intelligent" in this context dates from 1969.[4]

    From the introduction of the IBM 3270, and the DEC VT100 (1978), the user and programmer could notice significant advantages in VDU technology improvements, yet not all programmers used the features of the new terminals (backward compatibility in the VT100 and later Televideo terminals, for example, with "dumb terminals" allowed programmers to continue to use older software).

    Some dumb terminals had been able to respond to a few escape sequences without needing microprocessors: they used multiple printed circuit boards with manyIntegrated Circuits; the single factor that classed a terminal as "intelligent" was its ability to process user-input within the terminal—not interrupting the main computer at each keystroke—and send a block of data at a time (for example: when the user has finished a whole field or form). Most terminals in the early 1980s, such as ADM-3A, TVI912, Data General D2, DEC VT52, despite the introduction of ANSI terminals in 1978, were essentially "dumb" terminals, although some of them (such as the later ADM and TVI models) did have a primitive block-send capability.

    The advance in microprocessors and lower memory costs made it possible for the terminal to handle editing operations such as inserting characters within a field that may have previously required a full screen-full of characters to be re-sent from the computer, possibly over a slow modem line. Around the mid 1980s intelligent terminals, costing less that most dumb terminals would have a few years earlier, could provide enough user-friendly local editing of data and send the completed form to the main computer. Providing even more processing possibilities, workstations like the Televideo TS-800 could run CP/M-86, blurring the distinction between terminal and Personal Computer.

    Another of the motivations for development of the microprocessor was to simplify and reduce the electronics required in a terminal. That also made it practicable to load several "personalities" into a single terminal, so a Qume QVT-102 could emulate many popular terminals of the day, and so be sold into organizations that did not wish to make any software changes. Frequently emulated terminal types included:

    The ANSI X3.64 escape code standard produced uniformity to some extent, but significant differences remained (for example, the VT100Heathkit H19 in ANSI mode,Televideo 970, Data General D460, and Qume QVT-108 terminals all followed the ANSI standard, yet differences might exist of codes from function keys, what character attributes were available, block-sending of fields within forms, "foreign" character facilities, and handling of printers connected to the back of the screen).

    Most terminals were connected to minicomputers or mainframe computers and often had a green or amber screen. Typically terminals communicate with the computer via a serial port via a null modem cable, often using an EIA RS-232 or RS-422 or RS-423 or a current loop serial interface. IBM systems communicated over acoaxial cable using IBM's SNA protocol, but for many DECData General and NCR (and so on) computers there were many visual display suppliers competing against the computer manufacturer for terminals to expand the systems. In fact, the instruction design for the Intel 8008 was originally conceived at Computer Terminal Corporation as the processor for the Datapoint 2200.


     
    A Televideo ASCII character mode terminal, using a microprocessor, manufactured around 1982

    Contemporary[edit]

    While early IBM PCs had single color green screens, these screens were not terminals. The screen of a PC did not contain any character generation hardware; all video signals and video formatting were generated by the video display card in the PC, or (in most graphics modes) by the CPU and software. An IBM PC monitor, whether it was the green monochrome display or the 16-color display, was technically much more similar to an analog TV set (without a tuner) than to a terminal. With suitablesoftware a PC could, however, emulate a terminal, and in that capacity it could be connected to a mainframe or minicomputer. The Data General One could be booted into terminal emulator mode from its ROM. Eventually microprocessor-based personal computers greatly reduced the market demand for conventional terminals.

    In the 1990s especially, "thin clients" and X terminals have combined economical local processing power with central, shared computer facilities to retain some of the advantages of terminals over personal computers:

    Today, most PC telnet clients provide emulation of the most common terminal, the DEC VT100, using the ANSI escape codestandard X3.64, or could run as X terminals using software such as Cygwin/X under Microsoft Windows or X.Org Server software under Linux.

    Since the advent and subsequent popularization of the personal computer, few genuine hardware terminals are used to interface with computers today. Using themonitor and keyboard, modern operating systems like Linux and the BSD derivatives feature virtual consoles, which are mostly independent from the hardware used.

    When using a graphical user interface (or GUI) like the X Window System, one's display is typically occupied by a collection of windows associated with various applications, rather than a single stream of text associated with a single process. In this case, one may use a terminal emulator application within the windowing environment. This arrangement permits terminal-like interaction with the computer (for running a command line interpreter, for example) without the need for a physical terminal device; it can even allow the running of multiple terminal emulators on the same device.

    Capabilities[edit]

    Text terminals[edit]


     
    A typical text terminal produces input and displays output and errors

     
    Nano text editor running in the xterm terminal emulator

    text terminal, or often just terminal (sometimes text console) is a serial computer interface for text entry and display. Information is presented as an array of pre-selected formed characters. When such devices use a video display such as acathode-ray tube, they are called a "video display unit" or "visual display unit" (VDU) or "video display terminal" (VDT).

    The System console is a text terminal used to operate a computer. Modern computers have a built-in keyboard and display for the console. Some Unix-like operating systems such as Linux and FreeBSD have virtual consoles to provide several text terminals on a single computer.

    The fundamental type of application running on a text terminal is a command line interpreter or shell, which prompts for commands from the user and executes each command after a press of Enter. This includes Unix shells and some interactive programming environments. In a shell, most of the commands are small applications themselves.

    Another important application type is that of the text editor. A text editor occupies the full area of display, displays one or more text documents, and allows the user to edit the documents. The text editor has, for many uses, been replaced by the word processor, which usually provides rich formatting features that the text editor lacks. The first word processors used text to communicate the structure of the document, but later word processors operate in a graphical environment and provide a WYSIWYGsimulation of the formatted output.

    Programs such as Telix and Minicom control a modem and the local terminal to let the user interact with remote servers. On theInternettelnet and ssh work similarly.

    In the simplest form, a text terminal is like a file. Writing to the file displays the text and reading from the file produces what the user enters. In unix-like operating systems, there are several character special files that correspond to available text terminals. For other operations, there are special escape sequencescontrol characters and termios functions that a program can use, most easily via a library such as ncurses. For more complex operations, the programs can use terminal specific ioctl system calls. For an application, the simplest way to use a terminal is to simply write and read text strings to and from it sequentially. The output text is scrolled, so that only the last several lines (typically 24) are visible. Unix systems typically buffer the input text until the Enter key is pressed, so the application receives a ready string of text. In this mode, the application need not know much about the terminal. For many interactive applications this is not sufficient. One of the common enhancements is command line editing (assisted with such libraries as readline); it also may give access to command history. This is very helpful for various interactive command line interpreters.

    Even more advanced interactivity is provided with full-screen applications. Those applications completely control the screen layout; also they respond to key-pressing immediately. This mode is very useful for text editorsfile managers and web browsers. In addition, such programs control the color and brightness of text on the screen, and decorate it with underline, blinking and special characters (e.g. box drawing characters). To achieve all this, the application must deal not only with plain text strings, but also with control characters and escape sequences, which allow to move cursor to an arbitrary position, to clear portions of the screen, change colors and display special characters, and also respond to function keys. The great problem here is that there are so many different terminals and terminal emulators, each with its own set of escape sequences. In order to overcome this, special libraries (such as curses) have been created, together with terminal description databases, such as Termcap and Terminfo.

    Dumb terminals[edit]

    Dumb terminals are those that can interpret a limited number of control codes (CRLF, etc.) but do not have the ability to process special escape sequencesthat perform functions such as clearing a line, clearing the screen, or controlling cursor position. In this context dumb terminals are sometimes dubbed glass Teletypes, for they essentially have the same limited functionality as does a mechanical Teletype. This type of dumb terminal is still supported on modern Unix-like systems by setting the environment variable TERM to dumbSmart or intelligent terminals are those that also have the ability to process escape sequences, in particular the VT52VT100 or ANSI escape sequences.

    Graphical terminals[edit]

    A graphical terminal can display images as well as text. Graphical terminals are divided into vector-mode terminals, and raster mode.

    A vector-mode display directly draws lines on the face of a cathode-ray tube under control of the host computer system. The lines are continuously formed, but since the speed of electronics is limited, the number of concurrent lines that can be displayed at one time is limited. Vector-mode displays were historically important but are no longer used. Practically all modern graphic displays are raster-mode, descended from the picture scanning techniques used for television, in which the visual elements are a rectangular array of pixels. Since the raster image is only perceptible to the human eye as a whole for a very short time, the raster must be refreshed many times per second to give the appearance of a persistent display. The electronic demands of refreshing display memory meant that graphic terminals were developed much later than text terminals, and initially cost much more.

    Most terminals today are graphical, that is, they can show images on the screen. The modern term for graphical terminal is "thin client". A thin client typically uses a protocol like X11 for Unix-terminals, or RDP for Microsoft Windows. The bandwidth needed depends on the protocol used, the resolution, and thecolor depth.

    Modern graphic terminals allow display of images in color, and of text in varying sizes, colors, and fonts (type faces).

    In the early 1990s an industry consortium attempted to define a standard, AlphaWindows, that would allow a single CRT screen to implement multiple windows, each of which was to behave as a distinct terminal. Unfortunately like I2O this suffered from being run as a closed standard: non-members were unable to obtain even minimal information and there was no realistic way a small company or independent developer could join the consortium. Possibly because of this the standard disappeared without trace.

    Emulation[edit]

    terminal emulator is a piece of software that emulates a text terminal. In the past, before the widespread use of local area networking and broadband internet access, many computers would use a serial access program to communicate with other computers via telephone line or serial device.

    When the first Macintosh was released, a program called MacTerminal was used to communicate with many computers, including the IBM PC.

    Dec Terminal was one of the first terminal programs for the popular Altair.

    The Win32 console on Windows does not emulate a physical terminal that supports escape sequences[5][dubious ] so SSH and Telnet programs (for logging in textually to remote computers) for Windows, including the Telnet program bundled with some versions of Windows, often incorporate their own code to process escape sequences. The terminal emulators on most Unix-like systems, such as, for example, xterm and Terminal, emulate physical terminals that support escape sequences

    Modes[edit]

    Terminals can operate in various modes, relating to when they send input typed by the user on the keyboard to the receiving system (whatever that may be):

    • Character mode (a.k.a. character-at-a-time mode): In this mode, typed input is sent immediately to the receiving system.[6]
    • Line mode (a.k.a. line-at-a-time mode): In this mode, the terminal provides a local line editing function, and sends an entire input line, after it has been locally edited, when the user presses a return key.[6] A so-called "line mode terminal" operates solely in this mode.[7]
    • Block mode (a.k.a. screen-at-a-time mode): In this mode, the terminal provides a local full-screen data function. The user can enter input into multiple fields in a form on the screen (defined to the terminal by the receiving system), moving the cursor around the screen using keys such as Tab  and the arrow keys and performing editing functions locally using insertdelete← Backspace and so forth. The terminal sends only the completed form, consisting of all the data entered on the screen, to the receiving system when the user presses an ↵ Enter key.[8][9][6]

    There is a distinction between the return and the ↵ Enter keys. In some multiple-mode terminals, that can switch between modes, pressing the ↵ Enter key whennot in block mode does not do the same thing as pressing the return key. Whilst the return key will cause an input line to be sent to the host in line-at-a-time mode, the ↵ Enter key will rather cause the terminal to transmit the contents of the character row where the cursor is currently positioned to the host, host-issued prompts and all.[8]

    Different computer operating systems require different degrees of mode support when terminals are used as computer terminals. The POSIX terminal interface, as provided by Unix and POSIX-compliant operating systems, does not accommodate block-mode terminals at all, and only rarely requires the terminal itself to be in line-at-a-time mode, since the operating system is required to provide canonical input mode, where the terminal device driver in the operating system emulateslocal echo in the terminal, and performs line editing functions at the host end. Most usually, and especially so that the host system can support non-canonical input mode, terminals for POSIX-compliant systems are always in character-at-a-time mode. In contrast, IBM 3270 terminals connected to MVS systems are always required to be in block mode.[10][11][12][13]

    man 4 tty

    tty - controlling terminal

    DESCRIPTION
    The file /dev/tty is a character file with major number 5 and minor number 0, usually of mode 0666 and owner.group root.tty. It is a synonym for the controlling terminal of a process, if any.

    In addition to the ioctl(2) requests supported by the device that tty refers to, the ioctl(2) request TIOCNOTTY is supported.

    TIOCNOTTY
    Detach the calling process from its controlling terminal.

    If the process is the session leader, then SIGHUP and SIGCONT signals are sent to the foreground process group and all processes in the current session lose their controlling tty.

    This ioctl(2) call only works on file descriptors connected to /dev/tty. It is used by daemon processes when they are invoked by a user at a terminal. The process attempts to open /dev/tty. If the open succeeds, it detaches itself from the terminal by using TIOCNOTTY, while if the open fails, it is obviously not attached to a terminal and does not need to detach itself.

    FILES
    /dev/tty

    http://en.wikipedia.org/wiki/X_terminal

    X terminal

    From Wikipedia, the free encyclopedia
     
    Not to be confused with xterm or other terminal emulators running under X.

     
    Network Computing Devices NCD-88k X terminal.

     
    An X server runs on the X terminal, connecting to a central computer running an X display manager. In this example, client programs (xterm and xedit) are running on the same computer.

    In computing, an X terminal is a display/input terminal for X Window System client applications. X terminals enjoyed a period of popularity in the early 1990s when they offered a lower total cost of ownership alternative to a full Unixworkstation.

    An X terminal runs an X server. (In X, the usage of "client" and "server" is from the viewpoint of the programs: the X server supplies a screen, keyboard, mouse and touchscreen to client applications.) This connects to an X display manager(introduced in X11R3) running on a central machine, using XDMCP (X Display Manager Control Protocol, introduced in X11R4).[1]

    Thin clients have somewhat supplanted X terminals in that they are equipped with added flash memory and software for communication with remote desktop protocols. Due to the existence of free software implementations of multiple protocols, X terminals which do not have this extra flash memory have been made commercially obsolete by more general-purpose thin clients and by low cost PCs running an X server.[clarification needed][dubious ]

    http://en.wikipedia.org/wiki/Pseudo_terminal

    Pseudo terminal

    From Wikipedia, the free encyclopedia
     
     

     
    Pseudo terminals as they are used by script(1)

    In some operating systems, including Unix, a pseudo terminalpseudotty, or PTY is a pair of pseudo-devices, one of which, the slave, emulates a real text terminal device, the other of which, the master, provides the means by which a terminal emulator process controls the slave.

    History[edit]

    Pseudo terminals were present in the DEC PDP-6 Timesharing Monitor at least as early as 1967, and were used to implement batch processing.[1] They are described in the documentation for the succeeding TOPS-10 on the PDP-10.[2] Other DEC operating systems also had PTYs, including RSTS/E for the PDP-11, as did the third-party TENEX operating system for the PDP-10.

    Unix pseudo terminals originated in 1983 during the development of Eighth Edition Unix and were based on a similar feature in TENEX.[3] They were part of the 4.2 release of BSD. AT&T's System V included support for pseudo terminals as a driver in their STREAMS device model, along with the pseudo terminal multiplexer.

    Applications[edit]

    The role of the terminal emulator process is to interact with the user; to feed text input to the master pseudo-device for use by the shell (which is connected to the slave pseudo-device) and to read text output from the master pseudo-device and show it to the user. The terminal emulator process must also handle terminal control commands, e.g., for resizing the screen. Widely used terminal emulator programs include xtermGNOME TerminalKonsole and Mac OS X Terminal. Remote login handlers such as ssh and telnet servers play the same role but communicate with a remote user instead of a local one. Different again are programs such as expect.

    Screen and Tmux are used to add a session context to a pseudo terminal, making for a much more robust and versatile solution. For example, it provides terminal persistence allowing to disconnect from one computer and connect later on from another computer on the net.

    Variants[edit]

    In the BSD PTY system, the slave device file, which generally has a name of the form /dev/tty[p-za-e][0-9a-f], supports all system calls applicable to text terminal devices. Thus it supports login sessions. The master device file, which generally has a name of the form /dev/pty[p-za-e][0-9a-f], is the endpoint for communication with the terminal emulator. With this [p-za-e] naming scheme, there can be at most 256 tty pairs. Also, finding the first free pty master can beracy unless a locking scheme is adopted. For that reason, recent BSD operating systems, such as FreeBSD, implement Unix98 PTYs.[4]

    BSD PTYs have been rendered obsolete by Unix98 ptys whose naming system does not limit the number of pseudo-terminals and access to which occurs without danger of race conditions. /dev/ptmx is the "pseudo-terminal master multiplexer". Opening it returns a file descriptor of a master node and causes an associated slave node /dev/pts/N to be created.[5]

    man pts

    NAME
    ptmx and pts - pseudo-terminal master and slave

    DESCRIPTION
    The file /dev/ptmx is a character file with major number 5 and minor number 2, usually of mode 0666 and owner.group of root.root. It is used to create a pseudo-
    terminal master and slave pair.

    When a process opens /dev/ptmx, it gets a file descriptor for a pseudo-terminal master (PTM), and a pseudo-terminal slave (PTS) device is created in the /dev/pts
    directory. Each file descriptor obtained by opening /dev/ptmx is an independent PTM with its own associated PTS, whose path can be found by passing the descriptor
    to ptsname(3).

    Before opening the pseudo-terminal slave, you must pass the master’s file descriptor to grantpt(3) and unlockpt(3).

    Once both the pseudo-terminal master and slave are open, the slave provides processes with an interface that is identical to that of a real terminal.

    Data written to the slave is presented on the master descriptor as input. Data written to the master is presented to the slave as input.

    In practice, pseudo-terminals are used for implementing terminal emulators such as xterm(1), in which data read from the pseudo-terminal master is interpreted by
    the application in the same way a real terminal would interpret the data, and for implementing remote-login programs such as sshd(8), in which data read from the
    pseudo-terminal master is sent across the network to a client program that is connected to a terminal or terminal emulator.

    Pseudo-terminals can also be used to send input to programs that normally refuse to read input from pipes (such as su(1), and passwd(1)).

    FILES
    /dev/ptmx, /dev/pts/*

    NOTES
    The Linux support for the above (known as Unix98 pty naming) is done using the devpts file system, that should be mounted on /dev/pts.

    Before this Unix98 scheme, master ptys were called /dev/ptyp0, ... and slave ptys /dev/ttyp0, ... and one needed lots of preallocated device nodes.

    man pty

    NAME
    pty - pseudo-terminal interfaces

    DESCRIPTION
    A pseudo-terminal is a pair of virtual character devices that provide a bidirectional communication channel. One end of the channel is called the master; the other
    end is called the slave. The slave end of the pseudo-terminal provides an interface that behaves exactly like a classical terminal. A process that expects to be
    connected to a terminal, can open the slave end of a pseudo-terminal and then be driven by a program that has opened the master end. Anything that is written on
    the master end is provided to the process on the slave end as though it was input typed on a terminal. For example, writing the interrupt character (usually con-
    trol-C) to the master device would cause an interrupt signal (SIGINT) to be generated for the foreground process group that is connected to the slave. Conversely,
    anything that is written to the slave end of the pseudo-terminal can be read by the process that is connected to the master end. Pseudo-terminals are used by
    applications such as network login services (ssh(1), rlogin(1), telnet(1)), terminal emulators, script(1), screen(1), and expect(1).

    Historically, two pseudo-terminal APIs have evolved: BSD and System V. SUSv1 standardized a pseudo-terminal API based on the System V API, and this API should be
    employed in all new programs that use pseudo-terminals.

    Linux provides both BSD-style and (standardized) System V-style pseudo-terminals. System V-style terminals are commonly called Unix 98 pseudo-terminals on Linux
    systems. Since kernel 2.6.4, BSD-style pseudo-terminals are considered deprecated (they can be disabled when configuring the kernel); Unix 98 pseudo-terminals
    should be used in new applications.

    Unix 98 pseudo-terminals
    An unused Unix 98 pseudo-terminal master is opened by calling posix_openpt(3). (This function opens the master clone device, /dev/ptmx; see pts(4).) After per-
    forming any program-specific initializations, changing the ownership and permissions of the slave device using grantpt(3), and unlocking the slave using
    unlockpt(3)), the corresponding slave device can be opened by passing the name returned by ptsname(3) in a call to open(2).

    The Linux kernel imposes a limit on the number of available Unix 98 pseudo-terminals. In kernels up to and including 2.6.3, this limit is configured at kernel com-
    pilation time (CONFIG_UNIX98_PTYS), and the permitted number of pseudo-terminals can be up to 2048, with a default setting of 256. Since kernel 2.6.4, the limit is
    dynamically adjustable via /proc/sys/kernel/pty/max, and a corresponding file, /proc/sys/kernel/pty/nr, indicates how many pseudo-terminals are currently in use.
    For further details on these two files, see proc(5).

    BSD pseudo-terminals
    BSD-style pseudo-terminals are provided as pre-created pairs, with names of the form /dev/ptyXY (master) and /dev/ttyXY (slave), where X is a letter from the
    16-character set [p-za-e], and Y is a letter from the 16-character set [0-9a-f]. (The precise range of letters in these two sets varies across Unix implementa-
    tions.) For example, /dev/ptyp1 and /dev/ttyp1 constitute a BSD pseudo-terminal pair. A process finds an unused pseudo-terminal pair by trying to open(2) each
    pseudo-terminal master until an open succeeds. The corresponding pseudo-terminal slave (substitute "tty" for "pty" in the name of the master) can then be opened.

    FILES
    /dev/ptmx (Unix 98 master clone device)
    /dev/pts/* (Unix 98 slave devices)
    /dev/pty[p-za-e][0-9a-f] (BSD master devices)
    /dev/tty[p-za-e][0-9a-f] (BSD slave devices)

  • 相关阅读:
    NO.6: 若不想编译器提供自动生成的函数,就应该明确拒绝
    NO.5: 了解C++编译器默认为你生成的构造/赋值/析构
    NO.4: 确定对象被使用前已被初始化
    NO.3: 尽量使用const
    NO.2: 尽量以const,enum,inline 替换 #define
    NO.1: 视C++为一个语言联邦
    C/C++ exception类
    C/C++ 类成员函数指针 类成员数据指针
    c++中的 Stl 算法(很乱别看)
    自定义类签发校验token-实现多方式登录-自定义反爬类-admin后台表管理字段自定义-群查接口-搜索-排序-分页
  • 原文地址:https://www.cnblogs.com/baiyw/p/4226557.html
Copyright © 2011-2022 走看看