merged multiple files for one topic into one markdown file, did some refactoring in linux.md

This commit is contained in:
scbj
2025-06-24 11:52:38 +02:00
parent 28d472b36d
commit 9103bcd51c
10 changed files with 115 additions and 89 deletions

View File

@@ -1,3 +1,100 @@
# Linux
This document collects knowledge, tips and tricks on all things Linux, that don't get their own document.
<!--toc:start-->
- [Linux](#linux)
- [Setup and Configuration](#setup-and-configuration)
- [Locales and Keyboard Layouts](#locales-and-keyboard-layouts)
- [configure layout 'US intl. with deadkeys'](#configure-layout-us-intl-with-deadkeys)
- [Linux commands](#linux-commands)
- [combine commands with *xargs*](#combine-commands-with-xargs)
- [pipe output into clipboard](#pipe-output-into-clipboard)
- [permissions](#permissions)
- [octal permissions](#octal-permissions)
- [Terminal](#terminal)
- [ANSI escape sequences](#ansi-escape-sequences)
- [Text Style](#text-style)
- [Color codes](#color-codes)
- [8-16 Colors](#8-16-colors)
- [256 Colors](#256-colors)
- [RGB Colors](#rgb-colors)
<!--toc:end-->
## Setup and Configuration
### Locales and Keyboard Layouts
Use `localectl` to display and configure locales and keyboard layout:
```sh
# show current locales
localectl status
```
#### configure layout 'US intl. with deadkeys'
To configure `US intl. with deadkeys`, set the following values:
```sh
X11 Layout: us
X11 Model: default
X11 Variant: intl
```
## Linux commands
- [Linux commands](#linux-commands)
- [combine commands with *xargs*](#combine-commands-with-xargs)
### combine commands with *xargs*
Some commands (e.g. `chmod`) can't handle input via pipe and require the input as arguments.
`xargs` takes the standard input as list of arguments seperated by spaces or newlines and executes the given command with the input parsed to a list of arguments.
Usage:
```bash
find . -type f | xargs chmod 644
```
### pipe output into clipboard
> requires `xclip`
One can save command output to the clipboard by piping it to `xclip`:
```sh
# usage
command | xclip -selection clipboard
# working example with 'echo'
echo "hello world" | xclip -selection clipboard
```
> NOTE: the argument `-selection clipboard` is required
## permissions
Linux permissions are ordered as follows:
- owner
- group
- others
### octal permissions
In octal representation the actions (read, write, execute) have the values:
- read = 4
- write = 2
- execute = 1
## Terminal ## Terminal
- [ANSI escape sequences](#ansi-escape-sequences) - [ANSI escape sequences](#ansi-escape-sequences)
@@ -5,14 +102,17 @@
### ANSI escape sequences ### ANSI escape sequences
Ansi escape sequences are used to format output in a terminal. They **are prefixed with an escape character**, which can be written in a few ways: Ansi escape sequences are used to format output in a terminal.
They **are prefixed with an escape character**, which can be written in a few ways:
- Ctrl-Key `^[` - Ctrl-Key `^[`
- Octal `\033` (\0 for octal) - Octal `\033` (\0 for octal)
- Hexadecimal `\x1B` (\\x for hexadecimal) - Hexadecimal `\x1B` (\\x for hexadecimal)
- Unicode `\u001b` - Unicode `\u001b`
The sequences is started with a `[` followed by the command and arguments. Arguments are separated with `;`. **Sequences are terminated with `m`.** The sequences is started with a `[` followed by the command and arguments.
Arguments are separated with `;`.
**Sequences are terminated with `m`.**
``` bash ``` bash
# Example: # Example:
@@ -20,6 +120,8 @@ The sequences is started with a `[` followed by the command and arguments. Argum
``` ```
For the following tables we define `ESC = \x1B` For the following tables we define `ESC = \x1B`
#### Text Style #### Text Style
| ESC Code Sequence | Reset Sequence | Description | | ESC Code Sequence | Reset Sequence | Description |
@@ -37,11 +139,14 @@ For the following tables we define `ESC = \x1B`
> **Note:** Some terminals may not support some of the graphic mode sequences listed above. > **Note:** Some terminals may not support some of the graphic mode sequences listed above.
> **Note:** Both dim and bold modes are reset with the `ESC[22m` sequence. The `ESC[21m` sequence is a non-specified sequence for double underline mode and only works in some terminals and is reset with `ESC[24m`. > **Note:** Both dim and bold modes are reset with the `ESC[22m` sequence.
> The `ESC[21m` sequence is a non-specified sequence for double underline mode and only works in some terminals and is reset with `ESC[24m`.
#### Color codes #### Color codes
Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These colors are set by the user, but have commonly defined meanings. Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors.
These colors are set by the user, but have commonly defined meanings.
##### 8-16 Colors ##### 8-16 Colors
@@ -61,7 +166,8 @@ Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These col
> **Note:** the _Reset_ color is the reset code that resets _all_ colors and text effects, Use _Default_ color to reset colors only. > **Note:** the _Reset_ color is the reset code that resets _all_ colors and text effects, Use _Default_ color to reset colors only.
Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors. These have their own set of codes, mirroring the normal colors, but with an additional `;1` in their codes: Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors.
These have their own set of codes, mirroring the normal colors, but with an additional `;1` in their codes:
```sh ```sh
# Set style to bold, red foreground. # Set style to bold, red foreground.
@@ -83,6 +189,7 @@ Terminals that support the [aixterm specification](https://sites.ualberta.ca/dep
| Bright Cyan | `96` | `106` | | Bright Cyan | `96` | `106` |
| Bright White | `97` | `107` | | Bright White | `97` | `107` |
##### 256 Colors ##### 256 Colors
The following escape codes tells the terminal to use the given color ID: The following escape codes tells the terminal to use the given color ID:
@@ -97,17 +204,14 @@ Where `{ID}` should be replaced with the color index from 0 to 255 of the follow
![256 Color table](https://user-images.githubusercontent.com/995050/47952855-ecb12480-df75-11e8-89d4-ac26c50e80b9.png) ![256 Color table](https://user-images.githubusercontent.com/995050/47952855-ecb12480-df75-11e8-89d4-ac26c50e80b9.png)
The table starts with the original 16 colors (0-15). The table starts with the original 16 colors (0-15).
The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by 16, packed into a single value. The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by 16, packed into a single value.
The final 24 colors (232-255) are grayscale starting from a shade slighly lighter than black, ranging up to shade slightly darker than white. The final 24 colors (232-255) are grayscale starting from a shade slighly lighter than black, ranging up to shade slightly darker than white.
Some emulators interpret these steps as linear increments (`256 / 24`) on all three channels, although some emulators may explicitly define these values. Some emulators interpret these steps as linear increments (`256 / 24`) on all three channels, although some emulators may explicitly define these values.
##### RGB Colors ##### RGB Colors
More modern terminals supports [Truecolor](https://en.wikipedia.org/wiki/Color_depth#True_color_.2824-bit.29) (24-bit RGB), which allows you to set foreground and background colors using RGB. More modern terminals supports [Truecolor](https://en.wikipedia.org/wiki/Color_depth#True_color_.2824-bit.29) (24-bit RGB), which allows you to set foreground and background colors using RGB.
These escape sequences are usually not well documented. These escape sequences are usually not well documented.
| ESC Code Sequence | Description | | ESC Code Sequence | Description |
@@ -115,5 +219,6 @@ These escape sequences are usually not well documented.
| `ESC[38;2;{r};{g};{b}m` | Set foreground color as RGB. | | `ESC[38;2;{r};{g};{b}m` | Set foreground color as RGB. |
| `ESC[48;2;{r};{g};{b}m` | Set background color as RGB. | | `ESC[48;2;{r};{g};{b}m` | Set background color as RGB. |
> Note that `38` and `48` corresponds to the 16 color sequence and is interpreted by the terminal to set the foreground and background color respectively. Where as `;2` and `;5` sets the color format. > Note that `38` and `48` corresponds to the 16 color sequence and is interpreted by the terminal to set the foreground and background color respectively.
> Where as `;2` and `;5` sets the color format.

View File

@@ -1,5 +0,0 @@
./linux/linux.md
./linux/setup.md
./linux/commands.md
./linux/permissions.md
./linux/terminal.md

View File

@@ -1,29 +0,0 @@
## Linux commands
- [Linux commands](#linux-commands)
- [combine commands with *xargs*](#combine-commands-with-xargs)
### combine commands with *xargs*
Some commands (e.g. `chmod`) can't handle input via pipe and require the input as arguments. `xargs` takes the standard input as list of arguments seperated by spaces or newlines and executes the given command with the input parsed to a list of arguments.
Usage:
```bash
find . -type f | xargs chmod 644
```
### pipe output into clipboard
> requires `xclip`
One can save command output to the clipboard by piping it to `xclip`:
```sh
# usage
command | xclip -selection clipboard
# working example with 'echo'
echo "hello world" | xclip -selection clipboard
```
> NOTE: the argument `-selection clipboard` is required

View File

@@ -1,9 +0,0 @@
# Linux
This document collects knowledge, tips and tricks on all things Linux, that don't get their own document.
- [Setup and Configuration](linux/setup.md)
- [Linux commands](linux/commands.md)
- [Permissions](linux/permissions.md)
- [Terminal](linux/terminal.md)

View File

@@ -1,14 +0,0 @@
## permissions
Linux permissions are ordered as follows:
- owner
- group
- others
### octal permissions
In octal representation the actions (read, write, execute) have the values:
- read = 4
- write = 2
- execute = 1

View File

@@ -1,21 +0,0 @@
## Setup and Configuration
### Locales and Keyboard Layouts
Use `localectl` to display and configure locales and keyboard layout:
```sh
# show current locales
localectl status
```
#### configure layout 'US intl. with deadkeys'
To configure `US intl. with deadkeys`, set the following values:
```sh
X11 Layout: us
X11 Model: default
X11 Variant: intl
```

View File

@@ -1 +0,0 @@
./make/make.md