LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-16-2014, 03:48 AM   #1
johnpuppa
Member
 
Registered: Jun 2013
Distribution: Slackware
Posts: 44

Rep: Reputation: Disabled
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?
 
Old 06-16-2014, 04:06 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,747

Rep: Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561
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.
 
Old 06-16-2014, 05:15 AM   #3
johnpuppa
Member
 
Registered: Jun 2013
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: Disabled
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!
 
Old 06-16-2014, 05:41 AM   #4
johnpuppa
Member
 
Registered: Jun 2013
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: Disabled
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..
 
Old 06-16-2014, 05:42 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,747

Rep: Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561Reputation: 7561
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...
 
Old 06-16-2014, 07:29 AM   #6
johnpuppa
Member
 
Registered: Jun 2013
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: Disabled
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..
 
Old 06-16-2014, 10:54 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 7,011

Rep: Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142
Quote:
Originally Posted by johnpuppa View Post
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?
 
1 members found this post helpful.
Old 06-17-2014, 05:18 AM   #8
Speek
Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Slackware
Posts: 124

Rep: Reputation: 41
Quote:
Originally Posted by GazL View Post
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 ?
 
Old 06-17-2014, 07:55 AM   #9
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
 
1 members found this post helpful.
Old 06-17-2014, 08:31 AM   #10
GazL
LQ Veteran
 
Registered: May 2008
Posts: 7,011

Rep: Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142
Quote:
Originally Posted by tronayne View Post
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.
 
Old 06-17-2014, 09:02 AM   #11
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Quote:
Originally Posted by GazL View Post
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.
 
Old 06-17-2014, 09:19 AM   #12
GazL
LQ Veteran
 
Registered: May 2008
Posts: 7,011

Rep: Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142Reputation: 5142
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).

Last edited by GazL; 06-17-2014 at 09:27 AM.
 
Old 06-17-2014, 04:04 PM   #13
johnpuppa
Member
 
Registered: Jun 2013
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: Disabled
thanks for the explanation tronayne. Really cool!
 
Old 06-17-2014, 08:13 PM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,792

Rep: Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220Reputation: 2220
Quote:
Originally Posted by GazL View Post
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.
 
1 members found this post helpful.
Old 06-17-2014, 08:47 PM   #15
TracyTiger
Member
 
Registered: Apr 2011
Location: California, USA
Distribution: Slackware
Posts: 528

Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by GazL View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] man pages - man command phillyfilly Linux - Newbie 4 02-10-2014 05:41 AM
[SOLVED] SSH and at Command Behavior Woodsman Slackware 3 11-20-2009 04:08 PM
Behavior of Command Line Expansion in touch command ahmedb72 Linux - Newbie 10 07-01-2009 02:51 AM
Silly question really about ftp command in bash hashbangbinbash Linux - Newbie 3 07-04-2008 04:47 AM
ls command behavior day4night Linux - Newbie 7 01-25-2004 12:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration