How to read a man page

Hello,

I didn't know where to put this so i'm asking here.

I don't like asking n00b questions and always told to look at the man page or the manual so i'm here asking what is the best way to read it and understand it.. For freebsd im looking at


Can somebody explain to me so i can understand it or give me a point in the right direction.. There are a lot of guides online but i'm still confused.

Example

portmaster -Da

- D is don't clean dist files

- a is update

How would i know to run those commands at the same time..

I ran portmaster -da but i was getting errors about root

Thanks

Joe
 
Hi, for your particular question, the portmaster command needs root or root privilege. In other words you'd have to run it with sudo or doas (or as root). Now, unless you made a typo, if you want to clean distfiles, you want -D. Running -d means clean the distfiles. So, running
Code:
portmaster -da
means check all ports and update all that need to be updated, and clean all distfiles.



*Typo on my part. Originally I said -D is to clean distfiles, an upper case -D means DON'T clean distfiles*

Apologies, and thanks to astyle for catching it.

Man pages are often written more for people who already know the command and just need a reminder, or people who know the command and are wondering how to do a specific thing.

FreeBSD man pages are often pretty good, and often have an EXAMPLE section at the end, which can be very useful. On the other hand, if you're reading a man page and don't understand it, I've never seen anyone on these forums insult someone for not understanding a particular man page.

So, I would say, look for what you want in a man page. If you can't find what you need, or it's not clear to you, there's no shame in asking for help here.

I hope this helps a bit.
 
I ran portmaster -da but i was getting errors about root
Well, this basically means that you need to run that command as root:
Code:
% su root
Password: 
# portmaster -Da
...
lots of output snipped
...

Some commands can be run as a regular user (think ls, or pwd), and some are meant for root to run. portmaster(8) is one of those that are meant for root to run, rather than regular user.

Manpages do not typically specify if a command is meant to be run as root. But after awhile, you get a sense for what can be run as regular user and what should be run as root. Just remember the famous lesson about running rm -rf /* as root (yep, that will destroy the whole system).

Do pay attention to capitalization of flags, scottro ... as per portmaster(8):
Code:
 -D  no cleaning of distfiles (this has been made the default behavior)

-d  always clean    distfiles
 
I like to put some words of scottro whose words I cherish, in some perspective:
Man pages are often written more for people who already know the command and just need a reminder, or people who know the command and are wondering how to do a specific thing.
That's not quite true to say it that way.
That describes a command's help: -h --help (or no options at all)

Manpages are the basic core pillar of all unix[like] documentation.
Nothing else - no Book, Handbook, How-To, Wiki, Forum,... - can comply the task of a complete and up-to-date documentation of everything.
(IMO nothing shall be allowed on an unix[like] system that does not come with a man page; even if there are no options to be used, but at least a simple description what it is/does, only.[but that's another discussion])

I agree with scottro insofar that manpages not seldom for a newb on a certain topic are hard to comprehend, what really needs to be done to get something run as wished.
Most of the times that's because of most man pages try to be most brief.
Sometimes (seldom) a man page could have been written a bit less sloppy, okay.
But also sometimes there are manpages written foolproof - mostly for simple things with very few options.

But that comes to the classic problem of what's crystal to the author is not neccessarily comprehendable for the reader.
Everybody wants everything as short and brief as possible, while explanations need text. The more comprehandble the longer.
And the author needs to respect the previous knowledge of all of his readers without knowing them.
Mission impossible.

That's why there is additional documentation: Handbooks, Books, How-Tos, Tutorials,....Forums
All of those cover even less of everything - 'cause that's not their job. That's the man page's job.
Their jobs are to give more elaborated explanations on a certain topic, or dive deeper into one, cover a very speical point, or to give one preprocessed thread as an example of something - supplement or combine the knowledge from manpages.

If you give the topic 'documentation of unix[like] systems' a serious thought,
ask yourself:'How to get a documentation that's up to date, and covers everything?'
I think you'll see it likewise, and I bet that was the idea of those who invented man pages in the first place:
The only way to have everything covered up-to-date is if every single part of the entire whole has its own documention, maintained for itself independently - hence the manpages.

I admit if one used Word or LibreOffice only yet, the writing of a manpage is something new to be learned.
But it's no rocket science neither.
Learning to write HTML, LaTeX or especially XML is unlike harder.


But the OP's original question is a very good question,
and needs to be answered.
If nobody else fills that I will give some pointers to it later.
EDIT:
Sorry to scottro and astyle for this thoughtless sentence of mine.
It was early in the morning, I was in a hurry and didn't gave it a thought - sorry.
Also thank you to both for overlook that, being the greater men.
 
To answer the OP's question:

I don't like asking n00b questions
This may a newbies question, but it's a good one,
'cause as I pointed out in my former post, manpages are the most important documentation,
and it actually needs a bit warm up with that system, since sometimes it is too brief to get all out of it one needs to come to a satifying solution - and often enough you need to read several manpages to get something done, because some tasks are not done by understanding one manpage alone (I pointed out the problem of how to write a documentation on something complex and huge like an operating system, and what all comes with, not only a mass of packages.)

The certain example you put with portmaster needs to be discriminated:
How to read manpages in general is one point.
How the shell handles it - reading/understanding (error) messages is something different (astyle already covered that.)
And how a certain program/filter/app uses or names its options is something completely else again.
This depends on the certain piece of software (And you may already know un1x is case sensitive; means -d -D are not the same.)

How to read manpages:

Manpages are manuals.
Like the manual for a oven it just covers how to use the oven. It may come with some example recipes, but if simply to better understand the usage of the oven, to tell you it can be used to make stews, cookies, pizza, and pies, not to cover a certain dish. You may comprehend an oven's manual trying to cover every possible recipe would be endless.
So it's up to you to combine the recipe of apple tard with the manual's information, and gain experience on it to get your perfect apple tard in this oven.

As far as I know (please correct me, if I'm wrong) there are no rules how options have to be named (Some things are defined in POSIX, but that's no guarentee it covers everything, nor everybody always sticks to it strictly in any case.)
As scottro already pointed out, FreeBSD's manpages are (almost always) exemplary.
They (almost always) have the same structure.
So most programs/filters try to stick to a conform system of how to use options, like -x for single character options, --xxx for multicharacter (wordlike) options, and the file(s) to be handled are placed last.
Many (most) programs at least try to stick to a conformity as far as possible, and use e.g. -h for help, -v for verbose, -r for recursive, -h human readable.
But it's easy to understand it makes no sense to reserve -r for recursive if the programm has no use for recursive, but something else -r is better used for.
So like anywhere else, if there rules (written/not written) there always are exceptions.

That's why you may look it up any time in the manpage.
On the webpage you already linked,
or by using man portmaster to view it in your shell
(the manpages are on your machine, too. So you don't need no internet to access them.
And if you tell your shell to use most instead of the default less
( pkg install most then setenv PAGER most in ~/.cshrc (if you use [t]csh)) you get the manpages be shown colorfully structured.)

According to what already has been said here my advice is:
1. Very first look always should be the official HB.
2. If that what you're looking for is not covered there, second view is manpages.

Even if you realize after reading the first lines of a manpage's head it's not what you're looking for,
my advice is to at least skim once completely through it; just simply scroll it down, if only to get the idea how long the manpage is, and if there are examples; you'd be amazed after a while what knowledge you gather that way just by flying by, only. Of course, you will not learn its content that way. But another time if you actually need it (and for many manpages the day will come) you've already seen it.

As scottro pointed out:
Many good things are at the bottom of a manpage.
Mostly examples which not seldom cover the exact solution you're just looking for, give you an idea, or at least point you in the right direction.

Also at the bottom of a manpage almost always you'll find a list of files,
and other manpages on the same topic, with additional, according, similar, or alternative information.
I solved many of my tasks - gained some knowledge/understanding by just follow, skimming through, and reading those.

3. If this - HB & manpagess - ain't no help, it's always worth a shot to look into
/usr/local/share/doc/
You'll find a lot of elaborated documenation on the userland things you have installed.

To end with a - *cough* - 'philosophical' truism:
Learning un1x mostly means learn to read the documentation.

Tipp:
Try to look for manpages also on other topics, not only the certain command you're currently like to use.
You'll be amazed what you will find.
e.g.
man hier
 
Which options can be combined or not is generally not explicitly stated in the manpage. You have to know because of logic (they just don't make sense together) or by getting an error message (or outright malfunction).

BTW, for future postings it would be better to not say "got an error" but to copy-n-paste the actual error message.
 
How to read a man page?

Manly!

ManlyMan-small.jpeg


The lack of fingers is not ChatGPT's fault, it's because the guy works in a butcher's shop.
 
IIRC at an event some time ago it was acknowledged that the section 5 page for rc.conf was a problem …

… often have an EXAMPLE section …

rc.conf(5) lacks this section; the page is debatably too long; and so on.



groff_mdoc(7) includes a man page template with Examples followed by Diagnostics or Compatibility; Bugs at the end.

iwlwifi(4) has its bugs section near (not at) the end: "Certainly."
  • fair enough
  • drily amusing ?
Not amusing: many man pages don't even hint at significant bugs.



1727542278571.png1727542500870.pngFor anyone who wonders why iwlwifi(4)-compatible devices are missing from hardware notes (for releases of FreeBSD): it is, obscurely, because:
  • the page does not yet have a HARDWARE section
– a variation from the template above.

… Instead, please see the DESCRIPTION section of the manual page. A future edition may include a HARDWARE section.
 
Once thing that always used to confuse me were man page references like rc.conf(5). ”What’s the deal with number in parentheses?” I would wonder.

This table, showing the man page sections, helps it make more sense:

1 FreeBSD General Commands Manual
2 FreeBSD System Calls Manual
3 FreeBSD Library Functions Manual
4 FreeBSD Kernel Interfaces Manual
5 FreeBSD File Formats Manual
6 FreeBSD Games Manual
7 FreeBSD Miscellaneous Information Manual
8 FreeBSD System Manager's Manual
9 FreeBSD Kernel Developer's Manual

I also found it useful to scan this article on creating man pages, not for the details, but just for an idea of how they work:

 
Back
Top