4

With the risk of raising a question that might already have an answer, i would like to ask if anybody knows if and how is it possible to read man pages in my terminal for programs/apps that are not installed in my system using online sources/online tools.

I made a stackexchange and google search but found nothing about this issue.

For example man grep will raise the grep manual as expected. On the other hand man agrep will give an error since agrep is not installed. In order to read agrep manual i have to google agrep man pages , getting results like this : https://linux.die.net/man/1/agrep

PS: BTW it seems strange to me that http://man7.org/linux/man-pages/dir_all_alphabetic.html do not provide agrep...

I wonder if it is possible to run man agrep or similar command from my terminal (without installing agrep) and read agrep man pages in terminal as usual man works.

I don't expect all man pages of the world to be locally available; i just wonder if there is any tricky way to use man (or even other command) to search and display man pages of not installed progs without having to open browser, type keyword, search in results etc.

PS: As noticed by Kusalananda, raising web queries may lead to results not suitable for particular distro version (different versions result will pop up). So the best (in my dream) would be if there was a kind of Distro specific (Debian in my case) internal / built in command (or even a switch) that could retrieve online man pages specifically for my setup (i.e something like : man --online agrep or onlineman agrep). It seems not.

5
  • 1
    The first thing to understand is that each package is normally responsible in maintaining its man pages so that they stay coherent with the installed version. Some systems will install a generic list of man pages but they will fortunately never include all the man pages in the world. Jan 1, 2017 at 20:51
  • 1
    Your current Google search is a good solution imo. Jan 1, 2017 at 20:51
  • @JuliePelletier I was not expecting all the man pages of the world to be locally available... i look for a tricky way to call man (or other command maybe) to load man pages from online sources , without having to open my broswer, go to google, type the keyword, etc. Maybe what i say is just a dream. Jan 1, 2017 at 20:53
  • There are dozens of ways to make a simple shell script to do that, but I doubt anyone spent more than 10 minutes on the subject, since having a browser open and doing a Google search is usually as fast as typing the command. Jan 1, 2017 at 21:00
  • Under debian there is a package called debian-goodies which is a bunch of some sh/bash scripts. In there there is a script called debman that does exactly this work : downloads a deb package in a tmp directory (using debget script from the same bunch of scripts), and then extracts man pages out of this deb package. Dec 3, 2017 at 22:56

4 Answers 4

5

You can use links : links -dump https://linux.die.net/man/1/agrep | less . Just change the category and name and you're good.

13
  • 1
    OMG, that's really ingenious.
    – Sidahmed
    Jan 1, 2017 at 21:26
  • @schaiba If we tie this to a script, will be almost perfect (i can do that...). There is a kind of failure due to the web site (die.net), since die.net does not provide some /a lot of man pages (i.e yad). I think in my dream i imagine a script that could locate man pages for almost any command... Maybe the script i imagine of should poke the web to locate the man page requested... Jan 1, 2017 at 21:45
  • Maybe the Google Custom Search API might be of some interest.
    – schaiba
    Jan 1, 2017 at 21:49
  • 4
    @GeorgeVasiliou Just a question: How would you ensure that you got the manual for what's installed on your system, or even a manual that was relevant to your flavour of Unix? Some utilities have the same name on different systems, but very different semantics. Sometimes an online manual might describe extensions that aren't even available on the system you're interested in. Are you even concerned about versions and outdated manuals?
    – Kusalananda
    Jan 1, 2017 at 21:50
  • 2
    @GeorgeVasiliou Ho hum... At that stage, you might just as well pull the manual out of the package itself.
    – Kusalananda
    Jan 1, 2017 at 22:42
3

If this were Ubuntu, you could use the dman command from the bikeshed package. From man dman:

dman   is   a   script   that   remotely   retrieves   manpages    from
http://manpages.ubuntu.com, but reads them on the local system.

This  is  often  useful  to read a manpage of a utility that you do not
have installed on the local system.

It will cycle through each manpage section available for a given TOPIC.

IIRC, dman is a script, so it might be possible to modify it to work with https://manpages.debian.org.

1
  • Very interesting script. Seems not easy to port it for Debian due to the different implementation /different format of debian manpages web site (based on a cgi-script that runs on server without static pages support). Jan 7, 2017 at 11:17
2

As an alternative, you might consider the lynx text browser instead. That way, you need only enter:

lynx https://linux.die.net/man/1/agrep

It's worked for me in many situations, and appears to be widely available in software repositories for many systems.

As far as knowing you got the version for your system, I don't think there's any way to do that without getting the version number from the one you have installed, and looking in the man page you're trying to read.

2
  • For installed apps simple man is fine, we don't need online man. For not installed apps we could retrieve the version of the package with apt list... Jan 2, 2017 at 10:01
  • Ah, my misunderstanding. Yes, 'apt list' or equivalent for other distributions would be the way to go.
    – EdwinW
    Jan 2, 2017 at 20:44
0

Using online services to display manuals is cool, but as soon as i read @Kusalananda comment about pulling man pages out of installation packages, i got somehow obsessed to implement this technique that will ensure that i will read the correct manual for my distro.

The only bug in bellow solution is that it is based on recent versions of apt/dpkg that are available in Debian Testing 8.6 and might not be available in other systems.

Extract the man pages from .deb files without download
Locate the deb file like if you had plans to install the package in question (i.e yade):

apt-get --print-uris download yade
'http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb' yade_2016.06a-7_amd64.deb 1621148 SHA256:26c0d84484a92ae9c2828edaa63243eb764378d79191149970926aa3ec40cdd4

PS: --print-uris switch prints the url of deb package but deb is not downloaded.

Find the man pages hidden in this deb file:

dpkg -c <(curl -sL -o- http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb) |grep "man/man" |grep -vE "\/$" |awk '{print $NF}'
./usr/share/man/man1/yade-batch.1.gz
./usr/share/man/man1/yade.1.gz

Read the man page yade.1.gz (without downloading the deb):

man <(dpkg-deb --fsys-tarfile <(curl -sL -o- http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb) |tar -xO ./usr/share/man/man1/yade.1.gz)

man page is displayed correctly using man application.

apt --version --> apt 1.4~beta2 (amd64)
dpkg --version --> Debian 'dpkg' package management program version 1.18.18 (amd64).
man --version --> man 2.7.6.1
tar --version --> tar (GNU tar) 1.29
curl --version --> curl 7.51.0 (x86_64-pc-linux-gnu) libcurl/7.51.0 GnuTLS/3.5.7 zlib/1.2.8 libssh2/1.7.0 nghttp2/1.17.0 librtmp/2.3  

Alternative way by downloading deb file:
Bellow method based on classic apt-get, ar and tar should work in any distro.
deb file is downloaded in current working directory, man page is extracted and then file is removed.

pkg="$1"
apt-get download "$pkg" 2>/dev/null
debname=$(find . -name "$pkg*.deb")
datatar=$(ar t "$debname" |grep "data.tar") 
#ar t prints out the contents of the archive 

if [[ ${datatar##*.} == "gz" ]];then #extension check 
  options="z"
elif [[ ${datatar##*.} == "xz" ]];then
  options="J"
else
  echo "data.tar archive inside deb is not a gz or xz archive. Exiting"
  exit 1
fi

manpage+=($(ar p $debname $datatar | tar t"$options" |grep "man/man" |grep -vE "\/$" |awk '{print $NF}')) #tar t lists the files included in archive
man <(ar p "$debname" "$datatar" | tar xO"$options" ${manpage[@]}) 
#ar p and tar -O prints archive files / contents in stdout to be read by man
rm -f $debname #or rm -i for more control.

Using manpages.debian.org
As a third alternative, as of January 2017 somebody can use an alias / script that will pull the man page from debian nline, based on the fresh new debian manpages website which jumps you directly to the correct / most recent man page of the package you want:

alias debman='function __debman { links -dump https://manpages.debian.org/jump?q=$1 |awk "/Scroll to navigation/,0" |less; };__debman'

call it by terminal as $ debman yade

5
  • The simple approach is to set up a VM (I use a Vagrant box running directly on my Mac) and just install all the software packages whose man pages you are interested in. (Why get all complicated? Just use a VM.)
    – Wildcard
    Jan 6, 2017 at 4:35
  • @GeorgeVasiliou I would agree with Wildcard here. It's easier to just install the package, either locally or on a virtual machine. If you'd like to improve the script, then run it though ShellCheck and use something like apt-get download rather than curl for downloading (apt --print-uris doesn't work on Ubuntu AFAIK).
    – Kusalananda
    Jan 6, 2017 at 7:56
  • @Kusalananda Curl is not actually downloading the deb... it justs dumps the deb in the screen in above script. Absence of --print-uris is indeed a problem. Jan 6, 2017 at 11:55
  • @Kusalananda By the way, apt-get of Ubuntu 16 does support --print-uris : manpages.ubuntu.com/manpages/xenial/en/man8/apt-get.8.html, so above script should work in Ubuntu as well. In any case, to install the package (either directly or via VM) just to see the man page, does not sound a handy idea. The worst case would be to use apt-get download pkg and then extract the man page from the downloaded deb (see updated code). The whole story is to built a GUI catalogue of available pkgs in repos (with a GUI search form) and then to provide the man page of any package with one click. Jan 7, 2017 at 1:27
  • Based on this answer, here is a script to just download all the manpages from the repositories to your current directory. This will take quite a while and will consume a couple hundred megabytes of disk space once it is done, but it will allow you to simply browse these manpages with man just like any other manpage. gist.github.com/NuvandaPV/fc15eb998c305f8fc8123bf471971e79
    – Nuvanda
    Mar 25, 2019 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .