title: koi8-u(7)

text:
# koi8-u(7)

## NAME
koi8-u - Ukrainian character set encoded in octal, decimal, and hexadecimal

## DESCRIPTION
RFC 2310 defines an 8-bit character set, KOI8-U. KOI8-U encodes the characters used in Ukrainian and Byelorussian.

### KOI8-U characters
The following table displays the characters in KOI8-U that are printable and unlisted in the ascii(7) manual page.

Oct

Dec

Hex

Char

Description

200

128

80

─

BOX DRAWINGS LIGHT HORIZONTAL

201

129

81

│

BOX DRAWINGS LIGHT VERTICAL

202

130

82

┌

BOX DRAWINGS LIGHT DOWN AND RIGHT

203

131

83

┐

BOX DRAWINGS LIGHT DOWN AND LEFT

204

132

84

└

BOX DRAWINGS LIGHT UP AND RIGHT

205

133

85

┘

BOX DRAWINGS LIGHT UP AND LEFT

206

134

86

├

BOX DRAWINGS LIGHT VERTICAL AND RIGHT

207

135

87

┤

BOX DRAWINGS LIGHT VERTICAL AND LEFT

210

136

88

┬

BOX DRAWINGS LIGHT DOWN AND HORIZONTAL

211

137

89

┴

BOX DRAWINGS LIGHT UP AND HORIZONTAL

212

138

8A

┼

BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL

213

139

8B

▀

UPPER HALF BLOCK

214

140

8C

▄

LOWER HALF BLOCK

215

141

8D

█

FULL BLOCK

216

142

8E

▌

LEFT HALF BLOCK

217

143

8F

▐

RIGHT HALF BLOCK

220

144

90

░

LIGHT SHADE

221

145

91

▒

MEDIUM SHADE

222

146

92

▓

DARK SHADE

223

147

93

⌠

TOP HALF INTEGRAL

224

148

94

■

BLACK SQUARE

225

149

95

∙

BULLET OPERATOR

226

150

96

√

SQUARE ROOT

227

151

97

≈

ALMOST EQUAL TO

230

152

98

≤

LESS-THAN OR EQUAL TO

231

153

99

≥

GREATER-THAN OR EQUAL TO

232

154

9A

NO-BREAK SPACE

233

155

9B

⌡

BOTTOM HALF INTEGRAL

234

156

9C

°

DEGREE SIGN

235

157

9D

²

SUPERSCRIPT TWO

236

158

9E

·

MIDDLE DOT

237

159

9F

÷

DIVISION SIGN

240

160

A0

═

BOX DRAWINGS DOUBLE HORIZONTAL

241

161

A1

║

BOX DRAWINGS DOUBLE VERTICAL

242

162

A2

╒

BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE

243

163

A3

ё

CYRILLIC SMALL LETTER IO

244

164

A4

є

CYRILLIC SMALL LETTER UKRAINIAN IE

245

165

A5

╔

BOX DRAWINGS DOUBLE DOWN AND RIGHT

246

166

A6

і

CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I

247

167

A7

ї

CYRILLIC SMALL LETTER YI (Ukrainian)

250

168

A8

╗

BOX DRAWINGS DOUBLE DOWN AND LEFT

251

169

A9

╘

BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE

252

170

AA

╙

BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE

253

171

AB

╚

BOX DRAWINGS DOUBLE UP AND RIGHT

254

172

AC

╛

BOX DRAWINGS UP SINGLE AND LEFT DOUBLE

255

173

AD

ґ

CYRILLIC SMALL LETTER GHE WITH UPTURN

256

174

AE

╝

BOX DRAWINGS DOUBLE UP AND LEFT

257

175

AF

╞

BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE

260

176

B0

╟

BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE

261

177

B1

╠

BOX DRAWINGS DOUBLE VERTICAL AND RIGHT

262

178

B2

╡

BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE

263

179

B3

Ё

CYRILLIC CAPITAL LETTER IO

264

180

B4

Є

CYRILLIC CAPITAL LETTER UKRAINIAN IE

265

181

B5

╣

BOX DRAWINGS DOUBLE VERTICAL AND LEFT

266

182

B6

І

CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I

267

183

B7

Ї

CYRILLIC CAPITAL LETTER YI (Ukrainian)

270

184

B8

╦

BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL

271

185

B9

╧

BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE

272

186

BA

╨

BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE

273

187

BB

╩

BOX DRAWINGS DOUBLE UP AND HORIZONTAL

274

188

BC

╪

BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE

275

189

BD

Ґ

CYRILLIC CAPITAL LETTER GHE WITH UPTURN

276

190

BE

╬

BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL

277

191

BF

©

COPYRIGHT SIGN

300

192

C0

ю

CYRILLIC SMALL LETTER YU

301

193

C1

а

CYRILLIC SMALL LETTER A

302

194

C2

б

CYRILLIC SMALL LETTER BE

303

195

C3

ц

CYRILLIC SMALL LETTER TSE

304

196

C4

д

CYRILLIC SMALL LETTER DE

305

197

C5

е

CYRILLIC SMALL LETTER IE

306

198

C6

ф

CYRILLIC SMALL LETTER EF

307

199

C7

г

CYRILLIC SMALL LETTER GHE

310

200

C8

х

CYRILLIC SMALL LETTER HA

311

201

C9

и

CYRILLIC SMALL LETTER I

312

202

CA

й

CYRILLIC SMALL LETTER SHORT I

313

203

CB

к

CYRILLIC SMALL LETTER KA

314

204

CC

л

CYRILLIC SMALL LETTER EL

315

205

CD

м

CYRILLIC SMALL LETTER EM

316

206

CE

н

CYRILLIC SMALL LETTER EN

317

207

CF

о

CYRILLIC SMALL LETTER O

320

208

D0

п

CYRILLIC SMALL LETTER PE

321

209

D1

я

CYRILLIC SMALL LETTER YA

322

210

D2

р

CYRILLIC SMALL LETTER ER

323

211

D3

с

CYRILLIC SMALL LETTER ES

324

212

D4

т

CYRILLIC SMALL LETTER TE

325

213

D5

у

CYRILLIC SMALL LETTER U

326

214

D6

ж

CYRILLIC SMALL LETTER ZHE

327

215

D7

в

CYRILLIC SMALL LETTER VE

330

216

D8

ь

CYRILLIC SMALL LETTER SOFT SIGN

331

217

D9

ы

CYRILLIC SMALL LETTER YERU

332

218

DA

з

CYRILLIC SMALL LETTER ZE

333

219

DB

ш

CYRILLIC SMALL LETTER SHA

334

220

DC

э

CYRILLIC SMALL LETTER E

335

221

DD

щ

CYRILLIC SMALL LETTER SHCHA

336

222

DE

ч

CYRILLIC SMALL LETTER CHE

337

223

DF

ъ

CYRILLIC SMALL LETTER HARD SIGN

340

224

E0

Ю

CYRILLIC CAPITAL LETTER YU

341

225

E1

А

CYRILLIC CAPITAL LETTER A

342

226

E2

Б

CYRILLIC CAPITAL LETTER BE

343

227

E3

Ц

CYRILLIC CAPITAL LETTER TSE

344

228

E4

Д

CYRILLIC CAPITAL LETTER DE

345

229

E5

Е

CYRILLIC CAPITAL LETTER IE

346

230

E6

Ф

CYRILLIC CAPITAL LETTER EF

347

231

E7

Г

CYRILLIC CAPITAL LETTER GHE

350

232

E8

Х

CYRILLIC CAPITAL LETTER HA

351

233

E9

И

CYRILLIC CAPITAL LETTER I

352

234

EA

Й

CYRILLIC CAPITAL LETTER SHORT I

353

235

EB

К

CYRILLIC CAPITAL LETTER KA

354

236

EC

Л

CYRILLIC CAPITAL LETTER EL

355

237

ED

М

CYRILLIC CAPITAL LETTER EM

356

238

EE

Н

CYRILLIC CAPITAL LETTER EN

357

239

EF

О

CYRILLIC CAPITAL LETTER O

360

240

F0

П

CYRILLIC CAPITAL LETTER PE

361

241

F1

Я

CYRILLIC CAPITAL LETTER YA

362

242

F2

Р

CYRILLIC CAPITAL LETTER ER

363

243

F3

С

CYRILLIC CAPITAL LETTER ES

364

244

F4

Т

CYRILLIC CAPITAL LETTER TE

365

245

F5

У

CYRILLIC CAPITAL LETTER U

366

246

F6

Ж

CYRILLIC CAPITAL LETTER ZHE

367

247

F7

В

CYRILLIC CAPITAL LETTER VE

370

248

F8

Ь

CYRILLIC CAPITAL LETTER SOFT SIGN

371

249

F9

Ы

CYRILLIC CAPITAL LETTER YERU

372

250

FA

З

CYRILLIC CAPITAL LETTER ZE

373

251

FB

Ш

CYRILLIC CAPITAL LETTER SHA

374

252

FC

Э

CYRILLIC CAPITAL LETTER E

375

253

FD

Щ

CYRILLIC CAPITAL LETTER SHCHA

376

254

FE

Ч

CYRILLIC CAPITAL LETTER CHE

377

255

FF

Ъ

CYRILLIC CAPITAL LETTER HARD SIGN

## NOTES
The differences from KOI8-R are in the hex positions A4, A6, A7, AD, B4, B6, B7, and BD.

## SEE ALSO
ascii(7), charsets(7), cp1251(7), iso_8859-5(7), koi8-r(7), utf-8(7)


libc

package: man-pages

title: libc(7)

text:
# libc(7)

## NAME
libc - overview of standard C libraries on Linux

## DESCRIPTION
The term "libc" is commonly used as a shorthand for the "standard C library", a library of standard functions that can be used by all C programs (and sometimes by programs in other languages). Because of some history (see below), use of the term "libc" to refer to the standard C library is somewhat ambiguous on Linux.

### glibc
By far the most widely used C library on Linux is the GNU C Library http://www.gnu.org/software/libc/, often referred to as glibc. This is the C library that is nowadays used in all major Linux distributions. It is also the C library whose details are documented in the relevant pages of the man-pages project (primarily in Section 3 of the manual). Documentation of glibc is also available in the glibc manual, available via the command info libc. Release 1.0 of glibc was made in September 1992. (There were earlier 0.x releases.) The next major release of glibc was 2.0, at the beginning of 1997.

The pathname /lib/libc.so.6 (or something similar) is normally a symbolic link that points to the location of the glibc library, and executing this pathname will cause glibc to display various information about the version installed on your system.

### Linux libc
In the early to mid 1990s, there was for a while Linux libc, a fork of glibc 1.x created by Linux developers who felt that glibc development at the time was not sufficing for the needs of Linux. Often, this library was referred to (ambiguously) as just "libc". Linux libc released major versions 2, 3, 4, and 5, as well as many minor versions of those releases. Linux libc4 was the last version to use the a.out binary format, and the first version to provide (primitive) shared library support. Linux libc 5 was the first version to support the ELF binary format; this version used the shared library soname libc.so.5. For a while, Linux libc was the standard C library in many Linux distributions.

However, notwithstanding the original motivations of the Linux libc effort, by the time glibc 2.0 was released (in 1997), it was clearly superior to Linux libc, and all major Linux distributions that had been using Linux libc soon switched back to glibc. To avoid any confusion with Linux libc versions, glibc 2.0 and later used the shared library soname libc.so.6.

Since the switch from Linux libc to glibc 2.0 occurred long ago, man-pages no longer takes care to document Linux libc details. Nevertheless, the history is visible in vestiges of information about Linux libc that remain in a few manual pages, in particular, references to libc4 and libc5.

### Other C libraries
There are various other less widely used C libraries for Linux. These libraries are generally smaller than glibc, both in terms of features and memory footprint, and often intended for building small binaries, perhaps targeted at development for embedded Linux systems. Among such libraries are uClibc, dietlibc, and musl libc. Details of these libraries are covered by the man-pages project, where they are known.

## SEE ALSO
syscalls(2), getauxval(3), proc(5), feature_test_macros(7), man-pages(7), standards(7), vdso(7)


locale

title: locale(7)

summary: description of multilanguage support

text:
# locale(7)

## NAME
locale - description of multilanguage support

## SYNOPSIS

```
#include <locale.h>
```

## DESCRIPTION
A locale is a set of language and cultural rules. These cover aspects such as language for messages, different character sets, lexicographic conventions, and so on. A program needs to be able to determine its locale and act accordingly to be portable to different cultures.

The header <locale.h> declares data types, functions, and macros which are useful in this task.

The functions it declares are setlocale(3) to set the current locale, and localeconv(3) to get information about number formatting.

There are different categories for locale information a program might need; they are declared as macros. Using them as the first argument to the setlocale(3) function, it is possible to set one of these to the desired locale:

LC_ADDRESS (GNU extension, since glibc 2.2)

Change settings that describe the formats (e.g., postal addresses) used to describe locations and geography-related items. Applications that need this information can use nl_langinfo(3) to retrieve nonstandard elements, such as _NL_ADDRESS_COUNTRY_NAME (country name, in the language of the locale) and _NL_ADDRESS_LANG_NAME (language name, in the language of the locale), which return strings such as "Deutschland" and "Deutsch" (for German-language locales). (Other element names are listed in <langinfo.h>.)

LC_COLLATE

This category governs the collation rules used for sorting and regular expressions, including character equivalence classes and multicharacter collating elements. This locale category changes the behavior of the functions strcoll(3) and strxfrm(3), which are used to compare strings in the local alphabet. For example, the German sharp s is sorted as "ss".

LC_CTYPE

This category determines the interpretation of byte sequences as characters (e.g., single versus multibyte characters), character classifications (e.g., alphabetic or digit), and the behavior of character classes. On glibc systems, this category also determines the character transliteration rules for iconv(1) and iconv(3). It changes the behavior of the character handling and classification functions, such as isupper(3) and toupper(3), and the multibyte character functions such as mblen(3) or wctomb(3).

LC_IDENTIFICATION (GNU extension, since glibc 2.2)

Change settings that relate to the metadata for the locale. Applications that need this information can use nl_langinfo(3) to retrieve nonstandard elements, such as _NL_IDENTIFICATION_TITLE (title of this locale document) and _NL_IDENTIFICATION_TERRITORY (geographical territory to which this locale document applies), which might return strings such as "English locale for the USA" and "USA". (Other element names are listed in <langinfo.h>.)

LC_MONETARY

This category determines the formatting used for monetary-related numeric values. This changes the information returned by localeconv(3), which describes the way numbers are usually printed, with details such as decimal point versus decimal comma. This information is internally used by the function strfmon(3).

LC_MESSAGES

This category affects the language in which messages are displayed and what an affirmative or negative answer looks like. The GNU C library contains the gettext(3), ngettext(3), and rpmatch(3) functions to ease the use of this information. The GNU gettext family of functions also obey the environment variable LANGUAGE (containing a colon-separated list of locales) if the category is set to a valid locale other than "C". This category also affects the behavior of catopen(3).

LC_MEASUREMENT (GNU extension, since glibc 2.2)

Change the settings relating to the measurement system in the locale (i.e., metric versus US customary units). Applications can use nl_langinfo(3) to retrieve the nonstandard _NL_MEASUREMENT_MEASUREMENT element, which returns a pointer to a character that has the value 1 (metric) or 2 (US customary units).

LC_NAME (GNU extension, since glibc 2.2)

Change settings that describe the formats used to address persons. Applications that need this information can use nl_langinfo(3) to retrieve nonstandard elements, such as _NL_NAME_NAME_MR (general salutation for men) and _NL_NAME_NAME_MS (general salutation for women) elements, which return strings such as "Herr" and "Frau" (for German-language locales). (Other element names are listed in <langinfo.h>.)

LC_NUMERIC

This category determines the formatting rules used for nonmonetary numeric values—for example, the thousands separator and the radix character (a period in most English-speaking countries, but a comma in many other regions). It affects functions such as printf(3), scanf(3), and strtod(3). This information can also be read with the localeconv(3) function.

LC_PAPER (GNU extension, since glibc 2.2)

Change the settings relating to the dimensions of the standard paper size (e.g., US letter versus A4). Applications that need the dimensions can obtain them by using nl_langinfo(3) to retrieve the nonstandard _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT elements, which return int values specifying the dimensions in millimeters.

LC_TELEPHONE (GNU extension, since glibc 2.2)

Change settings that describe the formats to be used with telephone services. Applications that need this information can use nl_langinfo(3) to retrieve nonstandard elements, such as _NL_TELEPHONE_INT_PREFIX (international prefix used to call numbers in this locale), which returns a string such as "49" (for Germany). (Other element names are listed in <langinfo.h>.)

LC_TIME

This category governs the formatting used for date and time values. For example, most of Europe uses a 24-hour clock versus the 12-hour clock used in the United States. The setting of this category affects the behavior of functions such as strftime(3) and strptime(3).

LC_ALL

All of the above.

If the second argument to setlocale(3) is an empty string, "", for the default locale, it is determined using the following steps:

1.

If there is a non-null environment variable LC_ALL, the value of LC_ALL is used.

2.

If an environment variable with the same name as one of the categories above exists and is non-null, its value is used for that category.

3.

If there is a non-null environment variable LANG, the value of LANG is used.

Values about local numeric formatting is made available in a struct lconv returned by the localeconv(3) function, which has the following declaration:

```
struct lconv {

    /* Numeric (nonmonetary) information */

    char *decimal_point;     /* Radix character */

    char *thousands_sep;     /* Separator for digit groups to left

                                of radix character */

    char *grouping;     /* Each element is the number of digits in

                           a group; elements with higher indices

                           are further left.  An element with value

                           CHAR_MAX means that no further grouping

                           is done.  An element with value 0 means

                           that the previous element is used for

                           all groups further left. */

    /* Remaining fields are for monetary information */

    char *int_curr_symbol;   /* First three chars are a currency

                                symbol from ISO 4217.  Fourth char

                                is the separator.  Fifth char

                                is '\0'. */

    char *currency_symbol;   /* Local currency symbol */

    char *mon_decimal_point; /* Radix character */

    char *mon_thousands_sep; /* Like thousands_sep above */

    char *mon_grouping;      /* Like grouping above */

    char *positive_sign;     /* Sign for positive values */

    char *negative_sign;     /* Sign for negative values */

    char  int_frac_digits;   /* International fractional digits */

    char  frac_digits;       /* Local fractional digits */

    char  p_cs_precedes;     /* 1 if currency_symbol precedes a

                                positive value, 0 if succeeds */

    char  p_sep_by_space;    /* 1 if a space separates

                                currency_symbol from a positive

                                value */

    char  n_cs_precedes;     /* 1 if currency_symbol precedes a

                                negative value, 0 if succeeds */

    char  n_sep_by_space;    /* 1 if a space separates

                                currency_symbol from a negative

                                value */

    /* Positive and negative sign positions:

       0 Parentheses surround the quantity and currency_symbol.

       1 The sign string precedes the quantity and currency_symbol.

       2 The sign string succeeds the quantity and currency_symbol.

       3 The sign string immediately precedes the currency_symbol.

       4 The sign string immediately succeeds the currency_symbol. */

    char  p_sign_posn;

    char  n_sign_posn;
};
```

### POSIX.1-2008 extensions to the locale API
POSIX.1-2008 standardized a number of extensions to the locale API, based on implementations that first appeared in version 2.3 of the GNU C library. These extensions are designed to address the problem that the traditional locale APIs do not mix well with multithreaded applications and with applications that must deal with multiple locales.

The extensions take the form of new functions for creating and manipulating locale objects (newlocale(3), freelocale(3), duplocale(3), and uselocale(3)) and various new library functions with the suffix "_l" (e.g., toupper_l(3)) that extend the traditional locale-dependent APIs (e.g., toupper(3)) to allow the specification of a locale object that should apply when executing the function.

## ENVIRONMENT
The following environment variable is used by newlocale(3) and setlocale(3), and thus affects all unprivileged localized programs:

LOCPATH

A list of pathnames, separated by colons (':'), that should be used to find locale data. If this variable is set, only the individual compiled locale data files from LOCPATH and the system default locale data path are used; any available locale archives are not used (see localedef(1)). The individual compiled locale data files are searched for under subdirectories which depend on the currently used locale. For example, when en_GB.UTF-8 is used for a category, the following subdirectories are searched for, in this order: en_GB.UTF-8, en_GB.utf8, en_GB, en.UTF-8, en.utf8, and en.

## FILES
/usr/lib/locale/locale-archive

Usual default locale archive location.

/usr/lib/locale

Usual default path for compiled individual locale files.

## CONFORMING TO
POSIX.1-2001.

## SEE ALSO
iconv(1), locale(1), localedef(1), catopen(3), gettext(3), iconv(3), localeconv(3), mbstowcs(3), newlocale(3), ngettext(3), nl_langinfo(3), rpmatch(3), setlocale(3), strcoll(3), strfmon(3), strftime(3), strxfrm(3), uselocale(3), wcstombs(3), locale(5), charsets(7), unicode(7), utf-8(7)


mailaddr

title: mailaddr(7)

summary: mail addressing description

text:
# mailaddr(7)

## NAME
mailaddr - mail addressing description

## DESCRIPTION
This manual page gives a brief introduction to SMTP mail addresses, as used on the Internet. These addresses are in the general format

user@domain

where a domain is a hierarchical dot-separated list of subdomains. These examples are valid forms of the same address:

john.doe@monet.example.com

John Doe <john.doe@monet.example.com>

john.doe@monet.example.com (John Doe)

The domain part ("monet.example.com") is a mail-accepting domain. It can be a host and in the past it usually was, but it doesn't have to be. The domain part is not case sensitive.

The local part ("john.doe") is often a username, but its meaning is defined by the local software. Sometimes it is case sensitive, although that is unusual. If you see a local-part that looks like garbage, it is usually because of a gateway between an internal e-mail system and the net, here are some examples:

"surname/admd=telemail/c=us/o=hp/prmd=hp"@some.where

USER%SOMETHING@some.where

machine!machine!name@some.where

I2461572@some.where

(These are, respectively, an X.400 gateway, a gateway to an arbitrary internal mail system that lacks proper internet support, an UUCP gateway, and the last one is just boring username policy.)

The real-name part ("John Doe") can either be placed before <>, or in () at the end. (Strictly speaking the two aren't the same, but the difference is beyond the scope of this page.) The name may have to be quoted using "", for example, if it contains ".":

"John Q. Doe" <john.doe@monet.example.com>

### Abbreviation
Some mail systems let users abbreviate the domain name. For instance, users at example.com may get away with "john.doe@monet" to send mail to John Doe. This behavior is deprecated. Sometimes it works, but you should not depend on it.

### Route-addrs
In the past, sometimes one had to route a message through several hosts to get it to its final destination. Addresses which show these relays are termed "route-addrs". These use the syntax:

<@hosta,@hostb:user@hostc>

This specifies that the message should be sent to hosta, from there to hostb, and finally to hostc. Many hosts disregard route-addrs and send directly to hostc.

Route-addrs are very unusual now. They occur sometimes in old mail archives. It is generally possible to ignore all but the "user@hostc" part of the address to determine the actual address.

### Postmaster
Every site is required to have a user or user alias designated "postmaster" to which problems with the mail system may be addressed. The "postmaster" address is not case sensitive.

## FILES
/etc/aliases

~/.forward

## SEE ALSO
mail(1), aliases(5), forward(5), sendmail(8)

IETF RFC 5322


man

title: man(7)

summary: macros to format man pages

text:
# man(7)

## NAME
man - macros to format man pages

## SYNOPSIS
groff -Tascii -man file ...

groff -Tps -man file ...

man [section] title

## DESCRIPTION
This manual page explains the groff an.tmac macro package (often called the man macro package). This macro package should be used by developers when writing or porting man pages for Linux. It is fairly compatible with other versions of this macro package, so porting man pages should not be a major problem (exceptions include the NET-2 BSD release, which uses a totally different macro package called mdoc; see mdoc(7)).

Note that NET-2 BSD mdoc man pages can be used with groff simply by specifying the -mdoc option instead of the -man option. Using the -mandoc option is, however, recommended, since this will automatically detect which macro package is in use.

For conventions that should be employed when writing man pages for the Linux man-pages package, see man-pages(7).

### Title line
The first command in a man page (after comment lines, that is, lines that start with .\") should be

.TH title section date source manual

For details of the arguments that should be supplied to the TH command, see man-pages(7).

Note that BSD mdoc-formatted pages begin with the Dd command, not the TH command.

### Sections
Sections are started with .SH followed by the heading name.

The only mandatory heading is NAME, which should be the first section and be followed on the next line by a one-line description of the program:

.SH NAME

item \- description

It is extremely important that this format is followed, and that there is a backslash before the single dash which follows the item name. This syntax is used by the mandb(8) program to create a database of short descriptions for the whatis(1) and apropos(1) commands. (See lexgrog(1) for further details on the syntax of the NAME section.)

For a list of other sections that might appear in a manual page, see man-pages(7).

### Fonts
The commands to select the type face are:

.B

Bold

.BI

Bold alternating with italics (especially useful for function specifications)

.BR

Bold alternating with Roman (especially useful for referring to other manual pages)

.I

Italics

.IB

Italics alternating with bold

.IR

Italics alternating with Roman

.RB

Roman alternating with bold

.RI

Roman alternating with italics

.SB

Small alternating with bold

.SM

Small (useful for acronyms)

Traditionally, each command can have up to six arguments, but the GNU implementation removes this limitation (you might still want to limit yourself to 6 arguments for portability's sake). Arguments are delimited by spaces. Double quotes can be used to specify an argument which contains spaces. For the macros that produce alternating type faces, the arguments will be printed next to each other without intervening spaces, so that the .BR command can be used to specify a word in bold followed by a mark of punctuation in Roman. If no arguments are given, the command is applied to the following line of text.

### Other macros and strings
Below are other relevant macros and predefined strings. Unless noted otherwise, all macros cause a break (end the current line of text). Many of these macros set or use the "prevailing indent". The "prevailing indent" value is set by any macro with the parameter i below; macros may omit i in which case the current prevailing indent will be used. As a result, successive indented paragraphs can use the same indent without respecifying the indent value. A normal (nonindented) paragraph resets the prevailing indent value to its default value (0.5 inches). By default, a given indent is measured in ens; try to use ens or ems as units for indents, since these will automatically adjust to font size changes. The other key macro definitions are:

### Normal paragraphs
.LP

Same as .PP (begin a new paragraph).

.P

Same as .PP (begin a new paragraph).

.PP

Begin a new paragraph and reset prevailing indent.

### Relative margin indent
.RS i

Start relative margin indent: moves the left margin i to the right (if i is omitted, the prevailing indent value is used). A new prevailing indent is set to 0.5 inches. As a result, all following paragraph(s) will be indented until the corresponding .RE.

.RE

End relative margin indent and restores the previous value of the prevailing indent.

### Indented paragraph macros
.HP i

Begin paragraph with a hanging indent (the first line of the paragraph is at the left margin of normal paragraphs, and the rest of the paragraph's lines are indented).

.IP x i

Indented paragraph with optional hanging tag. If the tag x is omitted, the entire following paragraph is indented by i. If the tag x is provided, it is hung at the left margin before the following indented paragraph (this is just like .TP except the tag is included with the command instead of being on the following line). If the tag is too long, the text after the tag will be moved down to the next line (text will not be lost or garbled). For bulleted lists, use this macro with \(bu (bullet) or \(em (em dash) as the tag, and for numbered lists, use the number or letter followed by a period as the tag; this simplifies translation to other formats.

.TP i

Begin paragraph with hanging tag. The tag is given on the next line, but its results are like those of the .IP command.

### Hypertext link macros
.UR url

Insert a hypertext link to the URI (URL) url, with all text up to the following .UE macro as the link text.

.UE

[trailer] Terminate the link text of the preceding .UR macro, with the optional trailer (if present, usually a closing parenthesis and/or end-of-sentence punctuation) immediately following. For non-HTML output devices (e.g., man -Tutf8), the link text is followed by the URL in angle brackets; if there is no link text, the URL is printed as its own link text, surrounded by angle brackets. (Angle brackets may not be available on all output devices.) For the HTML output device, the link text is hyperlinked to the URL; if there is no link text, the URL is printed as its own link text.

These macros have been supported since GNU Troff 1.20 (2009-01-05) and Heirloom Doctools Troff since 160217 (2016-02-17).

### Miscellaneous macros
.DT

Reset tabs to default tab values (every 0.5 inches); does not cause a break.

.PD d

Set inter-paragraph vertical distance to d (if omitted, d=0.4v); does not cause a break.

.SS t

Subheading t (like .SH, but used for a subsection inside a section).

### Predefined strings
The man package has the following predefined strings:

\*R

Registration Symbol: ®

\*S

Change to default font size

\*(Tm

Trademark Symbol: (Tm)

\*(lq

Left angled double quote: “

\*(rq

Right angled double quote: ”

### Safe subset
Although technically man is a troff macro package, in reality a large number of other tools process man page files that don't implement all of troff's abilities. Thus, it's best to avoid some of troff's more exotic abilities where possible to permit these other tools to work correctly. Avoid using the various troff preprocessors (if you must, go ahead and use tbl(1), but try to use the IP and TP commands instead for two-column tables). Avoid using computations; most other tools can't process them. Use simple commands that are easy to translate to other formats. The following troff macros are believed to be safe (though in many cases they will be ignored by translators): \", ., ad, bp, br, ce, de, ds, el, ie, if, fi, ft, hy, ig, in, na, ne, nf, nh, ps, so, sp, ti, tr.

You may also use many troff escape sequences (those sequences beginning with \). When you need to include the backslash character as normal text, use \e. Other sequences you may use, where x or xx are any characters and N is any digit, include: \', \`, \-, \., \", \%, \*x, \*(xx, \(xx, \$N, \nx, \n(xx, \fx, and \f(xx. Avoid using the escape sequences for drawing graphics.

Do not use the optional parameter for bp (break page). Use only positive values for sp (vertical space). Don't define a macro (de) with the same name as a macro in this or the mdoc macro package with a different meaning; it's likely that such redefinitions will be ignored. Every positive indent (in) should be paired with a matching negative indent (although you should be using the RS and RE macros instead). The condition test (if,ie) should only have 't' or 'n' as the condition. Only translations (tr) that can be ignored should be used. Font changes (ft and the \f escape sequence) should only have the values 1, 2, 3, 4, R, I, B, P, or CW (the ft command may also have no parameters).

If you use capabilities beyond these, check the results carefully on several tools. Once you've confirmed that the additional capability is safe, let the maintainer of this document know about the safe command or sequence that should be added to this list.

## FILES
/usr/share/groff/[*/]tmac/an.tmac

/usr/man/whatis

## NOTES
By all means include full URLs (or URIs) in the text itself; some tools such as man2html(1) can automatically turn them into hypertext links. You can also use the UR and UE macros to identify links to related information. If you include URLs, use the full URL (e.g., http://www.kernel.org) to ensure that tools can automatically find the URLs.

Tools processing these files should open the file and examine the first nonwhitespace character. A period (.) or single quote (') at the beginning of a line indicates a troff-based file (such as man or mdoc). A left angle bracket (<) indicates an SGML/XML-based file (such as HTML or Docbook). Anything else suggests simple ASCII text (e.g., a "catman" result).

Many man pages begin with '\" followed by a space and a list of characters, indicating how the page is to be preprocessed. For portability's sake to non-troff translators we recommend that you avoid using anything other than tbl(1), and Linux can detect that automatically. However, you might want to include this information so your man page can be handled by other (less capable) systems. Here are the definitions of the preprocessors invoked by these characters:

e

eqn(1)

g

grap(1)

p

pic(1)

r

refer(1)

t

tbl(1)

v

vgrind(1)

## BUGS
Most of the macros describe formatting (e.g., font type and spacing) instead of marking semantic content (e.g., this text is a reference to another page), compared to formats like mdoc and DocBook (even HTML has more semantic markings). This situation makes it harder to vary the man format for different media, to make the formatting consistent for a given media, and to automatically insert cross-references. By sticking to the safe subset described above, it should be easier to automate transitioning to a different reference page format in the future.

The Sun macro TX is not implemented.

## SEE ALSO
apropos(1), groff(1), lexgrog(1), man(1), man2html(1), whatis(1), groff_man(7), groff_www(7), man-pages(7), mdoc(7)


man-pages

title: man-pages(7)

summary: conventions for writing Linux man pages

text:
# man-pages(7)

## NAME
man-pages - conventions for writing Linux man pages

## SYNOPSIS
man [section] title

## DESCRIPTION
This page describes the conventions that should be employed when writing man pages for the Linux man-pages project, which documents the user-space API provided by the Linux kernel and the GNU C library. The project thus provides most of the pages in Section 2, many of the pages that appear in Sections 3, 4, and 7, and a few of the pages that appear in Sections 1, 5, and 8 of the man pages on a Linux system. The conventions described on this page may also be useful for authors writing man pages for other projects.

### Sections of the manual pages
The manual Sections are traditionally defined as follows:

1 User commands (Programs)

Commands that can be executed by the user from within a shell.

2 System calls

Functions which wrap operations performed by the kernel.

3 Library calls

All library functions excluding the system call wrappers (Most of the libc functions).

4 Special files (devices)

Files found in /dev which allow to access to devices through the kernel.

5 File formats and configuration files

Describes various human-readable file formats and configuration files.

6 Games

Games and funny little programs available on the system.

7 Overview, conventions, and miscellaneous

Overviews or descriptions of various topics, conventions, and protocols, character set standards, the standard filesystem layout, and miscellaneous other things.

8 System management commands

Commands like mount(8), many of which only root can execute.

### Macro package
New manual pages should be marked up using the groff an.tmac package described in man(7). This choice is mainly for consistency: the vast majority of existing Linux manual pages are marked up using these macros.

### Conventions for source file layout
Please limit source code line length to no more than about 75 characters wherever possible. This helps avoid line-wrapping in some mail clients when patches are submitted inline.

### Title line
The first command in a man page should be a TH command:

.TH title section date source manual

The arguments of the command are as follows:

title

The title of the man page, written in all caps (e.g., MAN-PAGES).

section

The section number in which the man page should be placed (e.g., 7).

date

The date of the last nontrivial change that was made to the man page. (Within the man-pages project, the necessary updates to these timestamps are handled automatically by scripts, so there is no need to manually update them as part of a patch.) Dates should be written in the form YYYY-MM-DD.

source

The source of the command, function, or system call.

For those few man-pages pages in Sections 1 and 8, probably you just want to write GNU.

For system calls, just write Linux. (An earlier practice was to write the version number of the kernel from which the manual page was being written/checked. However, this was never done consistently, and so was probably worse than including no version number. Henceforth, avoid including a version number.)

For library calls that are part of glibc or one of the other common GNU libraries, just use GNU C Library, GNU, or an empty string.

For Section 4 pages, use Linux.

In cases of doubt, just write Linux, or GNU.

manual

The title of the manual (e.g., for Section 2 and 3 pages in the man-pages package, use Linux Programmer's Manual).

### Sections within a manual page
The list below shows conventional or suggested sections. Most manual pages should include at least the highlighted sections. Arrange a new manual page so that sections are placed in the order shown in the list.

NAME

SYNOPSIS

CONFIGURATION

[Normally only in Section 4]

DESCRIPTION

OPTIONS

[Normally only in Sections 1, 8]

EXIT STATUS

[Normally only in Sections 1, 8]

RETURN VALUE

[Normally only in Sections 2, 3]

ERRORS

[Typically only in Sections 2, 3]

ENVIRONMENT

FILES

VERSIONS

[Normally only in Sections 2, 3]

ATTRIBUTES

[Normally only in Sections 2, 3]

CONFORMING TO

NOTES

BUGS

EXAMPLES

AUTHORS

[Discouraged]

REPORTING BUGS

[Not used in man-pages]

COPYRIGHT

[Not used in man-pages]

SEE ALSO

Where a traditional heading would apply, please use it; this kind of consistency can make the information easier to understand. If you must, you can create your own headings if they make things easier to understand (this can be especially useful for pages in Sections 4 and 5). However, before doing this, consider whether you could use the traditional headings, with some subsections (.SS) within those sections.

The following list elaborates on the contents of each of the above sections.

NAME

The name of this manual page.

See man(7) for important details of the line(s) that should follow the .SH NAME command. All words in this line (including the word immediately following the "\-") should be in lowercase, except where English or technical terminological convention dictates otherwise.

SYNOPSIS

A brief summary of the command or function's interface.

For commands, this shows the syntax of the command and its arguments (including options); boldface is used for as-is text and italics are used to indicate replaceable arguments. Brackets ([]) surround optional arguments, vertical bars (|) separate choices, and ellipses (...) can be repeated. For functions, it shows any required data declarations or #include directives, followed by the function declaration.

Where a feature test macro must be defined in order to obtain the declaration of a function (or a variable) from a header file, then the SYNOPSIS should indicate this, as described in feature_test_macros(7).

CONFIGURATION

Configuration details for a device.

This section normally appears only in Section 4 pages.

DESCRIPTION

An explanation of what the program, function, or format does.

Discuss how it interacts with files and standard input, and what it produces on standard output or standard error. Omit internals and implementation details unless they're critical for understanding the interface. Describe the usual case; for information on command-line options of a program use the OPTIONS section.

When describing new behavior or new flags for a system call or library function, be careful to note the kernel or C library version that introduced the change. The preferred method of noting this information for flags is as part of a .TP list, in the following form (here, for a new system call flag):

XYZ_FLAG (since Linux 3.7)

Description of flag...

Including version information is especially useful to users who are constrained to using older kernel or C library versions (which is typical in embedded systems, for example).

OPTIONS

A description of the command-line options accepted by a program and how they change its behavior.

This section should appear only for Section 1 and 8 manual pages.

EXIT STATUS

A list of the possible exit status values of a program and the conditions that cause these values to be returned.

This section should appear only for Section 1 and 8 manual pages.

RETURN VALUE

For Section 2 and 3 pages, this section gives a list of the values the library routine will return to the caller and the conditions that cause these values to be returned.

ERRORS

For Section 2 and 3 manual pages, this is a list of the values that may be placed in errno in the event of an error, along with information about the cause of the errors.

Where several different conditions produce the same error, the preferred approach is to create separate list entries (with duplicate error names) for each of the conditions. This makes the separate conditions clear, may make the list easier to read, and allows metainformation (e.g., kernel version number where the condition first became applicable) to be more easily marked for each condition.

The error list should be in alphabetical order.

ENVIRONMENT

A list of all environment variables that affect the program or function and how they affect it.

FILES

A list of the files the program or function uses, such as configuration files, startup files, and files the program directly operates on.

Give the full pathname of these files, and use the installation process to modify the directory part to match user preferences. For many programs, the default installation location is in /usr/local, so your base manual page should use /usr/local as the base.

ATTRIBUTES

A summary of various attributes of the function(s) documented on this page. See attributes(7) for further details.

VERSIONS

A brief summary of the Linux kernel or glibc versions where a system call or library function appeared, or changed significantly in its operation.

As a general rule, every new interface should include a VERSIONS section in its manual page. Unfortunately, many existing manual pages don't include this information (since there was no policy to do so when they were written). Patches to remedy this are welcome, but, from the perspective of programmers writing new code, this information probably matters only in the case of kernel interfaces that have been added in Linux 2.4 or later (i.e., changes since kernel 2.2), and library functions that have been added to glibc since version 2.1 (i.e., changes since glibc 2.0).

The syscalls(2) manual page also provides information about kernel versions in which various system calls first appeared.

CONFORMING TO

A description of any standards or conventions that relate to the function or command described by the manual page.

The preferred terms to use for the various standards are listed as headings in standards(7).

For a page in Section 2 or 3, this section should note the POSIX.1 version(s) that the call conforms to, and also whether the call is specified in C99. (Don't worry too much about other standards like SUS, SUSv2, and XPG, or the SVr4 and 4.xBSD implementation standards, unless the call was specified in those standards, but isn't in the current version of POSIX.1.)

If the call is not governed by any standards but commonly exists on other systems, note them. If the call is Linux-specific, note this.

If this section consists of just a list of standards (which it commonly does), terminate the list with a period ('.').

NOTES

Miscellaneous notes.

For Section 2 and 3 man pages you may find it useful to include subsections (SS) named Linux Notes and Glibc Notes.

In Section 2, use the heading C library/kernel differences to mark off notes that describe the differences (if any) between the C library wrapper function for a system call and the raw system call interface provided by the kernel.

BUGS

A list of limitations, known defects or inconveniences, and other questionable activities.

EXAMPLES

One or more examples demonstrating how this function, file, or command is used.

For details on writing example programs, see Example programs below.

AUTHORS

A list of authors of the documentation or program.

Use of an AUTHORS section is strongly discouraged. Generally, it is better not to clutter every page with a list of (over time potentially numerous) authors; if you write or significantly amend a page, add a copyright notice as a comment in the source file. If you are the author of a device driver and want to include an address for reporting bugs, place this under the BUGS section.

REPORTING BUGS

The man-pages project doesn't use a REPORTING BUGS section in manual pages. Information on reporting bugs is instead supplied in the script-generated COLOPHON section. However, various projects do use a REPORTING BUGS section. It is recommended to place it near the foot of the page.

COPYRIGHT

The man-pages project doesn't use a COPYRIGHT section in manual pages. Copyright information is instead maintained in the page source. In pages where this section is present, it is recommended to place it near the foot of the page, just above SEE ALSO.

SEE ALSO

A comma-separated list of related man pages, possibly followed by other related pages or documents.

The list should be ordered by section number and then alphabetically by name. Do not terminate this list with a period.

Where the SEE ALSO list contains many long manual page names, to improve the visual result of the output, it may be useful to employ the .ad l (don't right justify) and .nh (don't hyphenate) directives. Hyphenation of individual page names can be prevented by preceding words with the string "\%".

Given the distributed, autonomous nature of FOSS projects and their documentation, it is sometimes necessary—and in many cases desirable—that the SEE ALSO section includes references to manual pages provided by other projects.

## FORMATTING AND WORDING CONVENTIONS
The following subsections note some details for preferred formatting and wording conventions in various sections of the pages in the man-pages project.

### SYNOPSIS
Wrap the function prototype(s) in a .nf/.fi pair to prevent filling.

In general, where more than one function prototype is shown in the SYNOPSIS, the prototypes should not be separated by blank lines. However, blank lines (achieved using .PP) may be added in the following cases:

- to separate long lists of function prototypes into related groups (see for example list(3));

- in other cases that may improve readability.

In the SYNOPSIS, a long function prototype may need to be continued over to the next line. The continuation line is indented according to the following rules:

1.

If there is a single such prototype that needs to be continued, then align the continuation line so that when the page is rendered on a fixed-width font device (e.g., on an xterm) the continuation line starts just below the start of the argument list in the line above. (Exception: the indentation may be adjusted if necessary to prevent a very long continuation line or a further continuation line where the function prototype is very long.) As an example:

```
int tcsetattr(int fd, int optional_actions,
              const struct termios *termios_p);
```

2.

But, where multiple functions in the SYNOPSIS require continuation lines, and the function names have different lengths, then align all continuation lines to start in the same column. This provides a nicer rendering in PDF output (because the SYNOPSIS uses a variable width font where spaces render narrower than most characters). As an example:

```
int getopt(int argc, char * const argv[],
           const char *optstring);
int getopt_long(int argc, char * const argv[],
           const char *optstring,
           const struct option *longopts, int *longindex);
```

### RETURN VALUE
The preferred wording to describe how errno is set is "errno is set to indicate the error" or similar. This wording is consistent with the wording used in both POSIX.1 and FreeBSD.

### ATTRIBUTES
Note the following:

- Wrap the table in this section in a .ad l/.ad pair to disable text filling and a .nh/.hy pair to disable hyphenation.

- Ensure that the table occupies the full page width through the use of an lbx description for one of the columns (usually the first column, though in some cases the last column if it contains a lot of text).

- Make free use of T{/T} macro pairs to allow table cells to be broken over multiple lines (also bearing in mind that pages may sometimes be rendered to a width of less than 80 columns).

For examples of all of the above, see the source code of various pages.

## STYLE GUIDE
The following subsections describe the preferred style for the man-pages project. For details not covered below, the Chicago Manual of Style is usually a good source; try also grepping for preexisting usage in the project source tree.

### Use of gender-neutral language
As far as possible, use gender-neutral language in the text of man pages. Use of "they" ("them", "themself", "their") as a gender-neutral singular pronoun is acceptable.

### Formatting conventions for manual pages describing commands
For manual pages that describe a command (typically in Sections 1 and 8), the arguments are always specified using italics, even in the SYNOPSIS section.

The name of the command, and its options, should always be formatted in bold.

### Formatting conventions for manual pages describing functions
For manual pages that describe functions (typically in Sections 2 and 3), the arguments are always specified using italics, even in the SYNOPSIS section, where the rest of the function is specified in bold:

int myfunction(int argc, char **argv);

Variable names should, like argument names, be specified in italics.

Any reference to the subject of the current manual page should be written with the name in bold followed by a pair of parentheses in Roman (normal) font. For example, in the fcntl(2) man page, references to the subject of the page would be written as: fcntl(). The preferred way to write this in the source file is:

```
    .BR fcntl ()
```

(Using this format, rather than the use of "\fB...\fP()" makes it easier to write tools that parse man page source files.)

### Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, and long sentences should split into lines at clause breaks (commas, semicolons, colons, and so on). This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences or sentence clauses.

### Formatting conventions (general)
Paragraphs should be separated by suitable markers (usually either .PP or .IP). Do not separate paragraphs using blank lines, as this results in poor rendering in some output formats (such as PostScript and PDF).

Filenames (whether pathnames, or references to header files) are always in italics (e.g., <stdio.h>), except in the SYNOPSIS section, where included files are in bold (e.g., #include <stdio.h>). When referring to a standard header file include, specify the header file surrounded by angle brackets, in the usual C way (e.g., <stdio.h>).

Special macros, which are usually in uppercase, are in bold (e.g., MAXINT). Exception: don't boldface NULL.

When enumerating a list of error codes, the codes are in bold (this list usually uses the .TP macro).

Complete commands should, if long, be written as an indented line on their own, with a blank line before and after the command, for example

```
man 7 man-pages
```

If the command is short, then it can be included inline in the text, in italic format, for example, man 7 man-pages. In this case, it may be worth using nonbreaking spaces ("\ ") at suitable places in the command. Command options should be written in italics (e.g., -l).

Expressions, if not written on a separate indented line, should be specified in italics. Again, the use of nonbreaking spaces may be appropriate if the expression is inlined with normal text.

When showing example shell sessions, user input should be formatted in bold, for example

```
$ date
Thu Jul  7 13:01:27 CEST 2016
```

Any reference to another man page should be written with the name in bold, always followed by the section number, formatted in Roman (normal) font, without any separating spaces (e.g., intro(2)). The preferred way to write this in the source file is:

```
    .BR intro (2)
```

(Including the section number in cross references lets tools like man2html(1) create properly hyperlinked pages.)

Control characters should be written in bold face, with no quotes; for example, ^X.

### Spelling
Starting with release 2.59, man-pages follows American spelling conventions (previously, there was a random mix of British and American spellings); please write all new pages and patches according to these conventions.

Aside from the well-known spelling differences, there are a few other subtleties to watch for:

- American English tends to use the forms "backward", "upward", "toward", and so on rather than the British forms "backwards", "upwards", "towards", and so on.

- Opinions are divided on "acknowledgement" vs "acknowledgment". The latter is predominant, but not universal usage in American English. POSIX and the BSD license use the former spelling. In the Linux man-pages project, we use "acknowledgement".

### BSD version numbers
The classical scheme for writing BSD version numbers is x.yBSD, where x.y is the version number (e.g., 4.2BSD). Avoid forms such as BSD 4.3.

### Capitalization
In subsection ("SS") headings, capitalize the first word in the heading, but otherwise use lowercase, except where English usage (e.g., proper nouns) or programming language requirements (e.g., identifier names) dictate otherwise. For example:

```
    .SS Unicode under Linux
```

### Indentation of structure definitions, shell session logs, and so on
When structure definitions, shell session logs, and so on are included in running text, indent them by 4 spaces (i.e., a block enclosed by .in +4n and .in), format them using the .EX and EE macros, and surround them with suitable paragraph markers (either .PP or .IP). For example:

```
    .PP

    .in +4n

    .EX

    int

    main(int argc, char *argv[])

    {

        return 0;

    }

    .EE

    .in

    .PP
```

### Preferred terms
The following table lists some preferred terms to use in man pages, mainly to ensure consistency across pages.

Term

Avoid using

Notes

bit mask

bitmask

built-in

builtin

Epoch

epoch

For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC)

filename

file name

filesystem

file system

hostname

host name

inode

i-node

lowercase

lower case, lower-case

nonzero

non-zero

pathname

path name

pseudoterminal

pseudo-terminal

privileged port

reserved port, system port

real-time

realtime, real time

run time

runtime

saved set-group-ID

saved group ID, saved set-GID

saved set-user-ID

saved user ID, saved set-UID

set-group-ID

set-GID, setgid

set-user-ID

set-UID, setuid

superuser

super user, super-user

superblock

super block, super-block

timestamp

time stamp

timezone

time zone

uppercase

upper case, upper-case

usable

useable

user space

userspace

username

user name

x86-64

x86_64

Except if referring to result of "uname -m" or similar

zeros

zeroes

See also the discussion Hyphenation of attributive compounds below.

### Terms to avoid
The following table lists some terms to avoid using in man pages, along with some suggested alternatives, mainly to ensure consistency across pages.

Avoid

Use instead

Notes

32bit

32-bit

same for 8-bit, 16-bit, etc.

current process

calling process

A common mistake made by kernel programmers when writing man pages

manpage

man page, manual page

minus infinity

negative infinity

non-root

unprivileged user

non-superuser

unprivileged user

nonprivileged

unprivileged

OS

operating system

plus infinity

positive infinity

pty

pseudoterminal

tty

terminal

Unices

UNIX systems

Unixes

UNIX systems

### Trademarks
Use the correct spelling and case for trademarks. The following is a list of the correct spellings of various relevant trademarks that are sometimes misspelled:

DG/UX

HP-UX

UNIX

UnixWare

### NULL, NUL, null pointer, and null character
A null pointer is a pointer that points to nothing, and is normally indicated by the constant NULL. On the other hand, NUL is the null byte, a byte with the value 0, represented in C via the character constant '\0'.

The preferred term for the pointer is "null pointer" or simply "NULL"; avoid writing "NULL pointer".

The preferred term for the byte is "null byte". Avoid writing "NUL", since it is too easily confused with "NULL". Avoid also the terms "zero byte" and "null character". The byte that terminates a C string should be described as "the terminating null byte"; strings may be described as "null-terminated", but avoid the use of "NUL-terminated".

### Hyperlinks
For hyperlinks, use the .UR/.UE macro pair (see groff_man(7)). This produces proper hyperlinks that can be used in a web browser, when rendering a page with, say:

BROWSER=firefox man -H pagename

### Use of e.g., i.e., etc., a.k.a., and similar
In general, the use of abbreviations such as "e.g.", "i.e.", "etc.", "cf.", and "a.k.a." should be avoided, in favor of suitable full wordings ("for example", "that is", "and so on", "compare to", "also known as").

The only place where such abbreviations may be acceptable is in short parenthetical asides (e.g., like this one).

Always include periods in such abbreviations, as shown here. In addition, "e.g." and "i.e." should always be followed by a comma.

### Em-dashes
The way to write an em-dash—the glyph that appears at either end of this subphrase—in *roff is with the macro "\(em". (On an ASCII terminal, an em-dash typically renders as two hyphens, but in other typographical contexts it renders as a long dash.) Em-dashes should be written without surrounding spaces.

### Hyphenation of attributive compounds
Compound terms should be hyphenated when used attributively (i.e., to qualify a following noun). Some examples:

32-bit value

command-line argument

floating-point number

run-time check

user-space function

wide-character string

### Hyphenation with multi, non, pre, re, sub, and so on
The general tendency in modern English is not to hyphenate after prefixes such as "multi", "non", "pre", "re", "sub", and so on. Manual pages should generally follow this rule when these prefixes are used in natural English constructions with simple suffixes. The following list gives some examples of the preferred forms:

interprocess

multithreaded

multiprocess

nonblocking

nondefault

nonempty

noninteractive

nonnegative

nonportable

nonzero

preallocated

precreate

prerecorded

reestablished

reinitialize

rearm

reread

subcomponent

subdirectory

subsystem

Hyphens should be retained when the prefixes are used in nonstandard English words, with trademarks, proper nouns, acronyms, or compound terms. Some examples:

non-ASCII

non-English

non-NULL

non-real-time

Finally, note that "re-create" and "recreate" are two different verbs, and the former is probably what you want.

### Generating optimal glyphs
Where a real minus character is required (e.g., for numbers such as -1, for man page cross references such as utf-8(7), or when writing options that have a leading dash, such as in ls -l), use the following form in the man page source:

\-

This guideline applies also to code examples.

The use of real minus signs serves the following purposes:

- To provide better renderings on various targets other than ASCII terminals, notably in PDF and on Unicode/UTF-8-capable terminals.

- To generate glyphs that when copied from rendered pages will produce real minus signs when pasted into a terminal.

To produce unslanted single quotes that render well in ASCII, UTF-8, and PDF, use "\(aq" ("apostrophe quote"); for example

\(aqC\(aq

where C is the quoted character. This guideline applies also to character constants used in code examples.

Where a proper caret (^) that renders well in both a terminal and PDF is required, use "\(ha". This is especially necessary in code samples, to get a nicely rendered caret when rendering to PDF.

Using a naked "~" character results in a poor rendering in PDF. Instead use "\(ti". This is especially necessary in code samples, to get a nicely rendered tilde when rendering to PDF.

### Example programs and shell sessions
Manual pages may include example programs demonstrating how to use a system call or library function. However, note the following:

- Example programs should be written in C.

- An example program is necessary and useful only if it demonstrates something beyond what can easily be provided in a textual description of the interface. An example program that does nothing other than call an interface usually serves little purpose.

- Example programs should ideally be short (e.g., a good example can often be provided in less than 100 lines of code), though in some cases longer programs may be necessary to properly illustrate the use of an API.

- Expressive code is appreciated.

- Comments should included where helpful. Complete sentences in free-standing comments should be terminated by a period. Periods should generally be omitted in "tag" comments (i.e., comments that are placed on the same line of code); such comments are in any case typically brief phrases rather than complete sentences.

- Example programs should do error checking after system calls and library function calls.

- Example programs should be complete, and compile without warnings when compiled with cc -Wall.

- Where possible and appropriate, example programs should allow experimentation, by varying their behavior based on inputs (ideally from command-line arguments, or alternatively, via input read by the program).

- Example programs should be laid out according to Kernighan and Ritchie style, with 4-space indents. (Avoid the use of TAB characters in source code!) The following command can be used to format your source code to something close to the preferred style:

indent -npro -kr -i4 -ts4 -sob -l72 -ss -nut -psl prog.c

*

For consistency, all example programs should terminate using either of:

exit(EXIT_SUCCESS);

exit(EXIT_FAILURE);

Avoid using the following forms to terminate a program:

exit(0);

exit(1);

return n;

*

If there is extensive explanatory text before the program source code, mark off the source code with a subsection heading Program source, as in:

.SS Program source

Always do this if the explanatory text includes a shell session log.

If you include a shell session log demonstrating the use of a program or other system feature:

- Place the session log above the source code listing

- Indent the session log by four spaces.

- Boldface the user input text, to distinguish it from output produced by the system.

For some examples of what example programs should look like, see wait(2) and pipe(2).

## EXAMPLES
For canonical examples of how man pages in the man-pages package should look, see pipe(2) and fcntl(2).

## SEE ALSO
man(1), man2html(1), attributes(7), groff(7), groff_man(7), man(7), mdoc(7)


title: math_error(7)

text:
# math_error(7)

## NAME
math_error - detecting errors from mathematical functions

## SYNOPSIS

```
#include <math.h>
#include <errno.h>
#include <fenv.h>
```

## DESCRIPTION
When an error occurs, most library functions indicate this fact by returning a special value (e.g., -1 or NULL). Because they typically return a floating-point number, the mathematical functions declared in <math.h> indicate an error using other mechanisms. There are two error-reporting mechanisms: the older one sets errno; the newer one uses the floating-point exception mechanism (the use of feclearexcept(3) and fetestexcept(3), as outlined below) described in fenv(3).

A portable program that needs to check for an error from a mathematical function should set errno to zero, and make the following call

```
feclearexcept(FE_ALL_EXCEPT);
```

before calling a mathematical function.

Upon return from the mathematical function, if errno is nonzero, or the following call (see fenv(3)) returns nonzero

```
fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW |

             FE_UNDERFLOW);
```

then an error occurred in the mathematical function.

The error conditions that can occur for mathematical functions are described below.

### Domain error
A domain error occurs when a mathematical function is supplied with an argument whose value falls outside the domain for which the function is defined (e.g., giving a negative argument to log(3)). When a domain error occurs, math functions commonly return a NaN (though some functions return a different value in this case); errno is set to EDOM, and an "invalid" (FE_INVALID) floating-point exception is raised.

### Pole error
A pole error occurs when the mathematical result of a function is an exact infinity (e.g., the logarithm of 0 is negative infinity). When a pole error occurs, the function returns the (signed) value HUGE_VAL, HUGE_VALF, or HUGE_VALL, depending on whether the function result type is double, float, or long double. The sign of the result is that which is mathematically correct for the function. errno is set to ERANGE, and a "divide-by-zero" (FE_DIVBYZERO) floating-point exception is raised.

### Range error
A range error occurs when the magnitude of the function result means that it cannot be represented in the result type of the function. The return value of the function depends on whether the range error was an overflow or an underflow.

A floating result overflows if the result is finite, but is too large to represented in the result type. When an overflow occurs, the function returns the value HUGE_VAL, HUGE_VALF, or HUGE_VALL, depending on whether the function result type is double, float, or long double. errno is set to ERANGE, and an "overflow" (FE_OVERFLOW) floating-point exception is raised.

A floating result underflows if the result is too small to be represented in the result type. If an underflow occurs, a mathematical function typically returns 0.0 (C99 says a function shall return "an implementation-defined value whose magnitude is no greater than the smallest normalized positive number in the specified type"). errno may be set to ERANGE, and an "underflow" (FE_UNDERFLOW) floating-point exception may be raised.

Some functions deliver a range error if the supplied argument value, or the correct function result, would be subnormal. A subnormal value is one that is nonzero, but with a magnitude that is so small that it can't be presented in normalized form (i.e., with a 1 in the most significant bit of the significand). The representation of a subnormal number will contain one or more leading zeros in the significand.

## NOTES
The math_errhandling identifier specified by C99 and POSIX.1 is not supported by glibc. This identifier is supposed to indicate which of the two error-notification mechanisms (errno, exceptions retrievable via fetestexcept(3)) is in use. The standards require that at least one be in use, but permit both to be available. The current (version 2.8) situation under glibc is messy. Most (but not all) functions raise exceptions on errors. Some also set errno. A few functions set errno, but don't raise an exception. A very few functions do neither. See the individual manual pages for details.

To avoid the complexities of using errno and fetestexcept(3) for error checking, it is often advised that one should instead check for bad argument values before each call. For example, the following code ensures that log(3)'s argument is not a NaN and is not zero (a pole error) or less than zero (a domain error):

```
double x, r;
if (isnan(x) || islessequal(x, 0)) {

    /* Deal with NaN / pole error / domain error */
}
r = log(x);
```

The discussion on this page does not apply to the complex mathematical functions (i.e., those declared by <complex.h>), which in general are not required to return errors by C99 and POSIX.1.

The gcc(1) -fno-math-errno option causes the executable to employ implementations of some mathematical functions that are faster than the standard implementations, but do not set errno on error. (The gcc(1) -ffast-math option also enables -fno-math-errno.) An error can still be tested for using fetestexcept(3).

## SEE ALSO
gcc(1), errno(3), fenv(3), fpclassify(3), INFINITY(3), isgreater(3), matherr(3), nan(3)

info libc


title: mount_namespaces(7)

summary: overview of Linux mount namespaces

text:
# mount_namespaces(7)

## NAME
mount_namespaces - overview of Linux mount namespaces

## DESCRIPTION
For an overview of namespaces, see namespaces(7).

Mount namespaces provide isolation of the list of mount points seen by the processes in each namespace instance. Thus, the processes in each of the mount namespace instances will see distinct single-directory hierarchies.

The views provided by the /proc/[pid]/mounts, /proc/[pid]/mountinfo, and /proc/[pid]/mountstats files (all described in proc(5)) correspond to the mount namespace in which the process with the PID [pid] resides. (All of the processes that reside in the same mount namespace will see the same view in these files.)

A new mount namespace is created using either clone(2) or unshare(2) with the CLONE_NEWNS flag. When a new mount namespace is created, its mount point list is initialized as follows:

- If the namespace is created using clone(2), the mount point list of the child's namespace is a copy of the mount point list in the parent's namespace.

- If the namespace is created using unshare(2), the mount point list of the new namespace is a copy of the mount point list in the caller's previous mount namespace.

Subsequent modifications to the mount point list (mount(2) and umount(2)) in either mount namespace will not (by default) affect the mount point list seen in the other namespace (but see the following discussion of shared subtrees).

### Restrictions on mount namespaces
Note the following points with respect to mount namespaces:

- Each mount namespace has an owner user namespace. As explained above, when a new mount namespace is created, its mount point list is initialized as a copy of the mount point list of another mount namespace. If the new namespace and the namespace from which the mount point list was copied are owned by different user namespaces, then the new mount namespace is considered less privileged.

- When creating a less privileged mount namespace, shared mounts are reduced to slave mounts. (Shared and slave mounts are discussed below.) This ensures that mappings performed in less privileged mount namespaces will not propagate to more privileged mount namespaces.

- Mounts that come as a single unit from a more privileged mount namespace are locked together and may not be separated in a less privileged mount namespace. (The unshare(2) CLONE_NEWNS operation brings across all of the mounts from the original mount namespace as a single unit, and recursive mounts that propagate between mount namespaces propagate as a single unit.)

- The mount(2) flags MS_RDONLY, MS_NOSUID, MS_NOEXEC, and the "atime" flags (MS_NOATIME, MS_NODIRATIME, MS_RELATIME) settings become locked when propagated from a more privileged to a less privileged mount namespace, and may not be changed in the less privileged mount namespace.

- A file or directory that is a mount point in one namespace that is not a mount point in another namespace, may be renamed, unlinked, or removed (rmdir(2)) in the mount namespace in which it is not a mount point (subject to the usual permission checks). Consequently, the mount point is removed in the mount namespace where it was a mount point.

Previously (before Linux 3.18), attempting to unlink, rename, or remove a file or directory that was a mount point in another mount namespace would result in the error EBUSY. That behavior had technical problems of enforcement (e.g., for NFS) and permitted denial-of-service attacks against more privileged users. (i.e., preventing individual files from being updated by bind mounting on top of them).

## SHARED SUBTREES
After the implementation of mount namespaces was completed, experience showed that the isolation that they provided was, in some cases, too great. For example, in order to make a newly loaded optical disk available in all mount namespaces, a mount operation was required in each namespace. For this use case, and others, the shared subtree feature was introduced in Linux 2.6.15. This feature allows for automatic, controlled propagation of mount and unmount events between namespaces (or, more precisely, between the members of a peer group that are propagating events to one another).

Each mount point is marked (via mount(2)) as having one of the following propagation types:

MS_SHARED

This mount point shares events with members of a peer group. Mount and unmount events immediately under this mount point will propagate to the other mount points that are members of the peer group. Propagation here means that the same mount or unmount will automatically occur under all of the other mount points in the peer group. Conversely, mount and unmount events that take place under peer mount points will propagate to this mount point.

MS_PRIVATE

This mount point is private; it does not have a peer group. Mount and unmount events do not propagate into or out of this mount point.

MS_SLAVE

Mount and unmount events propagate into this mount point from a (master) shared peer group. Mount and unmount events under this mount point do not propagate to any peer.

Note that a mount point can be the slave of another peer group while at the same time sharing mount and unmount events with a peer group of which it is a member. (More precisely, one peer group can be the slave of another peer group.)

MS_UNBINDABLE

This is like a private mount, and in addition this mount can't be bind mounted. Attempts to bind mount this mount (mount(2) with the MS_BIND flag) will fail.

When a recursive bind mount (mount(2) with the MS_BIND and MS_REC flags) is performed on a directory subtree, any bind mounts within the subtree are automatically pruned (i.e., not replicated) when replicating that subtree to produce the target subtree.

For a discussion of the propagation type assigned to a new mount, see NOTES.

The propagation type is a per-mount-point setting; some mount points may be marked as shared (with each shared mount point being a member of a distinct peer group), while others are private (or slaved or unbindable).

Note that a mount's propagation type determines whether mounts and unmounts of mount points immediately under the mount point are propagated. Thus, the propagation type does not affect propagation of events for grandchildren and further removed descendant mount points. What happens if the mount point itself is unmounted is determined by the propagation type that is in effect for the parent of the mount point.

Members are added to a peer group when a mount point is marked as shared and either:

- the mount point is replicated during the creation of a new mount namespace; or

- a new bind mount is created from the mount point.

In both of these cases, the new mount point joins the peer group of which the existing mount point is a member.

A new peer group is also created when a child mount point is created under an existing mount point that is marked as shared. In this case, the new child mount point is also marked as shared and the resulting peer group consists of all the mount points that are replicated under the peers of parent mount.

A mount ceases to be a member of a peer group when either the mount is explicitly unmounted, or when the mount is implicitly unmounted because a mount namespace is removed (because it has no more member processes).

The propagation type of the mount points in a mount namespace can be discovered via the "optional fields" exposed in /proc/[pid]/mountinfo. (See proc(5) for details of this file.) The following tags can appear in the optional fields for a record in that file:

shared:X

This mount point is shared in peer group X. Each peer group has a unique ID that is automatically generated by the kernel, and all mount points in the same peer group will show the same ID. (These IDs are assigned starting from the value 1, and may be recycled when a peer group ceases to have any members.)

master:X

This mount is a slave to shared peer group X.

propagate_from:X (since Linux 2.6.26)

This mount is a slave and receives propagation from shared peer group X. This tag will always appear in conjunction with a master:X tag. Here, X is the closest dominant peer group under the process's root directory. If X is the immediate master of the mount, or if there is no dominant peer group under the same root, then only the master:X field is present and not the propagate_from:X field. For further details, see below.

unbindable

This is an unbindable mount.

If none of the above tags is present, then this is a private mount.

### MS_SHARED and MS_PRIVATE example
Suppose that on a terminal in the initial mount namespace, we mark one mount point as shared and another as private, and then view the mounts in /proc/self/mountinfo:

```
sh1# mount --make-shared /mntS
sh1# mount --make-private /mntP
sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
77 61 8:17 / /mntS rw,relatime shared:1
83 61 8:15 / /mntP rw,relatime
```

From the /proc/self/mountinfo output, we see that /mntS is a shared mount in peer group 1, and that /mntP has no optional tags, indicating that it is a private mount. The first two fields in each record in this file are the unique ID for this mount, and the mount ID of the parent mount. We can further inspect this file to see that the parent mount point of /mntS and /mntP is the root directory, /, which is mounted as private:

```
sh1# cat /proc/self/mountinfo | awk '$1 == 61' | sed 's/ - .*//'
61 0 8:2 / / rw,relatime
```

On a second terminal, we create a new mount namespace where we run a second shell and inspect the mounts:

```
$ PS1='sh2# ' sudo unshare -m --propagation unchanged sh
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
222 145 8:17 / /mntS rw,relatime shared:1
225 145 8:15 / /mntP rw,relatime
```

The new mount namespace received a copy of the initial mount namespace's mount points. These new mount points maintain the same propagation types, but have unique mount IDs. (The --propagation unchanged option prevents unshare(1) from marking all mounts as private when creating a new mount namespace, which it does by default.)

In the second terminal, we then create submounts under each of /mntS and /mntP and inspect the set-up:

```
sh2# mkdir /mntS/a
sh2# mount /dev/sdb6 /mntS/a
sh2# mkdir /mntP/b
sh2# mount /dev/sdb7 /mntP/b
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
222 145 8:17 / /mntS rw,relatime shared:1
225 145 8:15 / /mntP rw,relatime
178 222 8:22 / /mntS/a rw,relatime shared:2
230 225 8:23 / /mntP/b rw,relatime
```

From the above, it can be seen that /mntS/a was created as shared (inheriting this setting from its parent mount) and /mntP/b was created as a private mount.

Returning to the first terminal and inspecting the set-up, we see that the new mount created under the shared mount point /mntS propagated to its peer mount (in the initial mount namespace), but the new mount created under the private mount point /mntP did not propagate:

```
sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
77 61 8:17 / /mntS rw,relatime shared:1
83 61 8:15 / /mntP rw,relatime
179 77 8:22 / /mntS/a rw,relatime shared:2
```

### MS_SLAVE example
Making a mount point a slave allows it to receive propagated mount and unmount events from a master shared peer group, while preventing it from propagating events to that master. This is useful if we want to (say) receive a mount event when an optical disk is mounted in the master shared peer group (in another mount namespace), but want to prevent mount and unmount events under the slave mount from having side effects in other namespaces.

We can demonstrate the effect of slaving by first marking two mount points as shared in the initial mount namespace:

```
sh1# mount --make-shared /mntX
sh1# mount --make-shared /mntY
sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
132 83 8:23 / /mntX rw,relatime shared:1
133 83 8:22 / /mntY rw,relatime shared:2
```

On a second terminal, we create a new mount namespace and inspect the mount points:

```
sh2# unshare -m --propagation unchanged sh
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
168 167 8:23 / /mntX rw,relatime shared:1
169 167 8:22 / /mntY rw,relatime shared:2
```

In the new mount namespace, we then mark one of the mount points as a slave:

```
sh2# mount --make-slave /mntY
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
168 167 8:23 / /mntX rw,relatime shared:1
169 167 8:22 / /mntY rw,relatime master:2
```

From the above output, we see that /mntY is now a slave mount that is receiving propagation events from the shared peer group with the ID 2.

Continuing in the new namespace, we create submounts under each of /mntX and /mntY:

```
sh2# mkdir /mntX/a
sh2# mount /dev/sda3 /mntX/a
sh2# mkdir /mntY/b
sh2# mount /dev/sda5 /mntY/b
```

When we inspect the state of the mount points in the new mount namespace, we see that /mntX/a was created as a new shared mount (inheriting the "shared" setting from its parent mount) and /mntY/b was created as a private mount:

```
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
168 167 8:23 / /mntX rw,relatime shared:1
169 167 8:22 / /mntY rw,relatime master:2
173 168 8:3 / /mntX/a rw,relatime shared:3
175 169 8:5 / /mntY/b rw,relatime
```

Returning to the first terminal (in the initial mount namespace), we see that the mount /mntX/a propagated to the peer (the shared /mntX), but the mount /mntY/b was not propagated:

```
sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
132 83 8:23 / /mntX rw,relatime shared:1
133 83 8:22 / /mntY rw,relatime shared:2
174 132 8:3 / /mntX/a rw,relatime shared:3
```

Now we create a new mount point under /mntY in the first shell:

```
sh1# mkdir /mntY/c
sh1# mount /dev/sda1 /mntY/c
sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
132 83 8:23 / /mntX rw,relatime shared:1
133 83 8:22 / /mntY rw,relatime shared:2
174 132 8:3 / /mntX/a rw,relatime shared:3
178 133 8:1 / /mntY/c rw,relatime shared:4
```

When we examine the mount points in the second mount namespace, we see that in this case the new mount has been propagated to the slave mount point, and that the new mount is itself a slave mount (to peer group 4):

```
sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
168 167 8:23 / /mntX rw,relatime shared:1
169 167 8:22 / /mntY rw,relatime master:2
173 168 8:3 / /mntX/a rw,relatime shared:3
175 169 8:5 / /mntY/b rw,relatime
179 169 8:1 / /mntY/c rw,relatime master:4
```

### MS_UNBINDABLE example
One of the primary purposes of unbindable mounts is to avoid the "mount point explosion" problem when repeatedly performing bind mounts of a higher-level subtree at a lower-level mount point. The problem is illustrated by the following shell session.

Suppose we have a system with the following mount points:

```
# mount | awk '{print $1, $2, $3}'
/dev/sda1 on /
/dev/sdb6 on /mntX
/dev/sdb7 on /mntY
```

Suppose furthermore that we wish to recursively bind mount the root directory under several users' home directories. We do this for the first user, and inspect the mount points:

```
# mount --rbind / /home/cecilia/
# mount | awk '{print $1, $2, $3}'
/dev/sda1 on /
/dev/sdb6 on /mntX
/dev/sdb7 on /mntY
/dev/sda1 on /home/cecilia
/dev/sdb6 on /home/cecilia/mntX
/dev/sdb7 on /home/cecilia/mntY
```

When we repeat this operation for the second user, we start to see the explosion problem:

```
# mount --rbind / /home/henry
# mount | awk '{print $1, $2, $3}'
/dev/sda1 on /
/dev/sdb6 on /mntX
/dev/sdb7 on /mntY
/dev/sda1 on /home/cecilia
/dev/sdb6 on /home/cecilia/mntX
/dev/sdb7 on /home/cecilia/mntY
/dev/sda1 on /home/henry
/dev/sdb6 on /home/henry/mntX
/dev/sdb7 on /home/henry/mntY
/dev/sda1 on /home/henry/home/cecilia
/dev/sdb6 on /home/henry/home/cecilia/mntX
/dev/sdb7 on /home/henry/home/cecilia/mntY
```

Under /home/henry, we have not only recursively added the /mntX and /mntY mounts, but also the recursive mounts of those directories under /home/cecilia that were created in the previous step. Upon repeating the step for a third user, it becomes obvious that the explosion is exponential in nature:

```
# mount --rbind / /home/otto
# mount | awk '{print $1, $2, $3}'
/dev/sda1 on /
/dev/sdb6 on /mntX
/dev/sdb7 on /mntY
/dev/sda1 on /home/cecilia
/dev/sdb6 on /home/cecilia/mntX
/dev/sdb7 on /home/cecilia/mntY
/dev/sda1 on /home/henry
/dev/sdb6 on /home/henry/mntX
/dev/sdb7 on /home/henry/mntY
/dev/sda1 on /home/henry/home/cecilia
/dev/sdb6 on /home/henry/home/cecilia/mntX
/dev/sdb7 on /home/henry/home/cecilia/mntY
/dev/sda1 on /home/otto
/dev/sdb6 on /home/otto/mntX
/dev/sdb7 on /home/otto/mntY
/dev/sda1 on /home/otto/home/cecilia
/dev/sdb6 on /home/otto/home/cecilia/mntX
/dev/sdb7 on /home/otto/home/cecilia/mntY
/dev/sda1 on /home/otto/home/henry
/dev/sdb6 on /home/otto/home/henry/mntX
/dev/sdb7 on /home/otto/home/henry/mntY
/dev/sda1 on /home/otto/home/henry/home/cecilia
/dev/sdb6 on /home/otto/home/henry/home/cecilia/mntX
/dev/sdb7 on /home/otto/home/henry/home/cecilia/mntY
```

The mount explosion problem in the above scenario can be avoided by making each of the new mounts unbindable. The effect of doing this is that recursive mounts of the root directory will not replicate the unbindable mounts. We make such a mount for the first user:

```
# mount --rbind --make-unbindable / /home/cecilia
```

Before going further, we show that unbindable mounts are indeed unbindable:

```
# mkdir /mntZ
# mount --bind /home/cecilia /mntZ
mount: wrong fs type, bad option, bad superblock on /home/cecilia,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail or so.
```

Now we create unbindable recursive bind mounts for the other two users:

```
# mount --rbind --make-unbindable / /home/henry
# mount --rbind --make-unbindable / /home/otto
```

Upon examining the list of mount points, we see there has been no explosion of mount points, because the unbindable mounts were not replicated under each user's directory:

```
# mount | awk '{print $1, $2, $3}'
/dev/sda1 on /
/dev/sdb6 on /mntX
/dev/sdb7 on /mntY
/dev/sda1 on /home/cecilia
/dev/sdb6 on /home/cecilia/mntX
/dev/sdb7 on /home/cecilia/mntY
/dev/sda1 on /home/henry
/dev/sdb6 on /home/henry/mntX
/dev/sdb7 on /home/henry/mntY
/dev/sda1 on /home/otto
/dev/sdb6 on /home/otto/mntX
/dev/sdb7 on /home/otto/mntY
```

### Propagation type transitions
The following table shows the effect that applying a new propagation type (i.e., mount --make-xxxx) has on the existing propagation type of a mount point. The rows correspond to existing propagation types, and the columns are the new propagation settings. For reasons of space, "private" is abbreviated as "priv" and "unbindable" as "unbind".

make-shared

make-slave

make-priv

make-unbind

shared

shared

slave/priv [1]

priv

unbind

slave

slave+shared

slave [2]

priv

unbind

slave+shared

slave+shared

slave

priv

unbind

private

shared

priv [2]

priv

unbind

unbindable

shared

unbind [2]

priv

unbind

Note the following details to the table:

[1]

If a shared mount is the only mount in its peer group, making it a slave automatically makes it private.

[2]

Slaving a nonshared mount has no effect on the mount.

### Bind (MS_BIND) semantics
Suppose that the following command is performed:

```
mount --bind A/a B/b
```

Here, A is the source mount point, B is the destination mount point, a is a subdirectory path under the mount point A, and b is a subdirectory path under the mount point B. The propagation type of the resulting mount, B/b, depends on the propagation types of the mount points A and B, and is summarized in the following table.

source(A)

shared

private

slave

unbind

dest(B)

shared

shared

shared

slave+shared

invalid

nonshared

shared

private

slave

invalid

Note that a recursive bind of a subtree follows the same semantics as for a bind operation on each mount in the subtree. (Unbindable mounts are automatically pruned at the target mount point.)

For further details, see Documentation/filesystems/sharedsubtree.txt in the kernel source tree.

### Move (MS_MOVE) semantics
Suppose that the following command is performed:

```
mount --move A B/b
```

Here, A is the source mount point, B is the destination mount point, and b is a subdirectory path under the mount point B. The propagation type of the resulting mount, B/b, depends on the propagation types of the mount points A and B, and is summarized in the following table.

source(A)

shared

private

slave

unbind

dest(B)

shared

shared

shared

slave+shared

invalid

nonshared

shared

private

slave

unbindable

Note: moving a mount that resides under a shared mount is invalid.

For further details, see Documentation/filesystems/sharedsubtree.txt in the kernel source tree.

### Mount semantics
Suppose that we use the following command to create a mount point:

```
mount device B/b
```

Here, B is the destination mount point, and b is a subdirectory path under the mount point B. The propagation type of the resulting mount, B/b, follows the same rules as for a bind mount, where the propagation type of the source mount is considered always to be private.

### Unmount semantics
Suppose that we use the following command to tear down a mount point:

```
unmount A
```

Here, A is a mount point on B/b, where B is the parent mount and b is a subdirectory path under the mount point B. If B is shared, then all most-recently-mounted mounts at b on mounts that receive propagation from mount B and do not have submounts under them are unmounted.

### The /proc/[pid]/mountinfo propagate_from tag
The propagate_from:X tag is shown in the optional fields of a /proc/[pid]/mountinfo record in cases where a process can't see a slave's immediate master (i.e., the pathname of the master is not reachable from the filesystem root directory) and so cannot determine the chain of propagation between the mounts it can see.

In the following example, we first create a two-link master-slave chain between the mounts /mnt, /tmp/etc, and /mnt/tmp/etc. Then the chroot(1) command is used to make the /tmp/etc mount point unreachable from the root directory, creating a situation where the master of /mnt/tmp/etc is not reachable from the (new) root directory of the process.

First, we bind mount the root directory onto /mnt and then bind mount /proc at /mnt/proc so that after the later chroot(1) the proc(5) filesystem remains visible at the correct location in the chroot-ed environment.

```
# mkdir -p /mnt/proc
# mount --bind / /mnt
# mount --bind /proc /mnt/proc
```

Next, we ensure that the /mnt mount is a shared mount in a new peer group (with no peers):

```
# mount --make-private /mnt  # Isolate from any previous peer group
# mount --make-shared /mnt
# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//'
239 61 8:2 / /mnt ... shared:102
248 239 0:4 / /mnt/proc ... shared:5
```

Next, we bind mount /mnt/etc onto /tmp/etc:

```
# mkdir -p /tmp/etc
# mount --bind /mnt/etc /tmp/etc
# cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//'
239 61 8:2 / /mnt ... shared:102
248 239 0:4 / /mnt/proc ... shared:5
267 40 8:2 /etc /tmp/etc ... shared:102
```

Initially, these two mount points are in the same peer group, but we then make the /tmp/etc a slave of /mnt/etc, and then make /tmp/etc shared as well, so that it can propagate events to the next slave in the chain:

```
# mount --make-slave /tmp/etc
# mount --make-shared /tmp/etc
# cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//'
239 61 8:2 / /mnt ... shared:102
248 239 0:4 / /mnt/proc ... shared:5
267 40 8:2 /etc /tmp/etc ... shared:105 master:102
```

Then we bind mount /tmp/etc onto /mnt/tmp/etc. Again, the two mount points are initially in the same peer group, but we then make /mnt/tmp/etc a slave of /tmp/etc:

```
# mkdir -p /mnt/tmp/etc
# mount --bind /tmp/etc /mnt/tmp/etc
# mount --make-slave /mnt/tmp/etc
# cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//'
239 61 8:2 / /mnt ... shared:102
248 239 0:4 / /mnt/proc ... shared:5
267 40 8:2 /etc /tmp/etc ... shared:105 master:102
273 239 8:2 /etc /mnt/tmp/etc ... master:105
```

From the above, we see that /mnt is the master of the slave /tmp/etc, which in turn is the master of the slave /mnt/tmp/etc.

We then chroot(1) to the /mnt directory, which renders the mount with ID 267 unreachable from the (new) root directory:

```
# chroot /mnt
```

When we examine the state of the mounts inside the chroot-ed environment, we see the following:

```
# cat /proc/self/mountinfo | sed 's/ - .*//'
239 61 8:2 / / ... shared:102
248 239 0:4 / /proc ... shared:5
273 239 8:2 /etc /tmp/etc ... master:105 propagate_from:102
```

Above, we see that the mount with ID 273 is a slave whose master is the peer group 105. The mount point for that master is unreachable, and so a propagate_from tag is displayed, indicating that the closest dominant peer group (i.e., the nearest reachable mount in the slave chain) is the peer group with the ID 102 (corresponding to the /mnt mount point before the chroot(1) was performed.

## VERSIONS
Mount namespaces first appeared in Linux 2.4.19.

## CONFORMING TO
Namespaces are a Linux-specific feature.

## NOTES
The propagation type assigned to a new mount point depends on the propagation type of the parent mount. If the mount point has a parent (i.e., it is a non-root mount point) and the propagation type of the parent is MS_SHARED, then the propagation type of the new mount is also MS_SHARED. Otherwise, the propagation type of the new mount is MS_PRIVATE.

Notwithstanding the fact that the default propagation type for new mount points is in many cases MS_PRIVATE, MS_SHARED is typically more useful. For this reason, systemd(1) automatically remounts all mount points as MS_SHARED on system startup. Thus, on most modern systems, the default propagation type is in practice MS_SHARED.

Since, when one uses unshare(1) to create a mount namespace, the goal is commonly to provide full isolation of the mount points in the new namespace, unshare(1) (since util-linux version 2.27) in turn reverses the step performed by systemd(1), by making all mount points private in the new namespace. That is, unshare(1) performs the equivalent of the following in the new mount namespace:

```
mount --make-rprivate /
```

To prevent this, one can use the --propagation unchanged option to unshare(1).

An application that creates a new mount namespace directly using clone(2) or unshare(2) may desire to prevent propagation of mount events to other mount namespaces (as is done by unshare(1)). This can be done by changing the propagation type of mount points in the new namespace to either MS_SLAVE or MS_PRIVATE, using a call such as the following:

```
mount(NULL, "/", MS_SLAVE | MS_REC, NULL);
```

For a discussion of propagation types when moving mounts (MS_MOVE) and creating bind mounts (MS_BIND), see Documentation/filesystems/sharedsubtree.txt.

## EXAMPLES
See pivot_root(2).

## SEE ALSO
unshare(1), clone(2), mount(2), pivot_root(2), setns(2), umount(2), unshare(2), proc(5), namespaces(7), user_namespaces(7), findmnt(8), mount(8), pam_namespace(8), pivot_root(8), umount(8)

Documentation/filesystems/sharedsubtree.txt in the kernel source tree.