Linux Command Line and Shell Scripting Bible. Christine Bresnahan

Чтение книги онлайн.

Читать онлайн книгу Linux Command Line and Shell Scripting Bible - Christine Bresnahan страница 7

Linux Command Line and Shell Scripting Bible - Christine Bresnahan

Скачать книгу

key combination and then press a function key (F1 through F7) for the virtual console you want to use. Function key F2 produces virtual console 2, key F3 produces virtual console 3, key F4 produces virtual console 4, and so on.

      Note

      Linux distributions typically use the Ctrl+Alt key combination with either F1 or F7 to reach the graphical interface. Ubuntu uses F7, while RHEL uses F1. It is best to test and see where your distribution puts the graphical interface.

Text mode virtual consoles use the whole screen and start with the text login screen displayed. An example of a text login screen from a virtual console is shown in Figure 2.2.

Figure 2.2 Linux virtual console login screen

      Notice in Figure 2.2 the words tty2 at the end of the first text line. The 2 in tty2 indicates that it is virtual console 2 and was reached by pressing the Ctrl+Alt+F2 key sequence. tty stands for teletypewriter. Teletypewriter is an old term, indicating a machine used for sending messages.

      Note

      Not all Linux distributions show the virtual console's tty number at the login screen.

      You log into a console terminal by entering your user ID after the login: prompt and typing your password after the Password: prompt. If you have never logged in this way before, be aware that typing your password is a different experience than in a graphical environment. In a graphical environment, you may see dots or asterisks indicating the password characters as you type. However, at the virtual console, nothing is displayed when you type your password.

      After logging into a virtual console, you are taken to the Linux CLI. Keep in mind that, within the Linux virtual console, you do not have the ability to run any graphical programs.

      After you have logged in to a virtual console, you can keep it active and switch to another virtual console without losing your active session. You can switch between all the virtual consoles, with multiple active sessions running. This feature provides a great deal of flexibility while you work at the CLI.

      Additional flexibility deals with the virtual console's appearance. Even though it is a text mode console terminal, you can modify the text and background colors.

For example, it may be easier on your eyes to set the background of the terminal to white and the text to black. After you have logged in, you can accomplish this modification in a couple of ways. One way is to type in the command setterm – inversescreen on and press the Enter key, as shown in Figure 2.3. Notice in the figure that the inversescreen feature is being turned on using the option on. You can also turn it off using the off option.

Figure 2.3 Linux virtual console with inversescreen being turned on

      Another way is to type two commands, one after the other. Type setterm – background white and press Enter, and then type setterm – foreground black and press Enter. Be careful because, when you change your terminal background first, it may be hard to see the commands you are typing.

With the commands in the preceding paragraph, you are not turning features on and off, as with inversescreen. Instead, you have a choice of eight colors. The choices are black, red, green, yellow, blue, magenta, cyan, and white (which looks gray on some distributions). You can get rather creative with your plain text mode console terminals. Table 2.2 shows some options you can use with the setterm command to help improve your console terminal's readability or appearance.

Table 2.2 setterm Options for Foreground and Background Appearance

      Virtual console terminals are great for accessing the CLI outside the GUI. However, sometimes, you need to access the CLI and run graphical programs. Using a terminal emulation package solves this problem and is a popular way to access the shell CLI from within the GUI. The following sections describe common software packages that provide graphical terminal emulation.

      Accessing CLI via Graphical Terminal Emulation

The graphical desktop environment offers a great deal more variety for CLI access than the virtual console terminal does. Many graphical terminal emulator packages are available for the graphical environment. Each package provides its own unique set of features and options. Some popular graphical terminal emulator packages are shown in Table 2.3 along with their websites.

Table 2.3 Popular Graphical Terminal Emulator Packages

      Although many graphical terminal emulator packages are available, the focus in this chapter is on three commonly used ones. Often installed in Linux distributions by default, they are GNOME Terminal, Konsole Terminal, and xterm.

      Using the GNOME Terminal Emulator

      GNOME Terminal is the GNOME desktop environment's default terminal emulator. Many distributions, such as RHEL, Fedora, and CentOS, use the GNOME desktop environment by default, and therefore use GNOME Terminal by default. However, other desktop environments, such as Ubuntu Unity, also use the GNOME terminal as their default terminal emulator package. It is fairly easy to use and a good terminal emulator for individuals who are new to Linux. This chapter section walks you through the various parts of accessing, configuring and using the GNOME terminal emulator.

Accessing the GNOME Terminal

      Each graphical desktop environment has different methods for accessing the GNOME terminal emulator. This section looks at accessing the GNOME Terminal in the GNOME, Unity, and KDE desktop environments.

      Note

      If you are using a different desktop environment than the ones listed in Table 2.3, you must look through the various menus offered in your environment to find the GNOME terminal emulator. In the menus, it is typically named Terminal

      In the GNOME desktop environment, accessing the GNOME Terminal is fairly straightforward. From the menu system in the upper-left corner of the window, click Applications, then select System Tools from the drop-down menu, and finally click Terminal. Written in shorthand, the directions look like the following: Applications⇨System Tools⇨ Terminal.

      Refer to Figure 2.1 to see a picture of the GNOME Terminal. It was accessed in a GNOME desktop environment on a CentOS distribution.

      In the Unity desktop environment, accessing the GNOME terminal takes a little more effort. The simplest access method is Dash⇨Search and type Terminal. The GNOME terminal shows up in the Dash home area as an application named Terminal. Click that icon to open the GNOME terminal emulator.

      Tip

      In some Linux distribution desktop environments, such as Ubuntu's Unity, you can quickly access the GNOME terminal using the shortcut key combination Ctrl+Alt+T.

      In the KDE desktop environment, the Konsole terminal emulator is the default emulator. Therefore, you must dig down through the menus to access GNOME Terminal. Start with the icon labeled Kickoff

Скачать книгу