% Unix/Linux Software Package Management % Ian! D. Allen - idallen@idallen.ca - www.idallen.com % Winter 2012 - January to April 2012 Topics and Readings (Fedora Textbook) ===================================== * Chapter 13 Software Packages ================= A software package is a bundle of software and configuration files, plus some scripts used to install the software. A software package is a way of distributing software so that it can be easily installed, upgraded, queried, and deleted. Package management systems take all the various files containing programs and data, documentation, and configuration information, and place them in one specially formatted file. The advantage of having a package manager is that you do not have to compile the application on your system to install it. You simply need to have a compiled version of the package - usually called a pre-compiled binary created by someone who is generally more knowledgeable about compiling the package in its most optimized format. You can then install this compiled package/application through the package manager. There are two main systems for package management: RPM and APT/DEB. Two Worlds - RPM and APT/DEB ============================ There are two main systems for managing packages: * RPM packages (**`*.rpm`**): used by Red Hat, Fedora, Mandriva, etc. * APT/DEB packages (**`*.deb`**): used by Debian, Ubuntu, Mint, etc. You can sometimes convert one type of package to another, but other differences in the distributions may mean the package does not install correctly. Packages have version numbers, and are designed to work with certain other packages and distributions of Linux. We will look mostly at RPM package managers this term. YUM - Yellowdog Updater Modified for RPM ======================================== YUM is a high-level package manager that works with RPM packages. It automatically installs or updates dependent software packages, so you don't have to worry about the low-level RPM details. It can contact remote servers to fetch new packages as needed. Usage: yum install package_name yum install grub yum remove package_name yum remove grub yum list # list all packages that are available (thousands!) yum search string # list package names and descriptions matching string yum check-updates # list which packages have updates available yum update [package] # update the given package (or all packages) YUM is preferred over using the lower-level tools such as **`rpm`** that do not know how to use remote servers. RPM - Red Hat Package Manager ============================= The **`rpm`** command is a low-level package manager. Most people use **`yum`** instead. RPM can access packages on remote servers using URLs, but it does not keep track of what is available as YUM does. You may need to use RPM to fix a broken system where YUM doesn't work. RPM has several major groups of options. We will look at Query options and Install options: Query installed packages ------------------------ rpm -qa # lists names of all packages currently installed rpm -qf /bin/ls # find which installed package "owns" a file rpm -q package_name # show full name of installed package with this name rpm -q grub rpm -qi grub # display installed package information rpm -ql grub # lists most files installed by package rpm -qR grub # display dependencies of installed package Some packages have "dependencies"; they depend on capabilities that are provided by other packages. If these dependencies are not respected, rpm will not let you install the package. Install/Remove packages ----------------------- Note: Use the RPM Upgrade option instead of Install - it avoids package conflicts. rpm -i package_file # install the given RPM package_file rpm -v -i dosfstools-2.11-8.fc7.i386.rpm **Upgrade** is used to upgrade an existing package. It installs the current version of package and erases all previous versions. (Use Upgrade instead of Installation option to avoid conflicts.) rpm -U package_file rpm -v -U bash-3.2-20.fc8.i386.rpm Uninstall (erase) a package: rpm -e package_name rpm -e grub Be careful not to erase a package needed by other packages! You can also use RPM to verify packages by comparing the installed versions of files with the versions distributed in the package. Unix/Linux tar file (tarball) ============================= Long before package managers such as YUM, RPM, and APT, there were "tar" archives. Originally written as a magnetic Tape ARchiver, the command is common to every Unix/Linux system. A "tar" archive file is the Unix version of a "zip" file. A "tar" archive, also called a "tarball", is a single file that contains multiple uncompressed files and directories. Unix/Linux software source is often distributed as a "tarball". The syntax of the **`tar`** command is irregular - you don't have to put dashes in front of the operation letters (but you can if you like): tar [options] -f [] Example: tar -cf stuff.tar *.c Example: tar cf my.tar . # create archive of current directory Example: tar -xvf my.tar # extract everything into current dir Example: tar xvf my.tar mydir # only extract mydir from the archive You must always use one of three major operation letters: -t: list the pathnames in the archive -x: extract (all or some) pathnames from the archive -c: create a new tar archive (erases existing contents!) You may optionally use some relevant options: -f: select the output pathname (almost always used; must be last option) -p: preserve permissions when extracting -v: verbose (more messages about what is happening, or more detail) -z: the entire archive is compressed (or uncompressed if extracting) Tarballs may be compressed *as a whole* using the gzip command or by options to the "tar" command itself: $ tar cvf tarball.tar *.c # create tarball.tar verbosely $ gzip tarball.tar # compress into tarball.tar.gz $ tar cvzf tarball.tar.gz *.c # do both of the above in one step $ tar tvf tarball.tar # verbose table of contents (uncompressed) $ tar xvf tarball.tar # extract contents (uncompressed) $ tar tzvf tarball.tar.gz # verbose table of contents (compressed) $ tar xzvf tarball.tar.gz # extract contents (compressed) Tarballs will archive entire directories if you give them directories: $ cd # go to my home directory $ tar czf /tmp/homedir.tar.gz . # archive everything into a file $ cd /some/backupdir $ tar xzpf /tmp/homedir.tar.gz # extract the whole archive The name of the tar archive can be anything; the suffixes are there simply for human readers to better know what the files contain. Compressed tarballs have names such as **`*.tar.gz`** or **`*.tgz`**. * Q: Is a tarball an archive of individual compressed files, or a compressed archive of individual files? -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/ [Plain Text] - plain text version of this page in [Pandoc Markdown](http://johnmacfarlane.net/pandoc/) format