Linux Bible. Christopher Negus
Чтение книги онлайн.

Читать онлайн книгу Linux Bible - Christopher Negus страница 21

Название: Linux Bible

Автор: Christopher Negus

Издательство: John Wiley & Sons Limited

Жанр: Зарубежная образовательная литература

Серия:

isbn: 9781118999882

isbn:

СКАЧАТЬ you to gather data input and direct data output between commands and the Linux filesystem. To save typing, you can find, edit, and repeat commands from your shell history. Many power users hardly touch a graphical interface, doing most of their work from a shell.

      ● You can gather commands into a file using programming constructs such as conditional tests, loops, and case statements to quickly do complex operations that would be difficult to retype over and over. Programs consisting of commands that are stored and run from a file are referred to as shell scripts. Most Linux system administrators use shell scripts to automate tasks such as backing up data, monitoring log files, or checking system health.

      The shell is a command language interpreter. If you have used Microsoft operating systems, you'll see that using a shell in Linux is similar to – but generally much more powerful than – the interpreter used to run commands in DOS or in the CMD command interface. You can happily use Linux from a graphical desktop interface, but as you grow into Linux you will surely need to use the shell at some point to track down a problem or administer some features.

      How to use the shell isn't obvious at first, but with the right help you can quickly learn many of the most important shell features. This chapter is your guide to working with the Linux system commands, processes, and filesystem from the shell. It describes the shell environment and helps you tailor it to your needs.

      About Shells and Terminal Windows

      There are several ways to get to a shell interface in Linux. Three of the most common are the shell prompt, Terminal window, and virtual console, which you learn more about in the following sections.

      To start using this section, boot up your Linux system. On your screen, you should either see a plain-text login prompt similar to the following:

      Or you will see a graphical login screen.

      In either case, you should log in with a regular user account. If you have a plain-text login prompt, continue to the “Using the shell prompt” section. If you log in through a graphical screen, go to the “Using a terminal window” section to see how to access a shell from the desktop. In either case, you can access more shells as described in the “Using virtual consoles” section.

      Using the shell prompt

      If your Linux system has no graphical user interface (or one that isn't working at the moment), you will most likely see a shell prompt after you log in. Typing commands from the shell will probably be your primary means of using the Linux system.

      The default prompt for a regular user is simply a dollar sign:

      The default prompt for the root user is a pound sign (also called a hash mark):

      In most Linux systems, the $ and # prompts are preceded by your username, system name, and current directory name. For example, a login prompt for the user named jake on a computer named pine with /usr/share/ as the current working directory would appear as

      You can change the prompt to display any characters you like and even read in pieces of information about your system – for example, you can use the current working directory, the date, the local computer name, or any string of characters as your prompt. To configure your prompt, see the section “Setting your prompt” later in this chapter.

      Although a tremendous number of features are available with the shell, it's easy to begin by just typing a few commands. Try some of the commands shown in the remainder of this section to become familiar with your current shell environment.

      In the examples that follow, the dollar ($) and pound (#) symbols indicate a prompt. A $ indicates that the command can be run by any user, but a # typically means you should run the command as the root user – many administrative tools require root permission to be able to run them. The prompt is followed by the command that you type (and then press Enter). The lines that follow show the output resulting from the command.

      Using a terminal window

      With the desktop GUI running, you can open a terminal emulator program (sometimes referred to as a Terminal window) to start a shell. Most Linux distributions make it easy for you to get to a shell from the GUI. Here are two common ways to launch a Terminal window from a Linux desktop:

      ● Right-click the desktop. In the context menu that appears, if you see Open in Terminal, Shells, New Terminal, Terminal Window, Xterm, or some similar item, select it to start a Terminal window. (Some distributions have disabled this feature.)

      ● Click the panel menu. Many Linux desktops include a panel at the top or bottom of the screen from which you can launch applications. For example, in some systems that use the GNOME 2 desktop, you can select Applications arr System Tools arr Terminal to open a Terminal window. In GNOME 3, go to the activities screen, type Terminal, and press Enter.

      In all cases, you should be able to type a command as you would from a shell with no GUI. Different terminal emulators are available with Linux. In Fedora, Red Hat Enterprise Linux (RHEL), and other Linux distributions that use the GNOME desktop, the default Terminal emulator window is the GNOME Terminal (represented by the gnome-terminal command).

      GNOME Terminal supports many features beyond the basic shell. For example, you can cut and paste text to or from a GNOME Terminal window, change fonts, set a title, choose colors or images to use as background, and set how much text to save when text scrolls off the screen.

      To try some GNOME Terminal features, start up a Fedora or RHEL system and log in to the desktop. Then follow this procedure:

      1. Select Applications arr Utilities arr Terminal (or go the the Activities screen and type Terminal). A Terminal window should open on your desktop.

      2. Select Edit arr Profile Preferences.

      3. On the General tab, uncheck the “Use the system fixed width font” box.

      4. From the Font field, try a different font and select OK. The new font appears in the Terminal window.

      5. Re-select the “Use system fixed width font” box. This takes you back to the original font.

      6. On the Colors tab, clear the “Use colors from system theme” check box. From here, you can try some different font and background colors.

      7. Re-select the “Use colors from system theme” box to go back to the default colors.

      8. Go to the Profile window. There are other features you may want to experiment with, such as setting how much scrolled data is kept.

      9. Close the Profile window when you are finished. You are now ready to use your Terminal window.

СКАЧАТЬ