Kwa wala wanaotumia ubuntu linux tuma hii njia ya command apt

Kwa wala wanaotumia ubuntu linux tuma hii njia ya command apt

Herbalist Dr MziziMkavu

Platinum Member
Joined
Feb 3, 2009
Posts
43,113
Reaction score
34,953
What is apt?

apt is a Debian tool used to manage packages in such a way that when the user asks for a package to be installed the system also installs (or upgrades) all the necessary packages to make the package work.
The apt we're documenting here is the version that works with rpm files.

To use apt-get and its friends, you'll have to install the package apt. If your GNU/Linux vendor supports apt, you'll find it at his FTP site.

[TABLE="class: WARNING, width: 100%"]
[TR]
[TD]Warning[/TD]
[/TR]
[/TABLE]
[TABLE="class: WARNING, width: 100%"]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]This is a development version. It may screw up your system, so use it at your own risk.[/TD]
[/TR]
[/TABLE]



Installing and configuring your system for apt

To use apt you'll have to do the following procedure:


  1. become root user
  2. install the apt package with either rpm -ihv or rpm -Uhv. This package can be obtained from your vendor's site (if he supports apt or maybe even from your distribution CD).
  3. run apt-get update to download the package's database from the default server[1]
  4. run apt-get check, so that apt can verify if your box is OK and all package's dependencies are correctly satisfied
    Note: If your system isn't seriously broken, you'll be able to fix it with apt-get -f install. If its broken, you'll have to fix these dependencies by hand (I mean, using the rpmcommand) before start using apt.
    ​
  5. If everything goes fine, you'll be able to use apt-get's and other apt's commands listed later in this document.

    How to use apt-get

    apt-get's commands are very easy and intuitive.
    Its commands follow this structure:
    [TABLE="width: 100%"]
    [TR]
    [TD="bgcolor: white"] # apt-get [options] command

    # apt-get [options] install package [package ...]
    [/TD]
    [/TR]
    [/TABLE]
  6. The command line may be a variation of the following basic types:
  7. apt-get updateUpdates apt-get's local database with server's pkglist's files.
  8. apt-get checkverifies system's integrity using apt
  9. apt-get install some-packageinstalls some new package, automatically resolving and downloading dependent packages
  10. apt-get upgradechecks for outdated packages in the system and automatically upgrades them
  11. apt-get dist-upgradesame as apt-get upgrade, but installs all base packages and tries to upgrade everything, installing new packages if needed
  12. apt-get remove some-packageremoves the some-package package and all other packages that depends on it
  13. apt-get cleanremoves the downloaded packages from the cache directory (/var/cache/apt/archives/), freeing some disk space at your system ;-)



    How to use apt-cache

    Besides apt-get there's also apt-cache.
    apt-cache is a command to manipulate and obtain information from the packages at apt's cache.
    This command is not to be used by common users. You'll like it if you're developing something to be used with apt.
    apt-cache addAdds a package file to the source cache.
    apt-cache gencachesBuilds both the package and source cache
    apt-cache showpkgShow some general information for a single package
    apt-cache statsShow some basic statistics
    apt-cache dumpShow the entire file in a terse form
    apt-cache dumpavailPrint an available file to stdout
    apt-cache unmetShow unmet dependencies
    apt-cache checkCheck the cache a bit
    apt-cache searchSearch the package list for a regex pattern
    apt-cache showShow a readable record for the package
    apt-cache dependsShow raw dependency information for a package
    apt-cache pkgnamesList the names of all packages
    apt-cache dottyGenerate package graphs for GraphVis

 
Using apt-cdrom and apt-config

apt-cdrom is a simple command to add CDROMs to apt's sources.list file. Its syntax is a variation on this basic command line:
[TABLE="width: 100%"]
[TR]
[TD="bgcolor: white"] # apt-cdrom add
[/TD]
[/TR]
[/TABLE]

apt-cdrom uses information from your /etc/fstab if you don't specify where's the CDROM drive.

apt-config is a tool to read apt's apt.conf file and is very useful to dump it to screen. Its syntax is a variation of these basic options:


apt-config [options] shell
Shell mode

Creating a repository

To setup an apt-get repository, you'll need to have an HTTP or FTP server with the standard distribution package tree and its base directory. The top of the directory tree must be in/etc/apt/sources.list.
Note: Other methods besides HTTP and FTP are still untested.
​
You'll have to make sure that the files available at this server can be accessed. You can use any browser or web tool and try downloading a file for testing purposes. Doing this test will eliminate server's misconfiguration problems now.
You'll need the following directory structure:
main directoryit will contain license files, directories with source packages, directories with binary packages, etc. Its exactly like the root directory on a CD.
vendor directorythis is a holder for other directories that will have the binary packages.
repositoriesthese are the directories that, inside the vendor directory, will contain the packages. Its name must start with RPMS., i.e., the word RPMS in upper case followed by a dot. After the dot you'll put the name that you want to associate with these files. One example is beta or official for, respectively, the beta and official versions of your distribution.
a base directorythis directory will have the pkglist files with packages names and dependencies.



With all these directories you'll be able to configure your sources.list file to access the repositories you've created.
Example 1. /etc/apt/sources.list
[TABLE="width: 100%"]
[TR]
[TD="bgcolor: white"] rpm http://joes.box.com/stuff 5.1/conectiva cds security[/TD]
[/TR]
[/TABLE]

With configuration shown at Example 1, the repository tree needs to be something like what's described at Example 2.

Example 2. Server tree

[TABLE="width: 100%"]
[TR]
[TD="bgcolor: white"] /home/httpd/stuff
/home/httpd/stuff/5.1
1.gif

/home/httpd/stuff/5.1/lots-of-README-and-LICENSE-files
2.gif

/home/httpd/stuff/5.1/SRPMS
/home/httpd/stuff/5.1/conectiva
/home/httpd/stuff/5.1/conectiva/base
/home/httpd/stuff/5.1/conectiva/base/hdlist.cds
/home/httpd/stuff/5.1/conectiva/base/hdlist.security
/home/httpd/stuff/5.1/conectiva/base/pkglist.cds.bz2
/home/httpd/stuff/5.1/conectiva/base/pkglist.security.bz2
3.gif

/home/httpd/stuff/5.1/conectiva/RPMS.cds/
4.gif

/home/httpd/stuff/5.1/conectiva/RPMS.security/
5.gif

/home/httpd/stuff/5.1/conectiva/etc-etc[/TD]
[/TR]
[/TABLE]
This is the top of the repository treeThis is the top for a specific version, 5.1 here.We've generated this control file...And also this one.This includes the packages available at Conectiva's CDsThis includes the packages that have security fixes
Note: The names cds and security are arbitrary. In practice you can call them the way you want. The only restriction is that they need to be a logical or physical division of the repository tree.
​
7.1. genbasedir

Every repository needs to have a package index file which will contain the list of every package available, their descriptions and dependencies. This file is named pkglist and is bzip2 compressed.
To generate the pkglist files you need to go to the base directory in the repository and run genbasedir. It will create the bzip2 compressed files.
Example 3. genbasedir's syntax
[TABLE="width: 100%"]
[TR]
[TD="bgcolor: white"] # genbasedir [-s | --sign] [--topdir=dir] distribution component [component ...]
[/TD]
[/TR]
[/TABLE]

Where, for each element of Example 3 we have:
-s or --signusing this parameter you'll be able to sign your pkglist files. This will prompt you for your gpg passphrase and will create a file named hashfile.gpg at the same directory.
--topdirthis parameter specifies the top directory where your repository is found. It's the corresponding directory to the URL specified at your sources.list file.
distributionis the name of your GNU/Linux distribution. It's usually your vendor's name with some version or other identifier appended to it. It's also at your sources.list file.
component(s)this (or these) are the places where your rpm files are located. You'll have to put here the same suffix you've used before or things won't work...

Then, for Example 2 we'd have:
[TABLE="width: 100%"]
[TR]
[TD="bgcolor: white"] # genbasedir --topdir=/home/httpd/stuff 5.1/conectiva cds
# genbasedir --topdir=/home/httpd/stuff 5.1/conectiva security
[/TD]
[/TR]
[/TABLE]




apt-config [options] dump
Show the configuration options in the screen

 
Common apt commands

apt-get install <package> Downloads <package> and all of its dependencies, and installs or upgrades them.
apt-get remove [--purge] <package> Removes <package> and any packages that depend on it. --purge specifies that packages should be purged.
apt-get update Updates packages listings from the repo, should be run at least once a week.
apt-get upgrade Upgrades all currently installed packages with those updates available from the repo. should be run once a week.
apt-get dist-upgrade [-u] Similar to apt-get upgrade, except that dist-upgrade will install or remove packages to satisfy dependencies.
apt-cache search <pattern> Searches packages and descriptions for <pattern>.
apt-cache show <package> Shows the full description of <package>.
apt-cache showpkg <package> Shows a lot more detail about <package>, and its relationships to other packages.
man apt Will give you more info on these commands as well as many that are in less common usage.



Common dpkg commands

dpkg -i <package.deb> Installs a package file; one that you downloaded manually, for example.
dpkg -c <package.deb> Lists the contents of <package.deb> a .deb file.
dpkg -I <package.deb> Extracts package information from <package.deb> a .deb file.
dpkg -r <package> Removes an installed package named <package>
dpkg -P <package> Purges an installed package named <package>. The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.
dpkg -L <package> Gives a listing of all the files installed by <package>. See also dpkg -c for checking the contents of a .deb file.
dpkg -s <package> Shows information on the installed package <package>. See also apt-cache show for viewing package information in the Debian archive and dpkg -I for viewing package information extracted from a .deb file.
dpkg-reconfigure <package> Reconfigures an installed package
man dpkg Will give you more info on these commands as well as many that are in less common usage.

 
apt-command sio kwamba inainstall package tu bali inainstall na all dependences...and its the most appropriate software installation in any linux or unix based system coz it takes care of the dependences and installs the most update version of the software......
 

Similar Discussions

Back
Top Bottom