Linux/unix Man Usage

Source: Internet
Author: User
Tags fam function prototype

Recently began to learn Linux C programming, need to use a lot of library functions and C standard library functions, found that the original Man command can also be used to query function prototypes.

For example, enter man Lseek to get the prototype of the function Lseek and the owning header file.

Some function names are both Linux commands and system calls, such as mkdir, which can be entered by the Man 2 mkdir to get the function prototype. Just enter man mkdir get the help of command mkdir.

For library functions You can enter the man 3 < library function name > get help information. Mans 3 Opendir

For system development often need to query function is very convenient, in addition to vim can be used in the SHIFT + K query.


The following transfers are from: http://blog.csdn.net/sunyubo458/article/details/5935248

Under the UNIX development, viewing the man manual is very necessary, but also very much needed. How to use the man more quickly?

Of course, there is no command, or can not remember the parameters of the command, it will be man, but in the Unix man manual has such a phenomenon, such as you want to see read () This C library functions and parameters and usage. Man read what's the result? Only the relevant help information for the Shell's Read command appears, and there is no relevant content for the read () library function.

Why?

That's because man's search order is based on the settings in MAN.CF. When man finds a match, he stops looking down. So when you want to see the read () function instead of trying to understand the use of the Read command, the light using man read is definitely not. In the environment I use:

Machine hardware:sun4u

OS version:5.8

Processor Type:sparc

Under the hardware:sunw,ultra-250.

When using Man-s 2 read, Force man to search only the files in section 2 (note: Depending on the version of UNIX, it may be different.)

Here's the question, what is section?

UNIX man page (don't think too much, man page is referred to as the reference manual page) is organized by section. When we use the man LS, we see LS (1), and the 1 in this bracket means that the man page of LS is located in sections 1. A section is usually made up of a main section name and an optional secondary section name. The main section name is usually a number, and the secondary section name is usually one or more letters. What the sections in Solaris correspond to:

1:user Commands and Utilities

2:system Calls

3:c Library Functions

4:file formats

5:headers,tables and macros

6:games and Demos

7:device and Network Interfaces

8:maintance and Accounting commands

9:device Driver Interfaces

Use the-s parameter to refer to which session is written. To remember, different versions, numbers may not be the same, this is the way, try the numbers can be, format such as: Man-s 2 read.

Attached: Other information about the man directive

Linux systems provide a number of commands and many utility software. Information on some commonly used commands and utility software can be obtained using the online Help manual provided by the system. In the Linux online Help manual, almost every command is described. Therefore, use the online Help command when a user does not use or understand a command on Linux.

The online manuals for Linux systems have a large amount of information available and are divided into sections based on their content.

1. Chapter Description:

1 General User's commands

2 system-invoked commands

3 commands for the C-language function library

4 Explanation of drivers and system devices

5 Explanation of the configuration file

6 command of the game program

7 other software or program commands

8 Commands for system maintenance

N Shell Internal Command chapter number

2. Man command

This command formats and displays the online manual page. Usually the user will enter the name of the command you want to get (for example, LS) after the command man, and he'll list a complete description of the command syntax, the meaning of each option, and related commands.

The general form of the command is: Man [option] command name

The main options in the command have the following meanings:

-m path Specifies the path of the Search man manual page

-S Chapter list specifies the list of chapters to view

-A Show all chapters

Chapter number Specifies the chapter number you want to view

(1) All manual pages belong to a specific field, denoted by a character.

The most common areas under Linux and their names and descriptions are as follows:

Domain Name Description

1 user commands, which can be initiated by anyone.

2 system calls, which are functions provided by the kernel.

3 routines, that is, library functions.

4 device, which is a special file in the/dev directory.

5 file format description, such as/etc/passwd.

6 games, no explanation!

7 Miscellaneous, such as macro command packs, conventions, and so on.

8 system Administrator tool, can only be started by root.

9 Other (Linux-specific) documents used to store kernel routines.

N new documents, you may want to move to a more appropriate area.

o old documents may be retained for a period of time.

L Local documentation, related to this particular system.

For example: Man LS will have LS (1)

(2) Some common parameters and usages of man

Man-a cmd

Open all areas of the same name help, for example man fam, you will first enter a fam (1M) version of the command fam Help, you press Q again

Will go into fam (3X), library function version of Help

Man-aw cmd

Displays all cmd file paths for all manuals, such as the Man-aw fam is

/usr/share/man/man1/fam.1m.gz

/usr/share/man/man3/fam.3x.gz

Man field code cmd

Direct designation of search manual pages in specific areas, such as the Man 3 fam directly into the library function version of Help

Man-m cmd

Specifies the search path for the manual file, such as Man-m/home/mysql/man MySQL shows you the help of the MySQL installation,

Instead of the system comes with the help of the old version of MySQL

Man cmd | Col-b > Cmd.txt

Output man manual information to a text file

Lang= Language Code

Man-w cmd

The path of a man-specific language manpage file

View a man page for a specific language version

For example, to view MPlayer's Chinese man

Shell> Lang=zh

Shell> man-w MPlayer

/usr/share/man/zh/man1/mplayer.1.gz

Open a new Shell window (or shell> lang=en_us in the original window). UTF-8)

Shell> man/usr/share/man/zh/man1/mplayer.1.gz

(3) Man's configuration file/etc/man.config

If you don't want to specify the path with-M every time man cmd, you can modify the configuration file to add content such as

Manpath/home/mysql/man

Man's search order in various fields can be modified by

Mansect 1:8:2:3:4:5:6:7:9:tcl:n:l:p:o

Implementation, generally not recommended modification.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.