- man page (Русский)
- Contents
- Доступ к man-страницам
- Формат страниц
- Поиск по страницам
- Просмотр локальных страниц
- Конвертирование страниц в HTML
- mandoc
- man2html
- man -H
- roffit
- Конвертирование в PDF
- Просмотр онлайн-страниц
- Полезные страницы
- Linux / UNIX: Getting help with man pages and how to use them
- man page sections
- man command examples
- Search man page referenced by printf
- Search man page by keywords
- How do I save man pages to a text file?
- Display all matching man pages
- info documentation
- info syntax
- Info page navigation commands
- /usr/share/doc
- How To – Linux / UNIX Create a Manpage
- Troff and Groff Macro
- A Quick Note About Man Page Layout
- Man Page Sections
- How to install man pages on Ubuntu Linux
- How to install man pages on Ubuntu Linux
- Search for Ubuntu man pages
- Create man page in Linux with examples (sample man page template)
- Where to find?
- How to create man page?
- Supported Macros
- Man Page Template and Example
- Man command in Linux
- How to Install?
- How to create user specific man page?
- Related Posts
man page (Русский)
man-страницы (от англ. manual — руководство) — справочные страницы, которые предоставляются почти всеми *nix-дистрибутивами, включая Arch Linux. Для их отображения служит команда man .
man-страницы изначально подразумевались как самодостаточные документы. Они ограничены в возможностях ссылаться друг на друга, в отличие от поддерживающих гиперссылки info-файлов — попытки GNU создать замену традиционному формату man-страниц.
Contents
Доступ к man-страницам
Чтобы отобразить man-страницу, наберите
Все страницы разделены на несколько категорий:
- Основные команды
- Системные вызовы (функции, предоставляемые ядром linux)
- Библиотечные вызовы (функции стандартной библиотеки языка Си)
- Специальные файлы (обычно расположенные в /dev ) и драйверы
- Форматы файлов и соглашения
- Игры
- Прочие страницы (также включая соглашения)
- Команды для системного администрирования (для которых обычно требуются права суперпользователя) и демоны
На man-страницы принято ссылаться по имени, с указанием номера категории в скобках. Часто существуют сразу несколько man-страниц с одинаковыми именами, но в разных категориях, например man(1) и man(7). В таком случае, команде man необходимо передать номер конкретной категории перед именем man-страницы, например:
отобразит man-страницу по файлу /etc/passwd вместо утилиты passwd .
Вместо того, чтобы отображать man-страницу целиком, вы можете вывести лишь ее краткое описание, используя команду whatis . Например,
выведет краткое описание команды ls: «list directory contents» («отобразить содержимое каталога»).
Формат страниц
Для удобства навигации, все man-страницы соответствуют единому стандартному формату. Вот список некоторых разделов, которые часто используются на страницах:
- NAME — имя команды и краткое однострочное описание ее назначения.
- SYNOPSIS — список опций и аргументов командной строки, которые принимает команда, либо параметры функции и ее заголовочный файл.
- DESCRIPTION — более подробное описание назначения и принципов работы команды или функции.
- EXAMPLES — типовые примеры использования, обычно от самых простых к более сложным.
- OPTIONS — описания для каждой из опций, которые принимает команда.
- EXIT STATUS — коды возврата и их значения.
- FILES — связанные с командой или функцией файлы.
- BUGS — вероятные проблемы, связанные с работой команды или функции и ожидающие решения. Также известны как KNOWN BUGS.
- SEE ALSO — список связанных команд и функций.
- AUTHOR, HISTORY, COPYRIGHT, LICENSE, WARRANTY — информация о программе: ее история, условия использования, создатели программы.
Поиск по страницам
Хотя команда man позволяет отображать man-страницы, возникает сложность, когда вы не знаете точного названия желаемой страницы. К счастью, вы можете воспользоваться опциями -k или —apropos , для поиска по ключевому слову в описаниях man-страниц.
Поиск работает только по индексированным страницам. Кеш индекса может устареть или вовсе отсутствовать, и на попытки поиска вы не будете получать ожидаемых результатов. Вы можете создать индекс или обновить его, выполнив
Индексация страниц должна запускаться при каждом добавлении man-страниц.
Теперь вы можете воспользоваться поиском. Например, чтобы найти man-страницы, связанные с паролями («password»), введите:
С тем же успехом, вы также можете воспользоваться командой apropos :
По-умолчанию, ключевое слово интерпретируется как регулярное выражение.
Если вы хотите произвести более углубленный поиск по всему содержимому страниц, используйте опцию -K :
Просмотр локальных страниц
Кроме утилиты man, для чтения man-страниц вы также можете использовать веб-браузер, например lynx или Firefox. Просмотр страниц в браузере позволяет воспользоваться основным преимуществом info-страниц — гиперссылками. Пользователи KDE могут читать man-страницы в Konqueror, используя URL вида:
Кроме того, вы можете установить следующие пакеты из официальных репозиториев:
1. xorg-xman для просмотра страниц в X.
2. yelp — Help Browser из состава GNOME.
Конвертирование страниц в HTML
mandoc
Установите пакет mandoc . Чтобы конвертировать страницу, для примера, free(1) , наберите:
Получившийся файл free.html теперь можно открыть в любом веб-браузере.
man2html
Сконвертируйте страницу командой:
Другая полезная функция man2html — экспорт в обычный текстовый файл, который можно распечатать:
man -H
Реализация утилиты man от GNU, также позволяет открыть страницу в веб-браузере:
Команда запустит браузер, установленный в переменной окружения BROWSER . Вы можете указать браузер явно, передав путь до исполняемого файла сразу после опции -H .
roffit
Для конвертирования страницы выполните:
Конвертирование в PDF
Man-страницы всегда были удобны для печати: они написаны в формате troff, который является типографским языком. Если у вас установлен ghostscript, конвертирование man-страниц в PDF выполнить очень просто:
По этой ссылке вы можете посмотреть, как будет выглядеть получившийся PDF-документ.
Обратите внимание, что шрифты главным образом ограничены набором Times и имеют жестко заданные размеры. Документ не будет содержать гиперссылок. Некоторые man-страницы форматировались так, чтобы выглядеть хорошо в терминале, однако могут отображаться некорректно в форме PostScript или PDF-документов.
Следующий perl-скрипт конвертирует man-страницы в PDF, кэшируя файлы в каталоге $HOME/.manpdf/ , и открывает программу для просмотра документа mupdf .
Просмотр онлайн-страниц
Существуют множество онлайн-хранилищ man-страниц; вот небольшой список:
Полезные страницы
Здесь приведен небольшой список полезных man-страниц, которые могут помочь вам получить более углубленные знания о множестве полезных вещей. Некоторые из них могут служить хорошими справочниками (например, таблица ASCII).
Вам могут быть интересны также и другие страницы седьмой категории:
А также страницы, относящиеся непосредственно к Arch Linux:
Источник
Linux / UNIX: Getting help with man pages and how to use them
The man Command
man page sections
Each man page comes in sections. The table below shows the section numbers of the manual followed by the types of pages they contain:
- Section # 1 : User command (executable programs or shell commands)
- Section # 2 : System calls (functions provided by the kernel)
- Section # 3 : Library calls (functions within program libraries)
- Section # 4 : Special files (usually found in /dev)
- Section # 5 : File formats and conventions eg /etc/passwd
- Section # 6 : Games
- Section # 7 : Miscellaneous (including macro packages and conventions),
- Section # 8 : System administration commands (usually only for root)
- Section # 9 : Kernel routines [Non standard]
So you see commands or files are referred by a name followed by manual section number in parentheses. For example, useradd(8) refers to the user add command from sys admin section # 8.
man command examples
Just use man command as follows:
man < command-name >
man < section > < command-name >
For example, display clear command man page, enter:
$ man clear
To display passwd file format man page (from section # 5):
$ man 5 passwd
To display more information about passwd command itself (from section # 1):
$ man 1 passwd
Search man page referenced by printf
To lookup the manual pages referenced by smail and print out the short descriptions of any found. For example:
$ man -f printf
Sample outputs:
This command is equivalent to whatis printf:
$ whatis -r printf
Search man page by keywords
Search the short descriptions and manual page names for the keyword printf as regular expression. Print out any matches.
$ man -k passwd
$ man -k printf
This command is equivalent to apropos printf:
$ apropos printf
$ apropos passwd
How do I save man pages to a text file?
The syntax is:
$ man ls | col -b > ls.txt
$ less less.txt
$ vi less.txt
Display all matching man pages
You can display, in succession, all of the available passwd manual pages contained within the manual. It is possible to quit between successive displays or skip any of them.
$ man -a passwd
To view next man page just hit [Enter] key, to skip press [CTRL+D] and to quit type [Ctrl+C].
info documentation
You can read documentation in Info format. This is another system that organizes its information into sections. info, a command used to view such documentation produced by Texinfo, a computer program documentation system developed for and by the GNU Project.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
info syntax
info < command-name >
For example display ls command info page:
$ info ls
In some cases, info command can offer more detailed help as compare to man page. For example try following two commands:
$ man date
$ info date
Info page navigation commands
- q – Quit info page
- n – Goto next section
- p – Goto previous section
- u – Goto one level up
You can start at buffers node within emacs manual
$ info emacs buffers
/usr/share/doc
You may also find /usr/share/doc a good place for more documentation. Both Gnome and KDE provides graphical help system under help menu. You can get help by pressing F1 key:
$ cd /usr/share/doc/
$ ls -l
$ ls -l | more
$ cd bash
$ ls -l
Sample outputs:
Use the more command to view docs:
$ more FAQ
$ grep word FAQ
$ vi FAQ
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
How To – Linux / UNIX Create a Manpage
Troff and Groff Macro
troff is a document processing system developed by AT&T for the Unix operating system. The troff typesetting system includes sets of commands called macros that are run before starting to process the document. These macros include setting up page headers and footers, defining new commands, and generally influencing how the output will be formatted. Under Linux all new manual pages should be marked up using the groff an.tmac package. The groff (GNU troff) software is a typesetting package which reads plain text mixed with formatting commands and produces formatted output.
A Quick Note About Man Page Layout
All man pages follow a common layout and it is recommend that you use the same for your man pages too:
You can add a few more other sections such as EXIT STATUS, ENVIRONMENT, FILES, and HISTORY etc. The table below shows the section numbers of the manual followed by the types of pages they contain.
Man Page Sections
The manual is generally split into eight numbered sections, organized as follows under Linux or UNIX like oses:
Section | Description |
---|---|
1 | Executable shell commands |
2 | System calls (functions provided by the kernel) |
3 | Library calls (functions within program libraries) |
4 | Special files (usually found in /dev) |
5 | File formats and conventions eg /etc/passwd |
6 | Games |
7 | Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) |
8 | System administration commands (usually only for root) |
9 | Kernel routines [Non standard] |
To see options and section information you can use with command man, enter the following command:
Источник
How to install man pages on Ubuntu Linux
I installed the minimal Ubuntu Linux 20.04 LTS cloud server, and now man pages are missing from my image. How do I install man pages on Ubuntu Linux 16.04/18.04/20.04 LTS server?
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Ubuntu Linux |
Est. reading time | 4 minutes |
Typically man pages for Ubuntu commands not installed on a minimal cloud server or container-based images. To save hard disk space and to keep container image rebuild time smaller, man pages not installed. But, fear not this page explains how to install man pages on Ubuntu Linux version 16.04/18.04/20.04 LTS using the apt command/apt-get command.
How to install man pages on Ubuntu Linux
You will see an error as follows when the man command and related files are not installed Ubuntu:
man
man useradd
-bash: man: command not found
First, you must run the following commands as the root user using the sudo command or su command. For example,
sudo -i
## OR ##
su —
Search for Ubuntu man pages
Use any one of the following command:
apt search manpages
apt search manpages | more
apt-cache search manpages
apt search man | grep -i db
We can filter out outputs using the grep command/egrep command:
apt-cache search manpages | egrep ‘manpages-(dev|posix)’
Let us see what these pages do:
apt info manpages-posix
apt info manpages-dev
apt info man-db
Источник
Create man page in Linux with examples (sample man page template)
Table of Contents
man page template in linux. create man page. man page with examples. create man page for custom script to check man script. sample man page template. how to write man page in Linux. Man page example. Man page template. Man Page editor. man command in linux. tutorial on how to write man page and how to create man page with examples. groff man command.
It is possible that in your organisation you have written a new tool for which you also need to create man page or write man page using any man page template. As man page are the single place where you can find all the details regarding the respective tool. man is the system’s manual pager. Each page argument given to man is normally the name of a program, utility or function.
So in this article I will share the steps to create man page with example in Linux with a sample man page template.
Where to find?
As an end user we use man to access the man page of the respective tool but most of us are unaware of the location of the man page. Now the ideal and default location of man pages of all the system tools are available under
Most which I have used were available under
But if you plan to create man page, you should keep the file under
To get the complete list of locations you can check /etc/man_db.conf . Below is a small snippet, for complete list please check the original man_db.conf file.
How to create man page?
To create man page (assuming from scratch), you can start by creating a new file under /usr/local/man/man1 .
For the sake of this article I will create man page for a dummy tool (test_script). If I try to access the man page of test_script
As we have not created one for this tool, we get this error. To create man page let us create an empty file.
Now you should be able to access the man page for test_script . Since currently the text file is empty, we see blank output.
Supported Macros
Below are the list of supported Macros:
Macro | Meaning |
---|---|
.B | Bold |
.BI | Bold, italic alternating |
.BR | Bold, roman alternating |
.EE | Example end |
.EX | Example end |
.I | Italic |
.IB | Italic, bold alternating |
.IP | Indented paragraph |
.IR | Italic, roman alternating |
.LP | (Left) paragraph |
.ME | Mail-to end |
.MT | Mail-to start |
.OP | (Command-line) option |
.P | Paragraph |
.PP | Paragraph |
.RB | Roman, bold alternating |
.RE | Relative-indent end |
.RI | Roman, italic alternating |
.RS | Relative-indent start |
.SB | Small bold |
.SH | Section heading |
.SM | Small |
.SS | Subsection heading |
.SY | Synopsis start |
.TH | Title heading |
.TP | Tagged paragraph |
.TQ | Tagged paragraph continuation |
.UE | URL end |
.UR | URL start |
.YS | Synopsis end |
Man Page Template and Example
The groff (GNU Troff) software is a typesetting package which reads plain text mixed with formatting commands and produces formatted output such as man page
You can use any editor to create man page such as vim or nano. To demonstrate this article I will create man page under /usr/local/man/man1 .
Below I have created a man page template. Here I have tried to use various macros which can help you choose between various options to help you create man page of your own
Man command in Linux
Above using the template we wrote our man page example for test script. To access the man page which we created using our man page template you can use man scriptname from the terminal.
How to Install?
To install man page you can leave the file test_script.1 under /usr/local/man/man1/
You can also archive this file into gzip format
Next a new archive will be created with gzip extension
How to create user specific man page?
To create a user specific man page you can choose a separate folder which is accessible only to the respective user. For example I have a user deepak and I will place the man page file under the home directory of this user.
So I will create a new structure under /home/deepak
Next move the man page of test_script which we placed under /usr/local/man/man1 . We are moving the file as we want only deepak user to access this man page.
Switch user to deepak
Next we must define the path of the man page location for deepak user using MANPATH . Check if there are any existing path defined for MANPATH .
Since there are no paths defined we will add the new path for MANPATH
If the user was already using MANPATH var then you can append the new path using below command
So this will append the new man page path to MANPATH variable
Next verify your variable content
So this should do the trick and now we should be able to access the man page of test_script
But if you try to access the same using root
If you wish to allow root user to access man page for test_script then add /home/deepak/man/man1 path to root user’s shell for MANPATH variable
Lastly I hope the steps from the article to create man page using man page template with examples on Linux was helpful. So, let me know your suggestions and feedback using the comment section.
Related Posts
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
Источник