Linux Bible. Christopher Negus

Linux Bible - Christopher Negus


Скачать книгу
back and forth between the workspace with Firefox on it and the one with the Nautilus file manager.

      7 Open a list of applications installed on your system and select an image viewer to open from that list. Use as few clicks or keystrokes as possible.

      8 Change the view of the windows on your current workspace to smaller views you can step through. Select any window you'd like to make it your current window.

      9 From your desktop, using only the keyboard, launch a music player.

      10 Take a picture of your desktop, using only keystrokes.

      IN THIS CHAPTER

       Understanding the Linux shell

       Using the shell from consoles or Terminals

       Using commands

       Using command history and tab completion

       Connecting and expanding commands

       Understanding variables and aliases

       Making shell settings permanent

       Using man pages and other documentation

      Before icons and windows took over computer screens, you typed commands to interact with most computers. On UNIX systems, from which Linux was derived, the program used to interpret and manage commands was referred to as the shell.

      No matter which Linux distribution you are using, you can always count on the fact that the shell is available to you. It provides a way to create executable script files, run programs, work with filesystems, compile computer code, and manage the computer. Although the shell is less intuitive than common graphical user interfaces (GUIs), most Linux experts consider the shell to be much more powerful than GUIs. Shells have been around a long time, and many advanced features that aren't available from the desktop can be accessed by running shell commands.

      The Linux shell illustrated in this chapter is called the bash shell, which stands for Bourne Again Shell. The name is derived from the fact that bash is compatible with the one of the earliest UNIX shells: the Bourne shell (named after its creator, Stephen Bourne, and represented by the sh command).

      Although bash is included with most distributions and considered a standard, other shells are available, including the C shell (csh), which is popular among BSD UNIX users, and the Korn shell (ksh), which is popular among UNIX System V users. Ubuntu uses the dash shell by default at boot time, which is designed to perform faster than the bash shell. Linux also has a tcsh shell (an improved C shell) and an ash shell (another Bourne shell look-alike).

      The following are a few major reasons to learn how to use the shell:

       You will learn to get around any Linux or other UNIX-like system. For example, I can log in to my Red Hat Enterprise Linux web server, my home multimedia server, my home router, or my wife's Mac and explore and use any of those computer systems from a shell. I can even log in and run commands on my Android phone. They all run Linux or similar systems on the inside.

       Special shell features enable you to gather data input and direct data output between commands and Linux filesystems. To save on 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 perform complex operations quickly, which 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. Many 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 PowerShell interpreter used to run commands. 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.

      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, boot up your Linux system. On your screen, you should see either a graphical login screen or a plain-text login prompt similar to the following:

       Red Hat Enterprise Linux Server release 8.0 (Ootpa) Kernel 4.18.0-42.el8.x86_64 on an X86 mylinuxhost login:

      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 number sign or a hash tag):

       #

      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 follows:

       [jake@pine share]$

      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 entering a few commands. Try some of the commands shown in the remaining sections 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 that you should run the command as the root user; that is, many administrative tools require root permission to be able to run them. The prompt is followed by the command that you


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