Solved Some command exist but are not executed

humphrayLegare

New Member

Reaction score: 5
Messages: 16

Hi people, in the terminal I was wondering what is the reason that i can type : man hier and this will give me the man page about the command but if I type : hier the command is not found ?
Same for some command like gethostname for example.

Best Regards
 

aragats

Daemon

Reaction score: 480
Messages: 1,162

The handbook describes the man pages sections. E.g. gethostname is a library function, not a command: pay attention to the man page's title.
You can explicitly call man of a particular section, in your case the section 1 (User command) obviously doesn't exist:
Code:
% man 1 gethostname
No manual entry for gethostname
 

ShelLuser

Son of Beastie

Reaction score: 1,706
Messages: 3,517

I was wondering what is the reason that i can type : man hier and this will give me the man page about the command but if I type : hier the command is not found ?
Because hier is not a command. The hier(7) manualpage explains the layout of the filesystem hierarchy, nothing more. You can somewhat notice this by its number; 7 means:
Code:
           3.   FreeBSD Library Functions Manual
           7.   FreeBSD Miscellaneous Information Manual
See man(1) for more information on that. As you can see 3 is used by libraries which is why you can't do much with gethostname. If you check its manualpage closer you'll see why this is so:
Code:
SYNOPSIS
     #include <unistd.h>

     int
     gethostname(char *name, size_t namelen);

     int
     sethostname(const char *name, int namelen);
See? gethostname is a so called function which you can use in your C programs by including unistd.h, then you'll have access to the function.

FreeBSD's manualpages don't merely cover commands, they also include system information, config files, libraries, and some even merely explain parameters. For example take a look at ports(7).

This is why it's important to know about the different sections. Commands such as man and apropos can be used to check for things in those sections. For example, lets say you're looking for a command to tell you the hostname:
Code:
peter@zefiris:/home/peter $ apropos -s1 hostname
hostname(1) - set or print name of current host system
geoiplookup(1) - look up country using IP Address or hostname
geoiplookup6, geouplookup6(1) - look up country using IP Address or hostname
logresolve(1) - Resolve IP-addresses to hostnames in Apache log files
ypwhich(1) - return hostname of NIS server of map master
By telling apropos to only search section 1 I managed to limit the output to general system commands only. If I hadn't....
Code:
peter@zefiris:/home/peter $ apropos hostname | wc -l
      29
... I'd have gotten lots of information which would be totally useless for me.

Hope this can help
 
OP
OP
humphrayLegare

humphrayLegare

New Member

Reaction score: 5
Messages: 16

Wow guys this is perfect explanation thank you very much for your I totally get it now !
 
Top