Saturday, October 31, 2009

Stealing Software from the Network













Stealing Software from the Network


�Network��If you are on the Internet, you can get zillions of programs free for the taking. You can get copies of programs in the same way you get copies of anything else on the Internet — by either using FTP or downloading files from a Web browser, such as Netscape, Opera, or Mozilla. See Chapter 19 for the inside scoop on downloading files from the Internet.


On many UNIX systems, this process is the most common way to get new software. Although most of it is shareware or freeware, even some commercial outfits are now selling their programs that you can download from the Internet.




Tar pits


When you download UNIX software from the Internet, nine times out of ten the filename ends in either .tar, .tar.Z, or .tar.gz. (We get to the most common exception in the next section.) Named, oddly enough, tar files, they don’t have anything to do with black, goopy paving material; tar is short for tape archive. You use this command for backing up (what used to be called "archiving," in the days when people went out of their way to make computers Look Important) UNIX systems to tape. (We discuss this use of tar in Chapter 23.)


In this section, though, you’re seeing tar in its other role, where it moonlights as a software-packaging command. The people who distribute the software use tar to glom into one big tar file all the files that make up the software package (it can have anywhere from just a few to as many as hundreds of files). This way, you download only one big file rather than hundreds of little files. Because tar files are generally so big, the software distributors then squish them even more, using either the compress command (which results in a file ending in .tar.Z) or the gzip command (which results in a file ending in .tar.gz). Using compress used to be the standard, but because gzip results in smaller files, it’s the compression program most people use these days.



�Tip��If you’re familiar with the Microsoft Windows world, you may have come across zip files, which end in .zip. These files are the Windows equivalent of tar files, except that zip combines the glomming and squishing phases into one command, an example of efficiency that true UNIX die-hards would never stand for.


Suppose that you find a really cool editor that you decided you can’t live without, and you download the tar file. It probably looks something horrendous, like really_cool_ed_unix_v.3.4pl6.tar.gz. To unpack your newly acquired tar file, first you have to unsquish it. If the file ends in .tar.Z, type this command:



uncompress really_cool_ed_unix_v.3.4pl5.tar.Z

Otherwise, type this command:



gunzip really_cool_ed_unix_v.3.4pl5.tar.gz

Either way, you end up with a file named really_cool_ed_unix_v.3.4pl6 .tar. Notice that the .Z or .gz is gone? This file is much bigger now that it’s unsquished.


Now you have to untar the file (that’s really the way the UNIX gurus phrase it). This step blows up your tar file into potentially hundreds of little files and puts them into whatever your current directory is. Make sure that your working directory is the directory where you really want all those files to be rather than someplace where you’ll have to move them later. (Moving one tar file where you want it is considerably easier than waiting until after you’ve blown it up into multitudes of files.) Okay, ready? Type this command:



tar xvf really_cool_ed_unix_v.3.4pl5.tar

The x in xvf stands for extract, the v means verbose so that you can see all the files being created, and f is for file and is followed by the name of the tar file.


Don’t get too excited yet, because you still have more to do. Included in the bunch of files you just created should be a file usually named README or INSTALL. This file has the rest of the installation instructions specific to the package you just downloaded.





Revving up RPM


For years, the tar file method has been the only game in UNIX-land for distributing software over the Internet. For UNIX administrators who are accustomed to installing software packages, this method works just fine. Among everyone else, though, a growing number of disgruntled users have clamored for an easier way to install and maintain software. Their calls were answered by Red Hat Linux, which came up with the Red Hat Package Manager (RPM).


RPM is a software-management system that is a substitute for tar. Rather than download a file ending in .tar.gz, you download one that ends in .rpm. The RPM utility unpacks the file, puts all the resulting little files in their correct places, and updates a database of installed software on the computer. If you later want to install an upgrade, RPM remembers that an older version is already installed and saves any existing configuration files while upgrading the necessary files. This feature is enough to generate grumbling from traditionalists about user-friendliness infiltrating UNIX.


An important caveat about RPM is that you can install software this way only if you are the system administrator, which for most people happens only if they have a PC running Linux, as described in Chapter 14. So far, its use has been limited mainly to versions of Linux, although the use of RPM is not necessarily restricted to Linux, and we’ve heard of people using it on other UNIX systems, too.





Unwrapping packages


If you use one of the BSD varieties of UNIX, including FreeBSD (which happens to be the version that Mac OS X is based on, so Mac users should keep reading), NetBSD, or OpenBSD, and if you’re the system administrator and know the superuser password, you can use the package system to install software on your computer. It’s the same general idea as RPM, except of course that it’s different because we wouldn’t want to be excessively compatible.


The program to install packages is called pkg_add. You give it the name of the package, which is a .tar.gz or .tgz (same thing for lazy typists) file. If you already downloaded the package or it’s on a CD-ROM, you give it the actual name of the package file. If not, you can give a URL that says where the package is on the Internet. Either way, type su and enter the password to become the superuser, then run pkg_add:



pkg_add pornotopia-1.1.tgz
pkg_add
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/multimedia/ pornotopia-1.1.tgz



�Tip��Unless someone sends you the URL of a package in an e-mail message or a Web page, the URL can be kind of hard to guess. Many versions of pkg_add have a -r option that looks in some likely places on the Internet to find the package:


pkg_add -r pornotopia


�Warning��Because pkg_add runs as the superuser, you have no protection against software that turns out to be buggy or malicious. The packages from the main distribution site for each system, like www.freebsd.org for FreeBSD, should be fine, but otherwise be very sure of what you’re getting.












No comments:

Post a Comment