Download (direct link):
Using Fancy Shell Tricks
To troubleshoot a Linux system, you won't be able to stay with the graphical interfaces. Being able to get to a shell command-line interface, or more likely several interfaces at once, is a critical component of Linux system administration.
On a Linux system that has no graphical interface (or boots to runlevel 3), the shell is all you will have to start with. Login from your text-based login screen and the next thing you will see is a shell prompt. From a graphical user interface (GUI) desktop, however, there are lots of different ways of accessing shells and tricks for using shells efficiently.
Ways to Get to a Shell
The most common way to get to a shell from any Linux desktop is to open a terminal emulator window. Back in the old UNIX days, before graphical interfaces (or Linux) even existed, a character-based terminal was the only way to access UNIX-like systems. A terminal emulator, as the name implies, emulates one of those old character terminals when you open a terminal emulator window on the desktop. As an alternative, you can open a virtual terminal to get to a shell.
In Fedora Linux, a terminal emulator running on the desktop is simply referred to as a Terminal window. Unlike early editions of Red Flat Linux, Fedora and other recent Red Flat Linux systems don't have an icon on the desktop or panel for opening a Terminal window. Flowever, there are still lots of ways to get to one.
Flere are a few ways to open the default Terminal window from a KDE (konsole) or GNOME (gnome-terminal) desktop:
® Ctrl+t- From the KDE desktop, click anywhere on the desktop background, then press Ctrl+t.
® Desktop menu- Right-click on the GNOME desktop background to see the desktop menu. Then select Open Terminal.
® Red Hat menu- Click on the Red Flat menu, then select System Tools?Terminal.
Figure 6-1 shows two Terminal windows. The top one is the Konsole window (konsole command) and the lower one is the GNOME Terminal window (gnome-terminal command).
Figure 6-1: Konsole (top) and GNOME Terminal (bottom) windows provide shell access on a Linux desktop.
Each of the Terminal windows shown currently has two shell interfaces open. On the Konsole window, the small terminal icons each represent a different shell, while the GNOME Terminal window has a tab representing each shell. The prompt in each window shows the user you are logged in (as root), the name of your local computer (shuttle, in this case), and the name of the current directory (/root and /tmp, respectively).
There are other terminal windows that are less commonly used. The xterm command launches the classic X terminal emulator window. The KDE kterm terminal window offers additional multilingual support. Both xterm and kterm allow many options for changing colors, fonts, and other attributes. However, those features are not selectable from menus on the window, as they are with Konsole and GNOME Terminal windows.
Tips on using Terminal windows are described a bit later. Besides the default bash shell, there are other different shells available (which are also described a bit later in this chapter).
Another way to get to a shell from Linux is by using virtual terminals. When you first boot Linux, six virtual terminals are started, offering you six text-based login screens. If you start Linux in graphical mode (the default runlevel 5), it will typically use a seventh virtual terminal.
You can switch to different virtual terminals from any Linux desktop, using the Ctrl+Alt+function key sequences or one of several virtual-terminal-switching commands (such as chvt orSwitchto). The number of the virtual terminal corresponds to the function key you use to switch, such as Ctrl+Alt+L1 (virtual terminal 1), Ctrl+Alt+L2 (virtual terminal 2), Ctrl+Alt+L3 (virtual terminal 3), and so on. Lrom any nongraphical virtual terminals (1 to 6), you can drop the Ctrl key. Lor example, you could use Alt+L7 to get back to your X desktop.
Note Use the Alt key from the left side of the keyboard.
To use either the chvt or switchto commands to change to another virtual terminal, follow the command with the number of the virtual terminal. Lor example:
# chvt 3
This changes to virtual terminal 3. The chvt and switchto commands are most useful at times when some application may have taken over your function keys.
The programs run in virtual terminals need not be purely text based. Programs that have been implemented using the new curses (ncurses) library routines can offer menu-driven interfaces that run in virtual terminals and Terminal windows. You can use Tab and arrow keys to move around and make selections. Examples include redhat-config-printer-tui and redhat-config-network-tui (the tui stands for text user interface) to see text-based interfaces for printers and network interfaces.
Tuning up a Terminal Window
In this chapter, I'm focusing on the gnome-terminal and konsole terminal emulation windows because these are the two default Terminal windows used with GNOME and KDE desktop environments, respectively. Of course, once a Terminal window is open, you can just type the commands you want and not fuss about it. Elowever, here are a few tips that might make using your Terminal window more pleasant: