Difference between revisions of "Package management in Ubuntu"
m |
m |
||
Line 90: | Line 90: | ||
===Installing Ubuntu packages in background=== | |||
To install Ubuntu packages in background use: | |||
<pre> | |||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q <package-name> | |||
</pre> | |||
Learned from http://askubuntu.com/questions/339790/how-can-i-prevent-apt-get-aptitude-from-showing-dialogs-during-installation | |||
A better way is to provide default values using debconf-set-selections. debconf-show can be used to see possible parameters for which values can be provided. | |||
Example installation script for postfix using debconf-set-selections is: | |||
<pre> | |||
echo "postfix postfix/root_address string saurabh@sbarjatiya.com" | sudo debconf-set-selections | |||
echo "postfix postfix/mailname string localhost" | sudo debconf-set-selections | |||
echo "postfix postfix/destinations string localhost" | sudo debconf-set-selections | |||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install postfix mailutils | |||
sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf | |||
sudo service postfix restart | |||
</pre> | |||
<yambe:breadcrumb>Ubuntu|Ubuntu</yambe:breadcrumb> | <yambe:breadcrumb>Ubuntu|Ubuntu</yambe:breadcrumb> |
Revision as of 03:57, 4 January 2014
<yambe:breadcrumb>Ubuntu|Ubuntu</yambe:breadcrumb>
Package management in Ubuntu
Package management commands
Update package metadata
To get list of latest packages from repository servers use:
sudo apt-get update
Install package
To installing package use:
sudo apt-get install <package-name>
Searching package
To search for a package with name or word in description use:
apt-cache search <word>
List installed packages
To get list of all installed packages use:
dpkg --get-selections
Package information
To get information about package use:
apt-cache show <package-name>
Removing package cache
To delete complete cache, except locks, use:
apt-get clean
Removing obsolete packages
To remove packages that are no longer avaialble in parent repo for download from local apt-cache use:
apt-get autoclean
Packages required for given package
Sometimes a package would require some other package or library to be installed for it to function properly. List of such dependencies can be obtained using:
apt-cache depends <package-name>
Packages that need given package
It is possible that a given package 'A' is required by some other installed package 'B' where 'B' depends on 'A' for it to function properly. To obtain list of all reversly dependent packages [B] for package A use:
apt-cache rdepends <package-name>
Package management tools
Package management tools supported by Ubuntu are:
- aptitude
- ncurses based
- synaptic
- Graphical
Learn more at https://help.ubuntu.com/community/AptGet/Howto
Miscellaneous issues
Copying apt-cache
To copy apt-cache from one machine to other so that the same packages do not get downloaded from Internet again copy contents of folder '/var/cache/apt' to other machine.
Installing Ubuntu packages in background
To install Ubuntu packages in background use:
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q <package-name>
Learned from http://askubuntu.com/questions/339790/how-can-i-prevent-apt-get-aptitude-from-showing-dialogs-during-installation
A better way is to provide default values using debconf-set-selections. debconf-show can be used to see possible parameters for which values can be provided.
Example installation script for postfix using debconf-set-selections is:
echo "postfix postfix/root_address string saurabh@sbarjatiya.com" | sudo debconf-set-selections echo "postfix postfix/mailname string localhost" | sudo debconf-set-selections echo "postfix postfix/destinations string localhost" | sudo debconf-set-selections sudo DEBIAN_FRONTEND=noninteractive apt-get -y install postfix mailutils sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf sudo service postfix restart
<yambe:breadcrumb>Ubuntu|Ubuntu</yambe:breadcrumb>