Monday, November 5, 2007

Maintenance

apt-get update -- Run this after changing /etc/apt/sources.list or /etc/apt/preferences. You also must run it periodically to make sure your source list is up-to-date. This is the equivalent of “reload” in Synaptic, or “check for updates” in Windows or OS X.
*

apt-get upgrade -- upgrades all installed packages. This is the equivalent of “mark all upgrades” and “apply” in Synaptic in one step.
*

apt-get dist-upgrade - upgrades the entire system to a newer release. The same as the above, except add the “smart upgrade” checkbox -- i.e. tell APT to do whatever it has to do to upgrade to the latest packages, even if it means removing some other packages. (NB this is not a recommended way of upgrading to a new release)
*

apt-get -f install -- the same as “Edit->Fix Broken Packages” and “Apply” in synaptic. Do this if you get complaints about packages with “unmet dependences”.
*

apt-get autoclean - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, apt-get clean is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes.
*

apt-get clean -- the same as above, excecpt remove *all* packages from the package cache. Usually you don’t need them, so this is smart if you’re running low on disk space. If you’re on dial-up, you might reconsider.
o

The package cache is in /var/cache/apt/archives, so "du -sh /var/cache/apt/archives" will tell you how much space cached packages are taking up.
*

dpkg-reconfigure foo -- reconfigure package ”foo“. You really want to know this one. With many packages, you’ll be prompted with some configuration questions you may not have known were there. For example: dpkg-reconfigure fontconfig-config will present present you with a ”wizard“ on configuring fonts in Ubuntu. I run this one on every Ubuntu install I do, because I want to make bitmapped fonts available to all my apps.
o

dpkg-reconfigure, like the name says, is for *reconfiguring* packages -- if you’ve installed a package that’s asked you questions, and you’d like to change some of those answers, this is what you’re looking for.
*

echo "foo hold" | dpkg --set-selectons -- place package "foo" on hold, i.e. don't upgrade this package, even if it means holding back loads of upgrades that depend on the upgraded version. This is the same as Synaptic's "Package->Lock Version"
o

Note that apt-get dist-upgrade will override this, but will warn you first. Also, if you want to use this with sudo, you need 'echo "foo hold" | sudo dpkg --set-selections' and not 'sudo echo "foo hold" | dpkg --set-selections'.
*

echo "foo install" -- remove the "hold" or "locked package" state set above. The same thing with sudo applies, i.e. it's 'echo "foo install" | sudo dpkg --set-selections'

ref : ubuntu forum

No comments: