13

How do I properly open a local .8 file like named.8 with the man command?

I have the man command and I have a .8 file. In my case it is bind9/bin/named/named.8 (which can be found on github) I'm pretty sure that I was able to do it before.

In my specific case, it is

$ man --version
man 2.7.5

$ man -C named.8
man: can't parse directory list `.\" Copyright (C) 2000, 2001, 2003-2009, 2011, 2013-2017 Internet Systems Consortium, Inc. ("ISC")
'
man: can't make sense of the manpath configuration file /etc/manpath.config

named.8 starts with:

.\" Copyright (C) 2000, 2001, 2003-2009, 2011, 2013-2017 Internet Systems Consortium, Inc. ("ISC")
.\" 
.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.hy 0
.ad l
'\" t
.\"     Title: named
.\"    Author: 
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 2014-02-19
.\"    Manual: BIND9

I tried Google searching "How to open a .8 file." and there were 0 results, so I think there should be a result for this (which is n times better of a reason to ask the question than if I only needed to know the answer for myself where n is the number of future searches for that made by anyone.)

0

4 Answers 4

27

man ./named.8 will work. man will take a filename as an argument, but if the argument "looks like" the name of a manpage, it will assume that it is, and not check for a file of that name. By adding ./ to refer to a file in the current directory, you make it clear that it's a filename, and so man will treat it as such. You could also use a full absolute path.

4
  • This is good. So good that it's bad. Now I don't know whether to choose your answer or Lok Lam Cheng's answer. Commented Apr 16, 2018 at 0:51
  • @TimothySwan doesn't bother me one way or the other. -l looks like a good choice. But it's worth knowing for lots of things that try to guess whether something is a filename or not, that a ./ can help you out. e.g. if you have a file named -x and something insists on thinking it's a flag because it starts with -, well, call it ./-x and it doesn't start with - anymore.
    – hobbs
    Commented Apr 16, 2018 at 1:07
  • @TimothySwan: FWIW, @hobbs' answer works in macos, whereas the other answer (using the -l argument) does not.
    – Seamus
    Commented Feb 26, 2020 at 9:39
  • @Seamus is correct, macOS has an ancient BSD man with no -l option. There are two options I can think of there: (A) You can run nroff -man <filename>|less, which will run the file through the same preprocessor man uses to format the output. (B) Or, more stupidly, if the file is in the proper section subdirectory (like, man1 for foo.1, man8 for your named.8 file, etc.), you can run man -M <parent_dir> <pagename>, and it will use the directory you specify as the manpath, finding e.g. man8/named.8 at that path and displaying it. (Like I said, stupid.)
    – FeRD
    Commented Jan 18, 2023 at 15:20
19

You can open a local file named.8 using the following command: man -l named.8

Reference: http://man7.org/linux/man-pages/man1/man.1.html

1
  • 2
    Yes. Activate "local" mode. Format and display local manual files instead of searching through the system's manual collection. Derp. But you must admit the man page for man is brimming. Commented Apr 16, 2018 at 0:49
8

The .8 part of the page name is indicating it's in section 8 of the man pages. Section #8 is the manpage section that is specific to System administration commands... usually commands own or controlled by root.

The command man will load that page as long as it in a proper manpath. For Ubuntu, this path is configured in /etc/manpath.config.

You will find /usr/share/man as one of the manpath locations. If you put that file (named.8) in the /usr/share/man/man8 section it can be loaded with the command:

$ man named

This is assuming the file is located:

/usr/share/man/man8/named.8

You can be more specific in loading that section with this command (which will load the same page:

$ man 8 named

You can see other examples of the structure by exploring the various man pages that have automatically been placed in the /usr/share/man directory hierarchy.

If you properly compile and install the github package, it will place the manual in one of the manpath locations and be loaded with one of these two commands:

$ man named
$ man 8 named

The second of the two commands are specifying (as your question asks) how to open a.8 file.

Of course, you can get lots of other details about the man page commands and structure with the commands:

$ man man
$ man manpath

Each one of the document pages will have links at the bottom to explain in more details other related commands, of which you can followup with:

$ man [name of other references in the page]

Other ways of calling man pages/man files include:

You can also open any man page by specifying the direct namepath of the page. For instance:

$ man /usr/share/man/man8/named.8
$ man ./named.8

Since named.8 doesn't exist in a default ubuntu install, you can test this option on a page that actually exist (/usr/share/man/man8/apt.8.gz):

$ man /usr/share/man/man8/apt.8.gz
$ man ./apt.8gz

When opening a page directly, rather than a page in the manpath, but keep in mind that if you are in the same folder as the page you would have to use man ./manpagename.8, whereas man manpagename.8 will search the manpath. It wouldn't see it, just as trying to call an execute file wouldn't see the command in the current directory unless that current directory was in the search path.

Note

Related to your Google search for the .8 extension, your hits would have been more specific to your question had you put quotes (") around the ".8" part of the question. Since it was a man page you were working with including the word man in the filter would have been even better.

This formatted question may help the next time you perform a Google search:

how to open a ".8" man file

Or, using the same search filter you put for your AU question:

How to open ".8" file with man?

1
  • What an... incredibly long answer that does, eventually, get around to answering the question asked, but does it in such a roundabout, irrelevancy-filled fashion that it's easy to miss the useful answer as it gets lost amid all the noise. This answer would be good, if it were about 60%-80% shorter.
    – FeRD
    Commented Jul 7, 2022 at 13:20
2

While other answers are correct, for many files you can try a generic solution: as long as you have lesspipe installed and activated you can do:

less some_file.8

and get a formatted output. If you have lesspipe installed, but not activated for some reason, you'll have to run eval $(lesspipe.sh) first.

You must log in to answer this question.

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