📄 linux-software-install.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><TITLE>Josh's Linux Guide - Installing Software Packages</TITLE> <META NAME="Description" CONTENT="How to install software packages on a GNU/Linux system."> <META NAME="Keywords" CONTENT="software, Linux, packages, install"></HEAD><LINK REL="stylesheet" TYPE="text/css" HREF="default.css"><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#7F007F"><H2><A NAME="0">Installing Software Packages</A></H2><B><FONT SIZE="-1">Created on September 30, 1997</FONT></B><BR><B><FONT SIZE="-1">Last updated on July 19, 2000</FONT></B><BR><B><FONT SIZE="-1">Development stage: Beta</FONT></B><P>If you've ever wondered how everyone else knows how to install softwarepackages and you don't, read on. Here, I'll try to explain what you shouldlook for when you're downloading all sorts of programs from all over, aswell as some examples.</P><P>This covers installing tarred and gzipped archives, not anydistribution-specific software packages. This document should work withall Linux distributions, not just the ones that use RPM. If you're usingRed Hat Linux or any other distribution that uses RPM, you can read up on<A HREF="linux-rpm-usage.html">using RPM</A>.</P><H3><A NAME="1">Summary</A></H3><OL><LI>Download the software, which is usually in the form *.tar.gz.</LI><LI>Extract the archive. Using <B>tar -zxvf archive.tar.gz</B> will usually work.</LI><LI>Do the standard <B>./configure ; make ; make install</B> to configure, compile, and install the software.</LI><LI>If you can't find instructions, try looking for a file called INSTALL or README in the directory.</LI></OL><H3><A NAME="2">Downloading</A></H3><P>The first step in installing a new program is download the archive. These archives usually come in *.tar.gz files (or *.tgz; same type ofcompression, different name) which are stored on FTP servers such as<B>sunsite.unc.edu</B>. On servers that aren't fully dedicated to servingout Linux software, the software you're looking for is usually stored inthe <TT>/pub/linux</TT> directory. A lot of servers also have Unixsoftware in <TT>/pub/unix</TT>, which means they're applications that canrun on all (or most) flavors of Unix, of which Linux is also included. Basically, just use your common sense when browsing or searching forprograms on these FTP servers.</P><P>There are a lot of Linux software archives out there, but you probablyalready have a single program in mind that you want to install. Anyway,here are some FTP sites that contain tons of software you can use withLinux:</P><UL><LI><A HREF="http://sunsite.unc.edu/pub/Linux">http://sunsite.unc.edu/pub/Linux</A></LI><LI><A HREF="ftp://tsx-11.mit.edu/pub/linux">ftp://tsx-11.mit.edu/pub/linux</A></LI><LI><A HREF="ftp://ftp.cc.gatech.edu">ftp://ftp.cc.gatech.edu/pub/linux</A></LI></UL><P>I know I missed at least a couple of good, popular ones. If you'rebored, you can try <A HREF="mailto:jgo@local.net">e-mailing</A> it tome.</P><H4><A NAME="3">Basic Stuff for the FTP Program</A></H4><P>Linux comes with a default <B>ftp</B> program, which probably came withyour distribution. With Red Hat it's NetKit, with Slackware it's somewherein disk set N, and for other distributions I have no idea. Let me know ifyou can help me out here so I won't sound like an idiot. (Too late,huh?).</P><P>Anyway, the <B>ftp</B> program will get you into an FTP server. The wayyou use it is <B>ftp ftp.host.somewhere.com</B>, and you'll be connectedto that server. For example, if I were to connect to sunsite.unc.edu, Iwould type <B><TT>ftp sunsite.unc.edu</TT></B> at the main Linux prompt.If there's an error, like the server being down, just type <B>openhost.elsewhere.com</B> when you're at the "<TT>ftp></TT>"command line.</P><P>Now, on to more important stuff. Like how to get your files. Assumingyou've changed to the directory you want using the <B>cd</B> command (itworks just like MS-DOS), key in <B>ls</B>. If it's a large directory,scroll up using the Shift-PageUp keystroke, use your mouse to highlightthe filename, type in "<B>get</B>, hit the spacebar, and then clickthe right mouse button. Finally, press [Enter] and you should see someFTP language being spit out on your screen.</P><P>Sometimes you may have to get multiple files. Say you want to getthe GIMP, and you've found the directory at <TT>ftp.gimp.org</TT>. Youwant to get everything that starts with "gimp". First typein, at the FTP command prompt, <B>prompt</B>. That's right, just type<B>prompt</B>. That will get the FTP client to stop asking youwhether you want to get each file when you do the next step. (You canalso turn it back on by typing it in again.) Now, use <B>mget</B>followed by any files that you want to get. I suggest using the"*" character to save you some typing. If I wanted to getall the GIMP file, for example, I'd type <B>mget gimp*tar.gz</B> whenin the directory for the GIMP archives.</P><P>After you've downloaded the file, it's in the directory that youstarted the <B>ftp</B> program from. Most software packages can beextracted anywhere, but just move it to <TT>/usr/src/</TT> as a goodhabit. Use <B><TT>mv filename.tar.gz /usr/src/</TT></B> so that itwill be in the directory <TT>/usr/src</TT> now.</P><H3><A NAME="4">Extracting the Package</A></H3><P>Once you've got your package downloaded, it's time to extractit. The method of compression that was used to store it might bedifferent; sometimes people might only use .tar to put all thecontents of a directory in one file, and sometimes they may use GNUzip (gzip), with a file extension of *.gz, which I think is convenientfor compressing single files. Most of the time, though, softwarepackages will come in a *.tar.gz or *.tgz format and will usuallyextract to one or more directories with the files inside them.</P><P>Anyway, now that you've got the file, you should know how toextract it (duh!). If it's a *.tar.gz file or a *.tgz file, you woulduse <B>tar -zxvf [filename]</B>. For example, if you have a file youdownloaded called <TT>gimp-0.99.17.tar.gz</TT> and you downloaded itinto <TT>/usr/local/src/</TT>, you'd do a <TT>cd /usr/local/src/</TT>first and then extract the archive using <TT>tar -zxvfgimp-0.99.15.tar.gz</TT>.</P><P>The <B>tar -zxvf</B> command line will extract a file, showing youthe files and directories which are being extracted. Most Linux/Unixsoftware packages in the *.tar.gz format create a directory afterextraction, but watch out for the ones that don't.</P><H3><A NAME="5">Compiling and Installing</A></H3><P>Most of the time, you'll have to have <B><TT>make</TT></B> installed.This is what helps compile large programs and most Unix software packages.However, before running this, you should help the software get to knowyour system. There's usually a file called <B>configure</B> in thedirectory that was extracted. Run it by typing <B>./configure</B> whenyou're in the directory.</P><P>That will print out a bunch of stuff that mentions stuff about checkingwhether gcc works, if automake is installed, if some .h file can be used,that sort of stuff.</P><P>After running <B>./configure</B> you should have everything ready tocompile. You shouldn't need to worry about optimizing anything right now;you just want that package to run well, which the authors of the softwareas well as the configure script should have already helped set up for.Usually you can just type <B>make</B>, which will compile the source codefor the program. Compiling it is basically taking those text files thatcontain instructions, the source, and converting it into binary files thatwill create your program.</P><P>Sometimes you'll have to type something else after <B>make</B> so thatit knows what to do. I had to do this when installing a mail server.Instead of just <TT>make</TT>, I had to type <TT>make lnx</TT> so that itwould know that I was running Linux. There's <TT>make depend</TT>,which, I guess, configures what depends on what.</P><P>Usually, after the <TT>make</TT>, you'll only need to do a <TT>makeinstall</TT>. Since <TT>make</TT> compiles the binary executables (theprogram), so <TT>make install</TT> installs them to the proper place.</P><H3><A NAME="6">Binaries</A></H3><P>Most software packages under Linux are available as binary packages, aswell. That means you don't have to go to the trouble (or fun) of compilingthe package yourself.</P><P>You should always read the README or INSTALL file, but as a generalrule, you can safely use the <TT>./configure ; make ; make install</TT>procedure. It probably won't compile anything since binaries are alreadypresent, though.</P><H3><A NAME="7">Keeping Logs</A></H3><P>If you are the root user on the system, you should keep a log of wherethe files installed to, in case you ever want to remove them. Create adirectory in your home directory (/root/) called <TT>install_logs</TT>using <TT>mkdir /root/install_logs</TT>. That will create the directory<TT>/root/install_logs</TT> so you can have text files telling you exactlywhere programs installed their files to.</P><P>Where are these text files going to come from, though? Well, assumingthat you use a standard <TT>make install</TT>, just type in <TT>makeinstall > /root/install_logs/program-1.0</TT>, where program-1.0 is thename and version of your software. That basically installs the files wherethey're supposed to be, while at the same time writing to a file exactlywhat would have been echoed out to the screen.</P><P>Even if you already did <TT>make install</TT>, you can still do a<TT>make install > /root/install_logs/program-1.0</TT>. That willreinstall the binaries, but that usually won't matter, since they'rethe same files, just being written to the same place again. I guessthere are some instances where you wouldn't want to do this, butgenerally it's safe to do many <TT>make install</TT> commands.</P><P>This isn't absolutely necessary, but it will help you keep track ofwhere your software files are, in case you want to get rid of them.</P><H3><A NAME="8">Cleaning Up</A></H3><P>Usually when you're done and you know that the program is working, youcan type <B><TT>rm -rf directory</TT></B>, where "directory" isthe directory created when you extracted a file. You won't need thatanymore, because it's just source code, but if you want to look at thesource code and modify the program, you should keep it around.</P><H3><A NAME="9">Tips</A></H3><P>When you can't seem to figure out what to do, just try reading a filecalled INSTALL in the directory that the tarred and gzipped fileextracted. If there is no INSTALL file, check for a file calledREADME.</P><H3><A NAME="10">Related Pages</A></H3><OL><LI><A HREF="linux-rpm-usage.html">Using RPM</A></LI></OL><HR><P>Questions, comments, suggestions, contributions, any feedback at all? Isure would like you hear what you have to say about my work. My e-mailaddress is <A HREF="mailto:jgo@local.net">jgo@local.net</A>.</P><HR><P><B><FONT SIZE="-1">Copyright © 1997-2000 <AHREF="mailto:jgo@local.net">Joshua Go (jgo@local.net)</A>. All rightsreserved. Permission to use, distribute, and copy this document ishereby granted. You may modify this document as long as credit to meis given.</FONT></B></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -