LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   man command and silly behavior (https://www.linuxquestions.org/questions/slackware-14/man-command-and-silly-behavior-4175508145/)

johnpuppa 06-16-2014 03:48 AM

man command and silly behavior
 
Hello guys,
I was wondering if you have ever experienced such problem:
I have the man command that when launched from root doesn't show every man page, but from normal user it displays them without any problem.
For instance it does this silly behavior with the command useradd, showing a blank file when called from root and it show the correct man page when called from normal user..

Quote:

bash-4.2# echo $MANPATH
/usr/local/man:/usr/man
Quote:

bash-4.2$ echo $MANPATH
/usr/local/man:/usr/man
Quote:

find /usr/man/ -name useradd*
/usr/man/fr/man8/useradd.8.gz
/usr/man/zh_TW/man8/useradd.8.gz
/usr/man/id/man8/useradd.8.gz
/usr/man/ru/man8/useradd.8.gz
/usr/man/tr/man8/useradd.8.gz
/usr/man/zh_CN/man8/useradd.8.gz
/usr/man/ja/man8/useradd.8.gz
/usr/man/de/man8/useradd.8.gz
/usr/man/man8/useradd.8.gz <--directory where useradd and usermod pages are
/usr/man/it/man8/useradd.8.gz
Quote:

ls -l /usr/man/man8/|grep useradd*
-rw-r--r-- 1 root root 5.3K Feb 14 22:55 useradd.8.gz

bash-4.2$ ls -l /usr/man/man8/|grep usermod*
-rw-r--r-- 1 root root 3.3K Feb 14 22:55 usermod.8.gz
Strange thing.. "man usermod" works fine from both user and root...
What could be the reason?

pan64 06-16-2014 04:06 AM

you need either use ls /usr/man/man8/useradd* or ls /usr/man/man8|grep useradd, but do not add * in this grep pattern.
you can try strace -f -o /tmp/strace.log man useradd and check how man tried to look for those files.

johnpuppa 06-16-2014 05:15 AM

Thanks for the help pal... in the log indeed they are accessing two different files:

From Root:
Quote:

999 9557 execve("/usr/bin/unxz", ["/usr/bin/unxz", "-c", "/usr/man/cat8/useradd.8 .xz"], [/* 39 vars */] <unfinished ...>
From user

Quote:

700 9530 stat64("/usr/man/man8/useradd.8.gz", {st_mode=S_IFREG|0644, st_size=5 361, ...}) = 0
701 9530 stat64("/usr/man/cat8/useradd.8.xz", 0xbfa169f0) = -1 EACCES (Permiss ion denied)
702 9530 stat64("/usr/man/cat8/useradd.8.xz", 0xbfa16ac0) = -1 EACCES (Permiss ion denied)
but eventually:
Quote:

1687 9537 execve("/bin/gunzip", ["/bin/gunzip", "-c", "/usr/man/man8/useradd.8. gz"], [/* 40 vars */] <unfinished ...>
So the problem is that they access different files... Indeed:
man /usr/man/cat8/useradd.8.xz

Quote:

fgets: No such file or directory
Error reading man page /usr/man/cat8/useradd.8.xz
No manual entry for /usr/man/cat8/useradd.8.xz
man /usr/man/cat8/userdel.8.xz <-- Works fine.. Maybe then some files are corrupted. I tried reinstalling these packages:

[ installed ] - shadow-4.1.5.1-i486-3_slack14.1
[ installed ] - bash-completion-2.1-noarch-1
but no luck so far...

what can it be?

also, why is adding * in the grep pattern a bad thing? :)

Your answer has been very helpful thanks!

johnpuppa 06-16-2014 05:41 AM

My solution has been to replace the gz file with the xz and of course I changed the type of archive.. works fine so it should be fine..

pan64 06-16-2014 05:42 AM

the * has a special meaning and it is not what you need. Otherwise it causes no problem in your case.
I would suggest you to run that strace for both useradd and usermod (and for both root and user) and find the differences. I think there is a permission problem or an environment variable was not set properly...

johnpuppa 06-16-2014 07:29 AM

I know what you mean about * but in that case works fine either way.. though your suggestion is more correct..
What is curious is why I have the user* man in both directories /usr/man/man8 and /usr/man/cat8 with a different archive extension..

GazL 06-16-2014 10:54 AM

Quote:

Originally Posted by johnpuppa (Post 5188797)
I know what you mean about * but in that case works fine either way.. though your suggestion is more correct..
What is curious is why I have the user* man in both directories /usr/man/man8 and /usr/man/cat8 with a different archive extension..

Check the date-stamps on the files. I suspect the .gz ones are older, and that the default compression was changed in man.conf at some point.


On a more general point:

Do the cached man-pages actually add any value these days? Processors are a damn sight faster than they used to be, so reformatting time is going to be unnoticeable, and the cached pages only get created/used on a 80 column wide display anyway, which I suspect doesn't match what most of us are using on a regular basis (mine is typically 159). Probably best to just set NOCACHE in man.conf and do away with the cat dirs completely.

And speaking of man.conf, what is it doing in /usr/lib64? Wouldn't /etc be far more appropriate?

Speek 06-17-2014 05:18 AM

Quote:

Originally Posted by GazL (Post 5188883)
And speaking of man.conf, what is it doing in /usr/lib64? Wouldn't /etc be far more appropriate?

Yes, I agree, /usr/lib64 is an inappropriate place for a configuration file. Pat, can you please move it to /etc ?

tronayne 06-17-2014 07:55 AM

Anymore, the cat directories are empty (Slackware 14.1) -- they live in /var/man and there are symbolic links to each directory (cat1 - cat9 and catn) in /usr/man. For a long time there were two sets of manual pages, one set with the man macros, the other, the cat pages, as formatted text. And, of course, there are multiple languages so you'll see man pages in the language specified by your locale. See man man for a description. The purpose was to cut down on the formatting time of manual pages to a simple text file and that was done automatically when the man utility was invoked (or you could force it, building all the I]cat[/I] pages in one go. Nowadays, why bother.

Manual pages are written using the man macros, embedded codes that specify how to display text. The codes are of the form at the beginning of a line followed by one or more characters. You can see what an unformatted manual page looks like with, say
Code:

zmore /usr/man/man8/useradd.8.gz
The codes are described in
Code:

man groff_man
man 7 man

Unix provides nroff and troff for formatting documents (including manual pages); Linux provides look- work-alike groff. Both, pretty much, will format and display (nroff, groff) or "typeset" (troff/groff documents. There are, at least on Slackware 14.1, a troff and nroff program, but you're expected to use the GNU analogs, groff.

As to the use or non use of the asterisk with the find utility: it's better to enclose arguments in single quotes when using the asterisk; e.g.,
Code:

find /usr/man -type f -name 'useradd*'
prevents problems and weirdness, that.

If you like to have hard copy of a particular manual page, you can invoke
Code:

man -t useradd | lp
and you'll get a formatted hard copy (rather nicely formatted, too).

What the -t argument does is "typeset" a document (the output is PostScript), which you pipe to your printer.

The published books written by the likes of Dennis Ritchie, Brian Kernighan and others at AT&T Bell Labs were all written using text macros for formatting (as with the manual macros). You have all of these for creating tables, equations, graphs, formatted text and so on on your Slackware system.

The rules are real simple:
  • Start every sentence on a new line;
  • Leave a blank line for a paragraph.
Try it: write a few lines of text, leave a blank line here and there, save as a file and
Code:

nroff file
See hat you get.

Hope this helps some.

GazL 06-17-2014 08:31 AM

Quote:

Originally Posted by tronayne (Post 5189291)
Anymore, the cat directories are empty (Slackware 14.1) -- they live in /var/man and there are symbolic links to each directory (cat1 - cat9 and catn) in /usr/man.

They're empty initially, but will fill up as you read man-pages on an 80 column terminal. That's why I mentioned setting the NOCACHE option.

tronayne 06-17-2014 09:02 AM

Quote:

Originally Posted by GazL (Post 5189307)
They're empty initially, but will fill up as you read man-pages on an 80 column terminal. That's why I mentioned setting the NOCACHE option.

Hm.

Mine are all empty (and I do read man pages fairly often), seems like the cat "feature" is shut off by default and I really wouldn't want to turn it back on anyway.

Stuff changes, methinks, sometimes for the better, sometimes for the worse.

GazL 06-17-2014 09:19 AM

Seems that in order for them to be created, as well as having to be on a 80 column terminal, you also need to be root, (probably due to the permissions on the directories), which may go some what to explaining why the few pages that existed in my system were for things like lilo(8).

johnpuppa 06-17-2014 04:04 PM

thanks for the explanation tronayne. Really cool!

rknichols 06-17-2014 08:13 PM

Quote:

Originally Posted by GazL (Post 5189326)
Seems that in order for them to be created, as well as having to be on a 80 column terminal, you also need to be root, (probably due to the permissions on the directories),...

In olden times, the man command was set-GID to "man" and the various "cat*" directories had group write permission to let that work. All that is left of that today is existance of a "man" group in /etc/group.

TracyTiger 06-17-2014 08:47 PM

Quote:

Originally Posted by GazL (Post 5189326)
Seems that in order for them to be created, as well as having to be on a 80 column terminal, you also need to be root

That is the case on the Slackware64 14.0 system in front of me. Both conditions were necessary (80 columns, root) before the cat file was created.


All times are GMT -5. The time now is 04:04 AM.