Starting from @derobert's answer, I worked my way to getting exactly the current version of all packages to reinstall.
Short version:
sudo dpkg -l | grep '^ii ' | sed 's/ */\t/g' |cut -f 2,3 | sed 's/\t/=/' | xargs apt-get install --reinstall -y --ignore-missing
Explained:
The key is actually specifying the required version of each package.
The general command is:
apt-get install --reinstall <package>=<version>
Breaking down the long command line:
$ dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===========================================================-==================================-============-========================================================================
ii adduser 3.113+nmu3 all add and remove users and groups
ii apt 0.9.7.8+rpi1 armhf commandline package manager
ii apt-utils 0.9.7.8+rpi1 armhf package managment related utility programs
ii aptitude-common 0.6.8.2-1 all architecture indepedent files for the aptitude package manager
ii atmel-firmware 1.3-4 all Firmware for Atmel at76c50x wireless networking chips.
$ dpkg -l | grep '^ii '
...gets rid of the header lines and a few packages with status 'hold
' (marked as hi
instead of ii
)
$ dpkg -l | grep '^ii ' | sed 's/ */\t/g'
... converts any number of spaces to a single TAB character, preparing the ground for cut
.
(Btw: why, oh why, doesn't sed
support x+
regex for "character x, one or more times"? It can be emulated with xx*
- meaning 'x' once followed by 'x' zero or more times)
The output looks like this:
ii adduser 3.113+nmu3 all add and remove users and groups
ii apt 0.9.7.8+rpi1 armhf commandline package manager
ii apt-utils 0.9.7.8+rpi1 armhf package managment related utility programs
ii aptitude-common 0.6.8.2-1 all architecture indepedent files for the aptitude package manager
ii atmel-firmware 1.3-4 all Firmware for Atmel at76c50x wireless networking chips.
Next:
$ dpkg -l | grep '^ii ' | sed 's/ */\t/g' | cut -f 2,3 | sed 's/\t/=/'
...gets the name and version of each package (the 2nd and 3rd fields), and replaces the tab that separates them with an '='
adduser=3.113+nmu3
apt=0.9.7.8+rpi1
apt-utils=0.9.7.8+rpi1
aptitude-common=0.6.8.2-1
atmel-firmware=1.3-4
Finally, pipe each of the above to apt-get as a long list of arguments using xargs
.
Notice the parameter --ignore-missing
- this command is run as 'best effort' - I don't want the updating to stop because some packages are not available to reinstall (those will stay unmodified)
$ dpkg -l | grep '^ii ' | sed 's/ */\t/g' |cut -f 2,3 | sed 's/\t/=/' | xargs apt-get install --reinstall --ignore-missing
While testing, I also added a --dry-run
argument to apt-get.
Man section 5 is "File Formats and Conventions" and is not installed by default. see What do the numbers in a man page mean?
To install part of it on a Debian system, install:
sudo apt-get install libarchive-dev
From packages.debian.org:
Package: libarchive-dev (3.1.2-11+deb8u1)
The libarchive library provides a flexible interface for reading and
writing archives in various formats such as tar and cpio. libarchive
also supports reading and writing archives compressed using various
compression filters such as gzip and bzip2. The library is inherently
stream-oriented; readers serially iterate through the archive, writers
serially add things to the archive.
Double checking if man(5) tar page is installed:
dpkg -S /usr/share/man/man5/tar.5.gz
libarchive-dev:amd64: /usr/share/man/man5/tar.5.gz
Listing the files installed/owned by the package:
dpkg -L libarchive-dev | grep man
/usr/share/man
/usr/share/man/man5
/usr/share/man/man5/tar.5.gz
/usr/share/man/man5/mtree.5.gz
/usr/share/man/man5/libarchive-formats.5.gz
/usr/share/man/man5/cpio.5.gz
/usr/share/man/man3
/usr/share/man/man3/libarchive_internals.3.gz
/usr/share/man/man3/libarchive_changes.3.gz
/usr/share/man/man3/libarchive.3.gz
/usr/share/man/man3/archive_write_set_options.3.gz
/usr/share/man/man3/archive_write_open.3.gz
/usr/share/man/man3/archive_write_new.3.gz
/usr/share/man/man3/archive_write_header.3.gz
/usr/share/man/man3/archive_write_free.3.gz
/usr/share/man/man3/archive_write_format.3.gz
/usr/share/man/man3/archive_write_finish_entry.3.gz
/usr/share/man/man3/archive_write_filter.3.gz
/usr/share/man/man3/archive_write_disk.3.gz
/usr/share/man/man3/archive_write_data.3.gz
/usr/share/man/man3/archive_write_blocksize.3.gz
/usr/share/man/man3/archive_write.3.gz
/usr/share/man/man3/archive_util.3.gz
/usr/share/man/man3/archive_read_set_options.3.gz
/usr/share/man/man3/archive_read_open.3.gz
/usr/share/man/man3/archive_read_new.3.gz
/usr/share/man/man3/archive_read_header.3.gz
/usr/share/man/man3/archive_read_free.3.gz
/usr/share/man/man3/archive_read_format.3.gz
/usr/share/man/man3/archive_read_filter.3.gz
/usr/share/man/man3/archive_read_extract.3.gz
/usr/share/man/man3/archive_read_disk.3.gz
/usr/share/man/man3/archive_read_data.3.gz
/usr/share/man/man3/archive_read.3.gz
/usr/share/man/man3/archive_entry_time.3.gz
/usr/share/man/man3/archive_entry_stat.3.gz
/usr/share/man/man3/archive_entry_perms.3.gz
/usr/share/man/man3/archive_entry_paths.3.gz
/usr/share/man/man3/archive_entry_linkify.3.gz
/usr/share/man/man3/archive_entry_acl.3.gz
/usr/share/man/man3/archive_entry.3.gz
In OS/X you have already parts of the man 5 at /usr/share/man/man5 directory. Apart from copying there the aforementioned pages, have not investigated how to install them.
Best Answer
The man pages on your system correspond to the software that's installed on your system. It would be bad if you had documentation that didn't describe the software you're running!
Ubuntu 14.04, by definition, includes software versions released at least a few months before April 2014.
Reinstalling man pages won't give you more recent versions. Reinstalling just gives you what you already had.
If you want your system to have recent documentation, you need to upgrade your distribution. You'll get more recent software and the assorted documentation.
If you want to read documentation for software that you don't have installed, then just read it on a website.
If you want to have easy access to software and documentation that's newer or older than your distribution, you can install another distribution on your machine (e.g. another release of Ubuntu), either in a virtual machine or in a chroot. See How do I run 32-bit programs on a 64-bit Debian/Ubuntu?