Console management

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← The form dialog for inputHomeGet the name of the current terminal →
  • The Linux system console is used to display messages from the BIOS, the kernel and from the other programs.
  • Console is nothing but a physical device consisting of a keyboard and a screen.
  • The terminfo database on a Linux (and UNIX) computer describes terminals including its attributes and capabilities. Terminfo describes terminals by giving a set of capabilities which they have, by specifying how to perform screen operations, and by specifying padding requirements and initialization sequences.
  • You can control your console via shell scripts using the following commands:
    • tty command - print the file name of the terminal connected to standard input.
    • reset command - terminal initialization.
    • tput command - initialize a terminal or query terminfo database.
    • setleds command - set the keyboard leds.
    • setterm command - set terminal attributes.

tput Command Examples

The tput command is very useful to add some spice to your Linux shell scripts. You can initialize the terminal according to the type of terminal in the environmental variable TERM:

tput init

To clear the terminal screen, enter:

tput clear

Other examples:

External links

  • 10 tools to add some spice to your UNIX shell scripts.
  • Discover tput: Add some spice to your UNIX shell scripts.
← The form dialog for inputHomeGet the name of the current terminal →