# Command-Line Basics

---

# Working with Text and Archives

_Peios / Using Peios / Command-Line Basics_

> Choose text tools, inspect archives, and extract contents without treating conventional metadata as a native backup.

Install the tools needed for the task. Package availability in the system
root does not imply availability in an initramfs.

## Inspect and compare

Use `grep` for matching lines, `sed` for line transformations, `awk` or `gawk`
for fields and records, and `find` with `xargs` for selecting files and
passing
arguments. `diff`, `cmp`, `diff3`, and `sdiff` compare contents. Peiosutils
supplies basic tools including `cat`, `head`, `tail`, `cut`, `paste`, `join`,
`sort`, `uniq`, `tr`, and `wc`.

```sh
grep -n 'error' output.txt
awk '{ print $1 }' records.txt
diff before.txt after.txt
less output.txt
```

In `less`, Space advances, `b` goes back, `/pattern` searches, `n` repeats the
search, and `q` quits. Its edit command needs a separately installed editor.
For terminal editing and its save/recovery rules, see
[Editing With nano](/peios/using-peios/command-line-basics/editing-with-nano.md).

## Create, inspect, and extract

1. Choose a format supported by the recipient and install its compressor
   command as well as the archive tool. A compression library alone does
   not provide the executable GNU tar invokes.
2. Create and inspect an archive:

   ```sh
   tar -caf backup.tar.xz documents/
   tar -tf backup.tar.xz
   ```

3. Extract into a fresh directory and inspect the resulting contents:

   ```sh
   mkdir restored
   tar -xf backup.tar.xz -C restored
   ```

GNU tar's `-a` selects compression by suffix, such as `.tar.gz`, `.tar.xz`,
`.tar.zst`, or `.tar.bz2`. The associated commands are gzip, XZ, Zstandard,
and bzip2. `file ARCHIVE` identifies contents independently of the name.

For ZIP exchange, use `zip -r documents.zip documents/`, inspect with
`unzip -l documents.zip`, then extract with
`unzip documents.zip -d restored-zip`.
These formats carry conventional metadata and contents, not a complete
Peios
backup of native security descriptors and registry state.

---

# Editing with Nano

_Peios / Using Peios / Command-Line Basics_

> Save a document and interpret the Peios port's private backup, recovery, and history behavior.

The `org.gnu.nano` package supplies nano and rnano. Its common package
supplies
syntax definitions, translations, and manuals. The vendor nanorc enables
bundled syntax definitions. HOME and XDG data conventions select user state.

## Edit and check a document

1. Open `nano path/to/file`. Use Ctrl+G for help.
2. Edit the intended buffer. Ctrl+O writes it; Enter confirms the filename.
3. Confirm the write succeeded before Ctrl+X exits. Check the saved contents
   when recovery or an external writer makes the result uncertain.

An existing regular file is written in place. Its owner, DACL, audit policy,
and integrity label remain, and hardlinks still refer to that object. This
is not atomic replacement or a guarantee against interrupted storage writes.
New documents use destination inheritance. FACS controls access; numeric root
and Unix modes do not grant permission. Saving does not itself require
permission to rewrite the descriptor, while synchronization needs its
applicable handle right.

## Choose backup and recovery behavior

`nano --backup file` requests a backup, normally `file~`. Backups, emergency
`.save` files, and formatter/speller scratch files are private to the
effective token's user SID before contents are written. They do not clone
the document's sharing policy or ownership. Normal mandatory and audit
controls still apply.

On a hangup or fatal error nano attempts an emergency save and reports its
path on success. Space, directory authority, and private-creation failures
can prevent it. There is no fallback to Unix `0600`. If backup fails, the
prompt lets the user decide whether to save the original without a backup;
do not mistake that choice for a successful recovery copy.

## History and lock files

Search/replace/command history and cursor-position history are optional,
selected by `--historylog` and `--positionlog`. nano uses a suitable existing
`~/.nano` or its XDG/default local-data directory. Its private state policy
must already hold for existing files and directories. It validates opened
files and refuses symlinks, multiple hardlinks, and incompatible policy
rather than silently changing permissions. A history error disables the
affected operation without disabling ordinary editing.

Advisory lock files use nano's interoperable format and normal inheritance.
They expose editing identity/path metadata, not buffer contents, and do not
authorize access. rnano's restricted editing mode also grants no new native
authority.

---

# Choosing Session Locales

_Peios / Using Peios / Command-Line Basics_

> Select language and regional conventions for new console, desktop, and SSH sessions.

A locale controls character handling, sorting, and regional formats such as
dates and numbers. It is separate from a console keyboard layout, console
font, or the desktop clock's 12-hour or 24-hour display preference.

## Before you start

Install the locale data needed by the intended sessions. `locale -a` lists
available locales when the locale tools are installed. Installing language
data does not select it. The Peios session resolver falls back to `C.UTF-8`;
a minimal image must supply its locale data for that fallback to work.

Choose the scope: machine defaults affect users without an override, while
personal preferences affect one account. You need write access to the chosen
registry key and destination layer. Record the old values before changing
individual format categories.

## Select and verify a locale

1. For personal preferences, open [My
   Settings](/peios/using-peios/local-accounts/my-settings.md) and choose **Language &
   Formats**. For machine defaults, use [System
   Settings](/peios/using-peios/registry/system-settings.md), **Language & Keyboard**.
2. Choose an installed language and the desired formats. Read the saved
   outcome. The forms write the language and their format categories
   together; use the registry interface for a change to only one category.
3. Keep existing work safe, then start a new session through the intended
   client. Rejoining an existing browser session does not refresh its
   process environments.
4. Inspect that new session:

   ```sh
   locale
   locale charmap
   locale -k decimal_point
   ```

Check the selected language, character set, and category values, not only the
saved registry fields. An application can make its own locale choice.

## Category precedence

Machine preferences live under `Machine\System\Locale`; account
preferences live under `Users\<SID>\Locale`. Read those keys' registry
manuals for supported values and types. authd prepares the private user root
at sign-in; it does not replace an existing root's descriptor.

A valid personal value overrides the same machine value. Categories without
an explicit value use `LANG`. Changing personal `LANG` alone does not remove
a machine category override. For example, a machine `LC_NUMERIC` can keep its
number format even when the account selects another language.

**System Default** removes a personal language override. **Match Language**
removes personal format overrides, so machine category overrides can still
apply. To select one installed locale for language and all categories handled
by the form, select it explicitly in both lists.

Wrong types, malformed names, and unavailable locale data are diagnosed and
ignored, leaving the preceding valid default. A locale name is not a path.
`LC_ALL`, `LANGUAGE`, and `LOCPATH` are not stored session preferences.
For a one-command override, an environment setting such as `LC_ALL=C` can
still be appropriate.

## Client and service boundaries

Console sign-in and new GXWI sessions clear inherited locale overrides before
applying registry preferences. Console `login -p` refreshes locale even while
preserving other environment values.

SSH applies the registry preferences as defaults. Explicit environment entries
permitted by SSH configuration, user environment files, or administrator
`SetEnv` settings can override them for that session. Check the effective
result through the actual SSH route.

These settings do not rewrite running process environments or become peinit's
global service environment. Services need their own documented configuration.

---

# Configuring Console Keyboards and Fonts

_Peios / Using Peios / Command-Line Basics_

> Apply a Linux virtual-console map and distinguish stored boot preferences from a successful live load.

The kbd tools operate on Linux virtual consoles such as `/dev/tty1`. They do
not change an SSH client's keyboard, a serial terminal, or the browser's
layout. Install `org.kernel.kbd` and its matching common data package;
keymaps and fonts live under `/usr/share/kbd`.

## Inspect and apply

1. To parse an installed layout without changing the console, generate a
   binary map: `loadkeys --bkeymap uk > uk.bmap`.
2. With authority for the console operation, apply the intended map:

   ```sh
   loadkeys -C /dev/tty1 uk
   ```

3. Verify typing at the machine's text console. A map can affect other
   virtual consoles; a device selection is not a per-session layout promise.

`setfont -C /dev/tty1 Lat2-Terminus16` loads an installed font when permitted.
`dumpkeys` inspects the map, `kbd_mode` inspects or changes keyboard mode,
`fgconsole` identifies the active console, and `chvt` switches consoles.
Switching is neither authentication nor creation of a logon session.

## Store a boot preference

The `console-keymap` service reads the `Keymap` name under
`Machine\System\Console`. A name selects installed data, never an arbitrary
path. With the registry and service-control rights, adapt:

```sh
reg set Machine/System/Console Keymap sz:uk
svctl restart console-keymap
```

System Settings offers the corresponding **Console Keyboard** layout
selection and requests a restart when available and permitted. A custom
image without the service does not acquire a loader by storing a value.
A configured boot-triggered service can apply the choice at next boot when
an immediate restart is unavailable. An absent value leaves the built-in US
layout; an invalid map leaves the existing layout and produces a diagnostic.

Inspect service status/output and verify actual console input. A saved value
or accepted restart request does not establish that loading finished. Font
persistence requires separate configuration. Installing kbd alone neither
applies its service seed nor starts additional sign-in prompts.

## Launch and package boundaries

`openvt` launches with the caller's token and the existing console descriptor;
it does not authenticate or grant identity. Its upstream `--user` mode is
rejected on Peios. Use the [managed console sign-in
services](/peios/signing-in/using-a-console.md) for that purpose.
The PAM-based vlock locker and optional XKB conversion are excluded from the
recipe. Debug and source packages do not configure the console.

---

# Choosing a Message Language

_Peios / Using Peios / Command-Line Basics_

> Read utility help and diagnostics in an installed language.

Peiosutils can display help and diagnostics in different languages. You can
choose a language for one command without changing the environment of your
shell or other applications.

## Before you start

- Install the matching `peiosutils-common` package with the utilities. It
  supplies translated messages, including the shared usage and error text.
- Use a command with translations for your chosen language. Coverage varies
  between commands; missing messages fall back to English.

## Choose a language

1. Set `LANG` for the command you want to run. For example, read the help for
   `sort` in French:

   ```sh
   env LANG=fr_FR.UTF-8 sort --help
   ```

2. To read the same help in English, select the English locale:

   ```sh
   env LANG=en_US.UTF-8 sort --help
   ```

These assignments apply to the command launched by `env`. Your shell keeps
its existing environment. See `env(1)` for other ways to control a command's
environment.

## Check the result

The French help includes `Utilisation:`; the English help includes `Usage:`.
Both should show readable usage text rather than an internal message name
such as `common-usage`.

If the command remains in English, check that its translation is installed.
A missing or unsupported language falls back to English. The shared message
loader reads `LANG`; other locale-sensitive operations can use additional
locale settings. Changing the language of help does not establish the
sorting or numeric-formatting rules for every command.
