Section 3.1. What is the Command Line?


3.1. What is the Command Line?

Unlike Windows, the GUI is completely optional in Linux. If you're feeling particularly competent, or you have certain requirements (or very old hardware), you can run your Linux machine with no graphics at all. As Linux has evolved, a variety of GUIs have been built on top of it, but the command line remains the administrator's best friend: a quick, easy, powerful way to perform actions that aren't always easily available from the desktop.

Figure 3-1. Accessing the GNOME Terminal.


Throughout this book, we'll use the GNOME Terminal application to gain access to the command line. You can access this application from Applications > System Tools > Terminal, as shown in Figure 3-1. The terminal itself is depicted in Figure 3-2.


Tip: The GNOME desktop environment is fully customizableand that includes the appearance of the terminal. You can determine the font that's used, change the foreground and background colors of the windowyou can even set the level of transparency of the window itself, so that it's possible to see the desktop image behind the window! Within the terminal, you can find these settings in Edit > Current Profile….

Figure 3-2. The GNOME Terminal application.


Let's look at a real-life example that uses the command line to meet a specific need. Once you understand the components of the command (and the complexity of the graphical alternative) , you'll begin to understand the practical utility of the terminal and the command line.

[kermit@swinetrek ~]$ find /var/backup/* -ctime +5 -exec rm {} \;

I use this command regularly to remove from my system backups that are more than five days old. The command uses the find tool to search for files in the /var/backup directory that are more than five days old. For each file that the find tool locates, it runs the rm command: rm is the standard "remove file" command. Running this command regularly helps to save system storage space by deleting backups that, after five days, have become unnecessary. Of course, this command should be run in conjunction with an automated process that creates these backups every day or so.

Let's compare the use of this command to the process of utilizing a graphical tool to accomplish the same task.

  1. Reach from the keyboard for the mouse.

  2. Double-click on the Computer icon on the desktop.

  3. Double-click on Filesystem to get to the root directory.

  4. Double-click the var folder to open it.

  5. Double-click the backup folder.

  6. Ensure that the resulting window displays the creation time of the files by selecting View > View as List.

  7. Holding down Ctrl, select the files with a creation date older than five days.

  8. Right-click and select Move to Trash from the context menu.

  9. To really delete the file, return to the desktop and empty the trash by right-clicking on the Trash icon and selecting Empty Trash.

You don't need to understand the intricacies of the Linux filesystem to see the advantage of the command line. The graphical approach involves at least ninelikely many moremouse clicks. Rather than viewing the process of finding and deleting these files as single operation, you're forced to break the process down into its individual components. Add to that the inefficiency of using the mouse to locate, point at, and click targets on the screen, as compared to the swift simplicity of entering commands via the keyboard , and you start to understand how the command line can be a valuable and efficient tool for system administration.

This, however, doesn't even address the real beauty and power of the command line. You don't believe that I actually run the rm command three times a week, do you? That would also be terribly inefficient: I'd be relying on my own porous memory to make sure that the backups were removed! In fact, most of the commands you'll use in Linux are fully scriptable, with minimal modification. In reality, I've asked my system, via the cron utility (which we'll cover in depth in Chapter 4) to execute the command three times each week. This is much like the Scheduled Tasks feature in Windows, but it's more powerful: it can do just about anything. As you can see, an understanding of Linux commands and command line concepts is essential, even if you only open a terminal window occasionally.




Run Your Own Web Server Using Linux & Apache
Run Your Own Web Server Using Linux & Apache
ISBN: 0975240226
EAN: 2147483647
Year: 2006
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net