Built-in Programs and External Programs the output beside the Bash shell, which was used to launch it. Try it out by typing csh, followed by ps: $ csh $ ps PID TTY TIME CMD 5355 pts/0 00:00:00 bash 5389 pts/0 00:00:00 csh 5409 pts/0 00:00:00 ps It should be noted that when we say that we ’switch’ to another shell, we do not actually exit Bash and start csh; rather we use bash as the launchpad to start another shell, in this case csh. We’ll be looking at the ps command in more detail in the next section. Built-in Programs and External Programs There are two different types of command that can be executed from a shell. They are built-in programs and external programs: Built-in programs are inherently built into the shell: All shells share a common set of built-in programs, such as the cd command, which enables us to change directory. In addition, there are other built-in commands that are specific to certain flavors of the shell. For instance, the amend method for setting environment variables usually varies from one flavor of the shell to another. We shall see more on setting environment variables later in this chapter. External commands are those that are independent of the flavor of shell. They can be executed from any shell and yield more or less the same result. For instance, the date command would output the date no matter what shell it is executed from. For the purpose of our discussion, we shall refer to both built-in commands and external commands by the generic term, command. Checking Compatibility of a Command with a Shell Of course, when we’re working within a particular shell, we can use only the built-in commands that are valid for that flavor of shell. As we’ll see later, this is particularly important when we write a shell script - a file that contains a sequence of shell commands. If we run a shell script within a particular shell, then it should contain only commands that are valid for the shell in question. To this end, it is useful to be able to check whether a given command is a built-in or an external command. For this, we can use the type command. This command tells us whether it is a built-in command within the current shell, or (if it is an external program) the location of the command. For example, in the Bash shell, if you use type to query the nature of the date and cd commands, you’ll find that the former is external and the latter is built-in: $ type date date is /bin/date $ type cd cd is a shell builtin 163
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services
November 2006
Thu 30 Nov 2006
Thu 30 Nov 2006
Different Types of Shell As well as allowing us to simply execute commands, the shell enables us to manage the execution of commands. It allows users to define shortcuts and abbreviations to refer to these commands and even to serve as a handy tool for knitting together commands to create conglomerates that function as new commands (they’re called scripts). In terms of flexibility, performance, task automation, and repetitive processing of tasks, the shell in the hands of a knowledgeable user still beats a GUI hands down. Different Types of Shell The earliest versions of UNIX came with what is today known as the Bourne shell (also known as sh), named after its inventor, Steve Bourne. Since then a variety of shell flavors have emerged. However, the core functionality and basic syntax of all of these shells has changed very little. The C-shell (or csh), distributed as part of BSD UNIX, was the next popular flavor of the shell to arrive. The C-shell syntax resembles the C programming language (particularly when it comes to writing shell scripts), hence its name. This aspect of the C-shell was intended to popularize it among the UNIX users, who at that time were largely C programmers. Other popular shells soon arrived - each with more features than the last, while all being backward compatible for the most part. Among them were the Korn shell (or ksh), which was written by David Korn of AT&T Bell Laboratories, and tcsh or the C-shell with command-completion features - that is, the shell ‘intuitively’ completes the commands when we type them in. The Born Again shell (or Bash) is one of the newer flavors of the shell, and is almost completely compatible with its ancestor, the Bourne shell. It is interesting to note that most Unix systems have sh available apart from a preferred flavor of the shell for that Unix system. In fact, some Unix systems make several shells available, and the user may switch between them at will. As far as Linux (and therefore Red Hat Linux 9) is concerned, Bash is the preferred shell, although users may switch to other shell flavors (for example, you can switch to the C-shell by typing csh at the Bash prompt). The choice of a shell is often dictated by personal preference, sometimes by the fact that a user started of with a particular flavor, or sometimes, as in the case of the C-shell, the programming language the user is comfortable with. In this chapter we focus on using the default shell, Bash, to illustrate features of the shell. Let’s begin the chapter by trying to find out what your current shell is. We can figure this out by typing the ps command in any terminal window at the command prompt. The ps command lists the processes - that is to say, the currently executing programs on your system: Note The command prompt is depicted as $ for brevity, it is usually [user@localhost current directory] by default. We shall learn more on setting the prompt later in this chapter. $ ps PID TTY TIME CMD 5355 pts/0 00:00:00 bash 5381 pts/0 00:00:00 ps On executing the ps command, we should see an output similar to the one above. On the last column of the second line of the output we see bash. If we were to switch to a different shell, say csh, we would see csh in 162
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services
Thu 30 Nov 2006
Chapter 6: The Shell Overview Before graphical user interfaces came into vogue, the only way to interact with an operating system was via the command line shell (often known simply as the shell). The shell allows users to type in commands for the operating system and the operating system to display the output that results from the execution of these commands. Despite the rise of GUIs like GNOME and KDE and predictions of the complete demise of the command line shell, the shell has held steady as the user interface of choice for a large number of users - sometimes as a last resort when the GUI fails, but often simply because it is a very flexible and powerful tool. In fact, the shell has evolved into a tool that allows users to do pretty much all that can be done using the operating system - far beyond what a GUI would permit. In this chapter, we’ll be discussing the following: The concepts of a command line shell and its background Shell commands, shortcut keys, and aliases The command line syntax Managing multiple tasks at the same time Using the shell as a scripting language The Shell as a Command Line Interface An operating system such as the Linux kernel consists of code written mostly in the low-level programming language C. The kernel is loaded into memory at the time the machine boots up, and sits there awaiting instructions. There are a number of ways for us to pass instructions to the kernel. One of the most important is to write programs that interact with it - once a program is written, you may compile and execute it to accomplish the task. Since programs written to interact with the kernel often have several tasks in common, there is usually a library of these common tasks, which is a collection of C subroutines (or functions as some might call them) organized into a library. This is simply known as the C library or the libc. While programs that use the C library are powerful and flexible, it is often cumbersome, if not downright impractical, to write a program, compile it, and run it every time we need to do something as simple as copying a file. This is where the shell comes in. The shell is a declarative and parameterized mechanism for executing common tasks. What this means is that the shell allows us to execute programs that are generic enough to take parameters. For example, by using the file copy program cp, supplying a source file and a destination file as parameters (also known as arguments), it is possible to copy a file from one location to another in the file system. The power of the shell comes from the wide gamut of programs that can be executed from it. These programs are what are commonly known as UNIX commands. As some readers might have guessed by now, the shell itself is another program. 161
Hint: This post is supported by Gama besplatan domen provider
Thu 30 Nov 2006
Emulators Wine Wine is an application that implements the Windows Application Programming Interface (API) on top of the native X Window System that is used by the GNOME and KDE graphical environments. It’s more of a compatibility layer than an emulator, but it does allow Windows applications to run. The latest version and more information can be found at Wine’s web site at http://www.winehq.com/. Most recent release of the Wine RPM packages can be found at http://mecano.gme.usherb.ca/~vberon/wine/, and the instructions for installing Wine and troubleshooting problems that you encounter can be found within the Wine User Guide, at http://www.winehq.com/Docs/wine-user/. Summary In this chapter we’ve touched on a variety of applications installed by default in Red Hat Linux 9. In some cases, we’ve discussed how they can be extended to provide yet further functionality. In fact, there are thousands of quality applications that are available either within the Red Hat Linux distribution or via the Internet, in some cases freeware thanks to the Open Source Foundation and the GNU Project. In other cases, shareware is available at a small cost, again via the Internet. We started by covering the OpenOffice suite of applications commonly used for office productivity. We touched on a couple of Internet applications - the Mozilla browser and the GAIM Instant Messenger application - and the Evolution personal information management tool. We skipped through a number of multimedia applications, which provided various audio and graphical facilities, and took a look at some of the more essential system tools - the gedit text editor, the Nautilus file manager, the File Roller compression tool, and the VMWare emulator. There is such a wealth of functionality available that you shouldn’t have trouble finding the application you need to do the job you want - whether it’s included in the Red Hat Linux 9 distribution or out there on the Internet somewhere. We’ll cover some more applications in Chapter 13. And if there’s nothing out there that fits your requirements, you could always start off your own Open Source project. In the end, you can achieve in Linux everything that you’d expect to be able to achieve on other platforms. 160
Hint: This post is supported by Gama besplatan domen provider
Wed 29 Nov 2006
A File Compression and Archiving Application This application
Posted by sales under redhatNo Comments
Emulators This starts the process of adding the files to the archive, compressing as we go. Emulators We’ve discussed various interoperability features of the applications in this chapter. For example, we’ve seen how OpenOffice is able to load and save files in formats like the Microsoft Office formats, and other non-native formats. In addition to these features, there are a number of emulators in existence. An emulator implements another (virtual) operating system within Linux, and hence you can run executables that are native to that operating system. Hence, we can (for example) run an emulator application that simulates the Microsoft Windows operating system running within Linux, and hence allows us to run Microsoft Windows Applications (binary files) untouched in their native format - from within Linux! The concept of emulators is not new, and they’re not unique to Linux. There have been many different emulators, for lots of platforms - mainly targeted at those who wish to recapture their youth or take a trip down memory lane. Among the most common emulators are those that simulate 8-bit home computers like the Sinclair ZX Spectrum. However, what’s far more impressive is the fact that emulators are available for simulating complex operating systems such as Microsoft Windows. In this section of the chapter we will discuss some of the emulators available. We won’t cover emulators in detail - it’s a large and complex topic, and the online documentation provided by the suppliers of some of these emulators is more than sufficient to get you started. But we will mention a couple of emulators, so you can start to get an idea of what they’re about. VMWare The VMWare application is an Enterprise Class virtual machine that can run multiple versions of an operating system on a single computer. For example, you could run multiple versions of the Windows operating system on a single Linux machine. More information can be found at http://www.vmware.com/. An example screen is shown below, demonstrating Windows XP running under VMWare on a Linux box: 159
Hint: This post is supported by Gama web hosting hrvatska services
Wed 29 Nov 2006
A File Compression and Archiving Application This application
Posted by sales under redhatNo Comments
A File Compression and Archiving Application This application is very similar to the Windows Explorer application you find in Microsoft’s Windows operating systems. It allows you to move up and down directory trees by double-clicking the icons. It also allows you to create new folders, move files, and cut and paste directories and files. A File Compression and Archiving Application While Nautilus allows you to manage your files, you’ll also find times when you need to archive files into a single compressed file in the style of PkZip. The File Roller application provides a graphical user interface to compressed files, allowing you to archive files and extract items from existing archives. It’s very similar to the WinZip utility for Microsoft Windows, which also provides a graphical interface to the PkZip utility. To start the File Roller application, select Main Menu | Accessories | File Roller or type file-roller at the command line: File Roller supports a number of compressed file formats including .zip, .lzh, and so on. It can be used to create new archives using the Archive | New menu option, to open existing archives, and to extract files from these archives. For example, to create a new .zip archive, select the Archive | New menu option and enter a filename in the field provided (here, I’m creating a new file called /home/markm/screenshots.zip): Then you can add files using the Add shortcut icon or the Edit | Add Files menu item. This will prompt you to select the files you wish to add. The screenshot below shows the window after adding all the files from the /root/anaconda-screenshots directory, that we took while writing Chapter 1: 158
Hint: This post is supported by Gama web hosting hrvatska services
Wed 29 Nov 2006
A File Management Application Of course, you could use editors such as OpenWriter to edit such documents, but the formatting and functionality provided with applications like OpenWriter is really overkill for configuration files and similar documents. This is where gedit is very useful. The gedit application is similar to Notepad or Wordpad in MS Windows, and is an effective text editor with a nice graphical user interface. To launch gedit, choose Main Menu | Accessories | Text Editor, or type gedit at the command line: A File Management Application A file manager is a GUI that allows you to manage and navigate the various drive types and directory structures on your system and network. Given the size of hard disks today (60GB is normal), and the capacity of CD-ROM drives, DVD-ROM drives, not to mention your local area network, the ability to quickly navigate and manage the files of such devices is extremely important. To start you off navigating your file system, Red Hat Linux places a link to your home directory (/home/
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services
Wed 29 Nov 2006
Graphics Applications PDF Viewer The PDF Viewer is another simple application, whose functionality is limited to viewing PDF files on-screen. To start the PDF Viewer, select Main Menu | Graphics | PDF Viewer or run the xpdf application from the command line. To access a file, use the right-hand mouse button and select Open from the menu. From the command line you can view a PDF document, specifying it as the first parameter on the command line. If we wanted to display the file chapter05.pdf, we would use the following command: $ xpdf chapter05.pdf If you want to convert a document into PDF format, there are a number of ways to achieve this. In essence it involves converting to the postscript file format, and then using a utility to convert to the PDF file format using the PS2PDF converter supplied with Ghostscript. For more information, see http://www.pathcom.com/~kujira/pdf_idx.htm. OpenDraw The OpenDraw application is installed as part of the OpenOffice suite, and is similar to the Microsoft Draw application that is now embedded within Microsoft Word. It allows you to draw diagrams using a variety of 2D- and 3D-objects and shapes, group and color them, and then embed your diagrams into your OpenOffice documents. It also supports the generation of graphs and the manipulation of text within your image. System Applications There are numerous other applications available and installed with Red Hat 9. Half the fun of a new operating system is exploring all these applications. There is much that isn’t installed by default, but is available on the Internet as freeware. In this section of the chapter we’ll talk about some of the handy system utilities and bread-and-butter applications that are usually not so exciting but are there to make your life easier. The applications we’ll examine here are the file managers, file compression utilities, and emulators. A Simple Text Editor For many users, the way in which tasks are accomplished primarily via GUI-based applications is a big attraction. Unix has always been associated with command line input, and it was not until the X-Windows system provided a GUI front-end that things become easier. One application that lends itself to this method of input is the simple text editor. 156
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services
Tue 28 Nov 2006
Graphics Applications As you can see, the GIMP application is a discrete window containing a menu, an icon toolbar, and color information. Each new image is seen in its own separate window (not shown here), which carries its own menu (accessed by right-clicking on the image). The application is considerably more powerful than Microsoft Paint, and its features are more closely aligned with applications such as Photoshop or Paint Shop Pro. For example, it supports: Numerous paint tools Support for layers and channels Advanced scripting and plug-in capabilities Gradient editor and blend tools Transformation support such as rotate and scale Multiple file formats The GIMP’s features are too numerous to list in detail, and again we will leave you to play with the application. The online documentation (found at http://www.gimp.org/docs.html) is very thorough and this can be supplemented by the documentation found at its main web site (at http://www.gimp.org/). In addition, a large collection of resources, available from the web site, covers patterns, palettes, brushes, gradients, scripts, and fonts, and contains links to other important web sites for The GIMP (such as a plug-in registry at http://registry.gimp.org/index.jsp and the very useful GIMP User Group - or GimpForce - at http://gug.sunsite.dk/). GQView GQView is a simple application that allows you to view a number of graphical images simultaneously. You start by selecting the directory in which the graphic files exist, and then either selecting the file from the left-hand pane with its image being displayed in the right hand pane or using the Slideshow feature available on the View menu. To start this application, select Main Menu | Graphics | More Graphical Applications | GQView Image Viewer or run gqview from the command line. The screenshot below shows the utility being used to display screenshots from the Red Hat Linux installation process that we covered back in Chapter 1: 155
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services
Tue 28 Nov 2006
Graphics Applications We won’t dwell on this application, but we’ll note that the user interface is again easy to use and provides a simpler (if less flexible) alternative to the cdrecord option. You simply use the top part of the dialog to locate the files you want to record, drag them across to the bottom part of the dialog (which represents the CD-ROM drive), and select the Record option. Graphics Applications There are numerous graphical applications installed within Red Hat Linux; some exist as part of KDE or GNOME. Others can be found within application suites such as OpenDraw (which is included within OpenOffice), and yet others are standalone applications written for the sole purpose of manipulating images. In this chapter, we’ll concentrate on the applications that are installed by default with Red Hat Linux 9: The GIMP, PDF Viewer, GQView, and OpenDraw. Most of these are contained within the Graphics package group (which you’ll find under the Applications category of the RPM), and can be found in the Main Menu | Graphics menu. The GIMP The GNU Image Manipulation Program (or GIMP, as it’s affectionately known) is a very powerful piece of software used for graphic manipulation and is equally at home as a simple paint program as it is at retouching photographic images you may have. It may be extended using the plug-in technology common to a number of Linux applications but may also be enhanced by using the internal scripting interface that allows you to automate tasks. The GIMP has been released under the GNU General Public license and as such is freely distributed software. It is installed by default within Red Hat Linux 9 and it has a web site at http://www.gimp.org/, where you’ll find documentation, support, and downloads. You can start the application by selecting Main Menu | Graphics | The GIMP, or by typing gimp at the command line. A variety of configuration and control windows appear when you start the application, and you can control which dialogs are open at any given time by using the File | Dialogs menu of the main GIMP window (which is the top-left of the three windows shown below): 154
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services