title: koi8-r(7)

text:
# koi8-r(7)

## NAME
koi8-r - Russian character set encoded in octal, decimal, and hexadecimal

## DESCRIPTION
RFC 1489 defines an 8-bit character set, KOI8-R. KOI8-R encodes the characters used in Russian.

### KOI8-R characters
The following table displays the characters in KOI8-R 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

╓

BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE

245

165

A5

╔

BOX DRAWINGS DOUBLE DOWN AND RIGHT

246

166

A6

╕

BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE

247

167

A7

╖

BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE

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

╜

BOX DRAWINGS UP DOUBLE AND LEFT SINGLE

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

╢

BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE

265

181

B5

╣

BOX DRAWINGS DOUBLE VERTICAL AND LEFT

266

182

B6

╤

BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE

267

183

B7

╥

BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE

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

╫

BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE

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 with KOI8-U 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-u(7), utf-8(7)


package: man-pages

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)


landlock

title: landlock(7)

summary: unprivileged access-control

text:
# landlock(7)

## NAME
Landlock - unprivileged access-control

## DESCRIPTION
Landlock is an access-control system that enables any processes to securely restrict themselves and their future children. Because Landlock is a stackable Linux Security Module (LSM), it makes it possible to create safe security sandboxes as new security layers in addition to the existing system-wide access-controls. This kind of sandbox is expected to help mitigate the security impact of bugs, and unexpected or malicious behaviors in applications.

A Landlock security policy is a set of access rights (e.g., open a file in read-only, make a directory, etc.) tied to a file hierarchy. Such policy can be configured and enforced by processes for themselves using three system calls:

•

landlock_create_ruleset(2) creates a new ruleset;

•

landlock_add_rule(2) adds a new rule to a ruleset;

•

landlock_restrict_self(2) enforces a ruleset on the calling thread.

To be able to use these system calls, the running kernel must support Landlock and it must be enabled at boot time.

### Landlock rules
A Landlock rule describes an action on an object. An object is currently a file hierarchy, and the related filesystem actions are defined with access rights (see landlock_add_rule(2)). A set of rules is aggregated in a ruleset, which can then restrict the thread enforcing it, and its future children.

### Filesystem actions
These flags enable to restrict a sandboxed process to a set of actions on files and directories. Files or directories opened before the sandboxing are not subject to these restrictions. See landlock_add_rule(2) and landlock_create_ruleset(2) for more context.

A file can only receive these access rights:

LANDLOCK_ACCESS_FS_EXECUTE

Execute a file.

LANDLOCK_ACCESS_FS_WRITE_FILE

Open a file with write access.

When opening files for writing, you will often additionally need the LANDLOCK_ACCESS_FS_TRUNCATE right. In many cases, these system calls truncate existing files when overwriting them (e.g., creat(2)).

LANDLOCK_ACCESS_FS_READ_FILE

Open a file with read access.

LANDLOCK_ACCESS_FS_TRUNCATE

Truncate a file with truncate(2), ftruncate(2), creat(2), or open(2) with O_TRUNC. Whether an opened file can be truncated with ftruncate(2) is determined during open(2), in the same way as read and write permissions are checked during open(2) using LANDLOCK_ACCESS_FS_READ_FILE and LANDLOCK_ACCESS_FS_WRITE_FILE. This access right is available since the third version of the Landlock ABI.

A directory can receive access rights related to files or directories. The following access right is applied to the directory itself, and the directories beneath it:

LANDLOCK_ACCESS_FS_READ_DIR

Open a directory or list its content.

However, the following access rights only apply to the content of a directory, not the directory itself:

LANDLOCK_ACCESS_FS_REMOVE_DIR

Remove an empty directory or rename one.

LANDLOCK_ACCESS_FS_REMOVE_FILE

Unlink (or rename) a file.

LANDLOCK_ACCESS_FS_MAKE_CHAR

Create (or rename or link) a character device.

LANDLOCK_ACCESS_FS_MAKE_DIR

Create (or rename) a directory.

LANDLOCK_ACCESS_FS_MAKE_REG

Create (or rename or link) a regular file.

LANDLOCK_ACCESS_FS_MAKE_SOCK

Create (or rename or link) a UNIX domain socket.

LANDLOCK_ACCESS_FS_MAKE_FIFO

Create (or rename or link) a named pipe.

LANDLOCK_ACCESS_FS_MAKE_BLOCK

Create (or rename or link) a block device.

LANDLOCK_ACCESS_FS_MAKE_SYM

Create (or rename or link) a symbolic link.

LANDLOCK_ACCESS_FS_REFER

Link or rename a file from or to a different directory (i.e., reparent a file hierarchy).

This access right is available since the second version of the Landlock ABI.

This is the only access right which is denied by default by any ruleset, even if the right is not specified as handled at ruleset creation time. The only way to make a ruleset grant this right is to explicitly allow it for a specific directory by adding a matching rule to the ruleset.

In particular, when using the first Landlock ABI version, Landlock will always deny attempts to reparent files between different directories.

In addition to the source and destination directories having the LANDLOCK_ACCESS_FS_REFER access right, the attempted link or rename operation must meet the following constraints:

•

The reparented file may not gain more access rights in the destination directory than it previously had in the source directory. If this is attempted, the operation results in an EXDEV error.

•

When linking or renaming, the LANDLOCK_ACCESS_FS_MAKE_* right for the respective file type must be granted for the destination directory. Otherwise, the operation results in an EACCES error.

•

When renaming, the LANDLOCK_ACCESS_FS_REMOVE_* right for the respective file type must be granted for the source directory. Otherwise, the operation results in an EACCES error.

If multiple requirements are not met, the EACCES error code takes precedence over EXDEV.

### Layers of file path access rights
Each time a thread enforces a ruleset on itself, it updates its Landlock domain with a new layer of policy. Indeed, this complementary policy is composed with the potentially other rulesets already restricting this thread. A sandboxed thread can then safely add more constraints to itself with a new enforced ruleset.

One policy layer grants access to a file path if at least one of its rules encountered on the path grants the access. A sandboxed thread can only access a file path if all its enforced policy layers grant the access as well as all the other system access controls (e.g., filesystem DAC, other LSM policies, etc.).

### Bind mounts and OverlayFS
Landlock enables restricting access to file hierarchies, which means that these access rights can be propagated with bind mounts (cf. mount_namespaces(7)) but not with OverlayFS.

A bind mount mirrors a source file hierarchy to a destination. The destination hierarchy is then composed of the exact same files, on which Landlock rules can be tied, either via the source or the destination path. These rules restrict access when they are encountered on a path, which means that they can restrict access to multiple file hierarchies at the same time, whether these hierarchies are the result of bind mounts or not.

An OverlayFS mount point consists of upper and lower layers. These layers are combined in a merge directory, result of the mount point. This merge hierarchy may include files from the upper and lower layers, but modifications performed on the merge hierarchy only reflect on the upper layer. From a Landlock policy point of view, each of the OverlayFS layers and merge hierarchies is standalone and contains its own set of files and directories, which is different from a bind mount. A policy restricting an OverlayFS layer will not restrict the resulted merged hierarchy, and vice versa. Landlock users should then only think about file hierarchies they want to allow access to, regardless of the underlying filesystem.

### Inheritance
Every new thread resulting from a clone(2) inherits Landlock domain restrictions from its parent. This is similar to the seccomp(2) inheritance or any other LSM dealing with tasks' credentials(7). For instance, one process's thread may apply Landlock rules to itself, but they will not be automatically applied to other sibling threads (unlike POSIX thread credential changes, cf. nptl(7)).

When a thread sandboxes itself, we have the guarantee that the related security policy will stay enforced on all this thread's descendants. This allows creating standalone and modular security policies per application, which will automatically be composed between themselves according to their run-time parent policies.

### Ptrace restrictions
A sandboxed process has less privileges than a non-sandboxed process and must then be subject to additional restrictions when manipulating another process. To be allowed to use ptrace(2) and related syscalls on a target process, a sandboxed process should have a subset of the target process rules, which means the tracee must be in a sub-domain of the tracer.

### Truncating files
The operations covered by LANDLOCK_ACCESS_FS_WRITE_FILE and LANDLOCK_ACCESS_FS_TRUNCATE both change the contents of a file and sometimes overlap in non-intuitive ways. It is recommended to always specify both of these together.

A particularly surprising example is creat(2). The name suggests that this system call requires the rights to create and write files. However, it also requires the truncate right if an existing file under the same name is already present.

It should also be noted that truncating files does not require the LANDLOCK_ACCESS_FS_WRITE_FILE right. Apart from the truncate(2) system call, this can also be done through open(2) with the flags O_RDONLY | O_TRUNC.

When opening a file, the availability of the LANDLOCK_ACCESS_FS_TRUNCATE right is associated with the newly created file descriptor and will be used for subsequent truncation attempts using ftruncate(2). The behavior is similar to opening a file for reading or writing, where permissions are checked during open(2), but not during the subsequent read(2) and write(2) calls.

As a consequence, it is possible to have multiple open file descriptors for the same file, where one grants the right to truncate the file and the other does not. It is also possible to pass such file descriptors between processes, keeping their Landlock properties, even when these processes do not have an enforced Landlock ruleset.

## VERSIONS
Landlock was introduced in Linux 5.13.

To determine which Landlock features are available, users should query the Landlock ABI version:

ABI

Kernel

Newly introduced access rights

1

5.13

LANDLOCK_ACCESS_FS_EXECUTE

LANDLOCK_ACCESS_FS_WRITE_FILE

LANDLOCK_ACCESS_FS_READ_FILE

LANDLOCK_ACCESS_FS_READ_DIR

LANDLOCK_ACCESS_FS_REMOVE_DIR

LANDLOCK_ACCESS_FS_REMOVE_FILE

LANDLOCK_ACCESS_FS_MAKE_CHAR

LANDLOCK_ACCESS_FS_MAKE_DIR

LANDLOCK_ACCESS_FS_MAKE_REG

LANDLOCK_ACCESS_FS_MAKE_SOCK

LANDLOCK_ACCESS_FS_MAKE_FIFO

LANDLOCK_ACCESS_FS_MAKE_BLOCK

LANDLOCK_ACCESS_FS_MAKE_SYM

2

5.19

LANDLOCK_ACCESS_FS_REFER

3

6.2

LANDLOCK_ACCESS_FS_TRUNCATE

Users should use the Landlock ABI version rather than the kernel version to determine which features are available. The mainline kernel versions listed here are only included for orientation. Kernels from other sources may contain backported features, and their version numbers may not match.

To query the running kernel's Landlock ABI version, programs may pass the LANDLOCK_CREATE_RULESET_VERSION flag to landlock_create_ruleset(2).

When building fallback mechanisms for compatibility with older kernels, users are advised to consider the special semantics of the LANDLOCK_ACCESS_FS_REFER access right: In ABI v1, linking and moving of files between different directories is always forbidden, so programs relying on such operations are only compatible with Landlock ABI v2 and higher.

## NOTES
Landlock is enabled by CONFIG_SECURITY_LANDLOCK. The lsm=lsm1,...,lsmN command line parameter controls the sequence of the initialization of Linux Security Modules. It must contain the string landlock to enable Landlock. If the command line parameter is not specified, the initialization falls back to the value of the deprecated security= command line parameter and further to the value of CONFIG_LSM. We can check that Landlock is enabled by looking for landlock: Up and running. in kernel logs.

## CAVEATS
It is currently not possible to restrict some file-related actions accessible through these system call families: chdir(2), stat(2), flock(2), chmod(2), chown(2), setxattr(2), utime(2), ioctl(2), fcntl(2), access(2). Future Landlock evolutions will enable to restrict them.

## EXAMPLES
We first need to create the ruleset that will contain our rules.

For this example, the ruleset will contain rules that only allow read actions, but write actions will be denied. The ruleset then needs to handle both of these kinds of actions. See the DESCRIPTION section for the description of filesystem actions.

```
struct landlock_ruleset_attr attr = {0};
int ruleset_fd;
attr.handled_access_fs =

        LANDLOCK_ACCESS_FS_EXECUTE |

        LANDLOCK_ACCESS_FS_WRITE_FILE |

        LANDLOCK_ACCESS_FS_READ_FILE |

        LANDLOCK_ACCESS_FS_READ_DIR |

        LANDLOCK_ACCESS_FS_REMOVE_DIR |

        LANDLOCK_ACCESS_FS_REMOVE_FILE |

        LANDLOCK_ACCESS_FS_MAKE_CHAR |

        LANDLOCK_ACCESS_FS_MAKE_DIR |

        LANDLOCK_ACCESS_FS_MAKE_REG |

        LANDLOCK_ACCESS_FS_MAKE_SOCK |

        LANDLOCK_ACCESS_FS_MAKE_FIFO |

        LANDLOCK_ACCESS_FS_MAKE_BLOCK |

        LANDLOCK_ACCESS_FS_MAKE_SYM |

        LANDLOCK_ACCESS_FS_REFER |

        LANDLOCK_ACCESS_FS_TRUNCATE;
```

To be compatible with older Linux versions, we detect the available Landlock ABI version, and only use the available subset of access rights:

```
/*

 * Table of available file system access rights by ABI version,

 * numbers hardcoded to keep the example short.

 */
__u64 landlock_fs_access_rights[] = {

    (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) - 1,  /* v1                 */

    (LANDLOCK_ACCESS_FS_REFER    << 1) - 1,  /* v2: add "refer"    */

    (LANDLOCK_ACCESS_FS_TRUNCATE << 1) - 1,  /* v3: add "truncate" */
};
int abi = landlock_create_ruleset(NULL, 0,

                                  LANDLOCK_CREATE_RULESET_VERSION);
if (abi == -1) {

    /*

     * Kernel too old, not compiled with Landlock,

     * or Landlock was not enabled at boot time.

     */

    perror("Unable to use Landlock");

    return;  /* Graceful fallback: Do nothing. */
}
abi = MIN(abi, 3);
/* Only use the available rights in the ruleset. */
attr.handled_access_fs &= landlock_fs_access_rights[abi - 1];
```

The available access rights for each ABI version are listed in the VERSIONS section.

If our program needed to create hard links or rename files between different directories (LANDLOCK_ACCESS_FS_REFER), we would require the following change to the backwards compatibility logic: Directory reparenting is not possible in a process restricted with Landlock ABI version 1. Therefore, if the program needed to do file reparenting, and if only Landlock ABI version 1 was available, we could not restrict the process.

Now that the ruleset attributes are determined, we create the Landlock ruleset and acquire a file descriptor as a handle to it, using landlock_create_ruleset(2):

```
ruleset_fd = landlock_create_ruleset(&attr, sizeof(attr), 0);
if (ruleset_fd == -1) {

    perror("Failed to create a ruleset");

    exit(EXIT_FAILURE);
}
```

We can now add a new rule to the ruleset through the ruleset's file descriptor. The requested access rights must be a subset of the access rights which were specified in attr.handled_access_fs at ruleset creation time.

In this example, the rule will only allow reading the file hierarchy /usr. Without another rule, write actions would then be denied by the ruleset. To add /usr to the ruleset, we open it with the O_PATH flag and fill the struct landlock_path_beneath_attr with this file descriptor.

```
struct landlock_path_beneath_attr path_beneath = {0};
int err;
path_beneath.allowed_access =

        LANDLOCK_ACCESS_FS_EXECUTE |

        LANDLOCK_ACCESS_FS_READ_FILE |

        LANDLOCK_ACCESS_FS_READ_DIR;
path_beneath.parent_fd = open("/usr", O_PATH | O_CLOEXEC);
if (path_beneath.parent_fd == -1) {

    perror("Failed to open file");

    close(ruleset_fd);

    exit(EXIT_FAILURE);
}
err = landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,

                        &path_beneath, 0);
close(path_beneath.parent_fd);
if (err) {

    perror("Failed to update ruleset");

    close(ruleset_fd);

    exit(EXIT_FAILURE);
}
```

We now have a ruleset with one rule allowing read access to /usr while denying all other handled accesses for the filesystem. The next step is to restrict the current thread from gaining more privileges (e.g., thanks to a set-user-ID binary).

```
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {

    perror("Failed to restrict privileges");

    close(ruleset_fd);

    exit(EXIT_FAILURE);
}
```

The current thread is now ready to sandbox itself with the ruleset.

```
if (landlock_restrict_self(ruleset_fd, 0)) {

    perror("Failed to enforce ruleset");

    close(ruleset_fd);

    exit(EXIT_FAILURE);
}
close(ruleset_fd);
```

If the landlock_restrict_self(2) system call succeeds, the current thread is now restricted and this policy will be enforced on all its subsequently created children as well. Once a thread is landlocked, there is no way to remove its security policy; only adding more restrictions is allowed. These threads are now in a new Landlock domain, merge of their parent one (if any) with the new ruleset.

Full working code can be found in https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/samples/landlock/sandboxer.c

## SEE ALSO
landlock_create_ruleset(2), landlock_add_rule(2), landlock_restrict_self(2)

https://landlock.io/


libc

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, 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 glibc 2.3. 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.

## STANDARDS
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-section

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 name and version of the project that provides the manual page (not necessarily the package that provides the functionality).

manual-section

Normally, this should be empty, since the default value will be good.

### 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

LIBRARY

[Normally only in Sections 2, 3]

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

ATTRIBUTES

[Normally only in Sections 2, 3]

VERSIONS

[Normally only in Sections 2, 3]

STANDARDS

HISTORY

NOTES

CAVEATS

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.

LIBRARY

The library providing a symbol.

It shows the common name of the library, and in parentheses, the name of the library file and, if needed, the linker flag needed to link a program against it: (libfoo[, -lfoo]).

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 summary of systems where the API performs differently, or where there's a similar API.

STANDARDS

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).

This section should note the current standards to which the API conforms to.

If the API is not governed by any standards but commonly exists on other systems, note them. If the call is Linux-specific or GNU-specific, note this. If it's available in the BSDs, note that.

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

HISTORY

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 HISTORY 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 Linux 2.2), and library functions that have been added to glibc since glibc 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.

Old versions of standards should be mentioned here, rather than in STANDARDS, for example, SUS, SUSv2, and XPG, or the SVr4 and 4.xBSD implementation standards.

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.

CAVEATS

Warnings about typical user misuse of an API, that don't constitute an API bug or design defect.

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, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase boundaries. 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, clauses, or phrases.

### Lists
There are different kinds of lists:

Tagged paragraphs

These are used for a list of tags and their descriptions. When the tags are constants (either macros or numbers) they are in bold. Use the .TP macro.

An example is this "Tagged paragraphs" subsection is itself.

Ordered lists

Elements are preceded by a number in parentheses (1), (2). These represent a set of steps that have an order.

When there are substeps, they will be numbered like (4.2).

Positional lists

Elements are preceded by a number (index) in square brackets [4], [5]. These represent fields in a set. The first index will be:

0

When it represents fields of a C data structure, to be consistent with arrays.

1

When it represents fields of a file, to be consistent with tools like cut(1).

Alternatives list

Elements are preceded by a letter in parentheses (a), (b). These represent a set of (normally) exclusive alternatives.

Bullet lists

Elements are preceded by bullet symbols (\[bu]). Anything that doesn't fit elsewhere is usually covered by this type of list.

Numbered notes

Not really a list, but the syntax is identical to "positional lists".

There should always be exactly 2 spaces between the list symbol and the elements. This doesn't apply to "tagged paragraphs", which use the default indentation rules.

### 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 (\[ti]) 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

symbolic link

symlink

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 byte
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

```
\[aq]C\[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 (glibc 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