How to Install packages from the repository using AptEdit
Installing packages from the repository is easy in Ubuntu as we have really user-friendly tools. Tools exist in both the GUI and Command Line forms. Though many users feel easy to use the GUI front end called Synaptic Package Manager,(under Kubuntu, the GUI front-end is called Adept) it still uses the dpkg as the back-end. Many users also feel its easy and fast to use the command line tool called Apt. It is common to get a reply "do an apt-get install" whenever a query on installing some packages occur. This also binds us and reminds us of the root links to the Debian.
In this How-To we will have a look at how to install a package using apt tool.
Updating the Package IndexEdit
Apt maintains a index of packages available in the repository. Thus, when we search for a package or as apt to install a package, it is first searched in this list to determine in which exact repository does the package has to be retrieved from. As newer versions and improvements of packages occur quite often, it is necessary to keep the package index updated to the latest improvements. This can be done with the update option of theapt-get command.
update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list.
Before starting an installation or searching a package, if you have not updated the package index off late, run the following command..
- $ sudo apt-get update
(Important - the above command requires admin privileges and hence sudo has to be used) Note, you'll be prompted for a password, that won't be echoed on to the screen. Type in the password of the user you created first, during the installation of (K)Ubuntu Linux.
This will be followed by fetching the package lists from the various repositories mentioned in the sources.lst file and the package index will be rebuild. This will take time depending upon how big the sources.lst file is. If any error is shown regarding a repository, please comment that particular repository and try again building the package index.
Finding the PackageEdit
Often we are not aware of the exact package name or rather want to see a list of similar packages. For example, if we are looking for a editor to use, we would like to have a list of editors that are available in the repos. Also, we would like to install more than one of the alternatives, as well as, we would like to install additional package related to a main package such as special modes for emacs.
To find a list of packages for a particular type or application we can use apt-cache search <package-name>command. For example, to find emacs and related packages type the following in the terminal.
- $ apt-cache search emacs
(Note - This command do not need the use of sudo keyword)
This will show us a list of packages that are related to emacs. We can focus down to specific packages and related items by altering the <package-name> argument of the command (such as emacs21 for emacs21 related packages). This is very useful when we do not know the exact package but only know partial name of the package, we can find the exact package name.
Also, this will help us find similar packages for an application. For example, we can find the command line browsers available by typing command line browser instead of the package in the same command. This will show a list of command line browsers available.
Installing with apt-get installEdit
Once we know what package to install or a list of package names to install, then we can install them usingapt-get install <package-name>.... command. When we have more than one package to install separate them by a single space. The main advantage of this tool is that all the dependencies for the specified packages are found out and installed along with the package. Also, suggested packages are listed so that we can install added functionality. Mostly, it confirms with a yes/no before proceeding the install, after showing the size of the files to be downloaded and the space they will occupy after installation.
For example, to install emacs21 package issue the following command in the terminal..
- $ sudo apt-get install emacs21
This will download emacs21 package along with its dependencies from the repos and install it in the system. Once the installation is done, the shell command prompt is returned.
We can also use basic regular expressions to specify a group of package names to be installed. For example, to install all packages under sun-java6, whose names obviously start with sun-java6, issue the following command..
- $ sudo apt-get install sun-java6-*
This will install all the 9 packages under sun-java6. But, be aware that the use of regular expression might match packages you do not require as well as older versions. The regular expressions can also be used onapt-cache search command as well.
It is recommended that you use following command for more information about this utility:
Explained below are: --purge --reinstall --simulate --download-only parameters of apt-get utility: --purge = Use purge instead of remove for anything that would be removed. An
asterisk ("*") will be displayed next to packages which are scheduled to be purged.
--reinstall = Re-Install packages that are already installed and at the newest
--simulate = No action; perform a simulation of events that would occur but do
not actually change the system.
--download-only = Downloads only specified source files or simply files from the
source.It does not install any related dependencies to the specified file. OR
You can try aptitude a text mode installer and some times even prefered over GUI (synaptic) it has all the facilities including search and all.