Update cheatsheets

This commit is contained in:
ivuorinen
2025-12-09 00:21:17 +00:00
parent 4bbaaf8836
commit e9c1654811
29 changed files with 76 additions and 28 deletions

1
tldr/[
View File

@@ -7,6 +7,7 @@ source: https://github.com/tldr-pages/tldr.git
> Check file types and compare values.
> Returns a status of 0 if the condition evaluates to true, 1 if it evaluates to false.
> See also: `test`.
> More information: <https://gnu.org/software/bash/manual/bash.html#index-test>.
- Test if a given variable is equal/not equal to the specified string:

View File

@@ -6,6 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# chgrp
> Change group ownership of files and directories.
> See also: `chown`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/chgrp-invocation.html>.
- Change the owner group of a file/directory:

View File

@@ -6,6 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# chown
> Change user and group ownership of files and directories.
> See also: `chgrp`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/chown-invocation.html>.
- Change the owner user of a file/directory:
@@ -20,6 +21,10 @@ source: https://github.com/tldr-pages/tldr.git
`sudo chown {{user}}: {{path/to/file_or_directory}}`
- Change the group of a file to a group that the current user belongs to:
`chown :{{group}} {{path/to/file_or_directory}}`
- Recursively change the owner of a directory and its contents:
`sudo chown {{[-R|--recursive]}} {{user}} {{path/to/directory}}`

View File

@@ -8,10 +8,14 @@ source: https://github.com/tldr-pages/tldr.git
> Run command or interactive shell with special root directory.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/chroot-invocation.html>.
- Run `$SHELL` in the new root directory:
`sudo chroot {{path/to/new_root}}`
- Run command as new root directory:
`sudo chroot {{path/to/new_root}} {{command}}`
- Use a specific user and group:
`sudo chroot --userspec {{username_or_id:group_name_or_id}}`
`sudo chroot --userspec {{username_or_id}}:{{group_name_or_id}} {{path/to/new_root}}`

View File

@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
---
# dirname
> Calculates the parent directory of a file or directory path.
> Remove trailing filename portion from a path.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/dirname-invocation.html>.
- Calculate the parent directory of a given path:

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# install
> Copy files and set attributes.
> Copy files (often executable) to a system location like `/usr/local/bin`, give them the appropriate permissions/ownership.
> Typically used by Makefiles.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html>.
- Copy files to the destination:

View File

@@ -22,4 +22,4 @@ source: https://github.com/tldr-pages/tldr.git
- Create a device file with default SELinux security context:
`sudo mknod {{[-Z |--context=]}}{{path/to/device_file}} {{type}} {{major_device_number}} {{minor_device_number}}`
`sudo mknod {{[-Z|--context]}} {{path/to/device_file}} {{type}} {{major_device_number}} {{minor_device_number}}`

View File

@@ -36,6 +36,6 @@ source: https://github.com/tldr-pages/tldr.git
`nl {{[-w|--number-width]}} {{col_width}} {{path/to/file}}`
- Use a specific string to separate the line numbers from the lines (TAB by default):
- Use a specific string to separate the line numbers from the lines (`TAB` by default):
`nl {{[-s|--number-separator]}} {{separator}} {{path/to/file}}`

18
tldr/linux/pivot_root Normal file
View File

@@ -0,0 +1,18 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# pivot_root
> Change the root filesystem to a new directory and move the current root to a subdirectory of the new root.
> Commonly used during system initialization (e.g., in `initramfs`) to switch from a temporary root to the real root filesystem.
> More information: <https://manned.org/pivot_root.8>.
- Make `/new_root` the new root (`/`) and move current root to a subdirectory of it:
`sudo pivot_root {{path/to/new_root}} {{path/to/new_root/old_root}}`
- Display help:
`pivot_root {{[-h|--help]}}`

View File

@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
---
# mkfifo
> Make FIFOs (named pipes).
> Make named pipes, also known as First In First Out (FIFO).
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/mkfifo-invocation.html>.
- Create a named pipe at a given path:

View File

@@ -16,10 +16,14 @@ source: https://github.com/tldr-pages/tldr.git
`nh clean all {{[-a|--ask]}}`
- Build a specified Nixos flake configuration and open it in a virtual machine:
- Build a specified Nixos flake configuration and create a symlink of the result from the Nix store:
`nh os build-vm {{path/to/flake}} {{[-H|--hostname]}} {{host}}`
- Build and test a specified Nixos flake configuration:
`nh os test {{path/to/flake}} {{[-H|--hostname]}} {{nixos}}`
- Build and switch to a specified Home manager flake configuration:
`nh home switch {{path/to/flake}} {{[-c|--configuration]}} {{home}}`

View File

@@ -7,7 +7,7 @@ source: https://github.com/tldr-pages/tldr.git
> `nix-build` can refer to multiple commands with the same name.
- View documentation for the traditional builder:
- View documentation for the traditional builder before version 2.4 of Nix:
`tldr nix-build.2`

View File

@@ -9,7 +9,7 @@ source: https://github.com/tldr-pages/tldr.git
> Generations can be listed using `nix-env --list-generations`.
> More information: <https://nixos.org/manual/nix/stable/command-ref/nix-collect-garbage.html>.
- Delete all store paths unused by current generations of each profile:
- Delete all user related store paths unused by current generations of each profile:
`nix-collect-garbage {{[-d|--delete-old]}}`
@@ -20,3 +20,7 @@ source: https://github.com/tldr-pages/tldr.git
- Delete all store paths older than 30 days:
`nix-collect-garbage --delete-older-than 30d`
- Delete all store paths unused by the current generation of each profile system-wide:
`sudo nix-collect-garbage {{[-d|--delete-old]}}`

View File

@@ -7,7 +7,7 @@ source: https://github.com/tldr-pages/tldr.git
> `nix-shell` can refer to multiple commands with the same name.
- View documentation for the traditional shell:
- View documentation for the traditional shell before version 2.4 of Nix:
`tldr nix-shell.2`

View File

@@ -7,7 +7,7 @@ source: https://github.com/tldr-pages/tldr.git
> `nix-store` can refer to multiple commands with the same name.
- View documentation for the traditional store:
- View documentation for the traditional store before version 2.4 of Nix:
`tldr nix-store.2`

View File

@@ -36,6 +36,6 @@ source: https://github.com/tldr-pages/tldr.git
`nl -w {{col_width}} {{path/to/file}}`
- Use a specific string to [s]eparate the line numbers from the lines (TAB by default):
- Use a specific string to [s]eparate the line numbers from the lines (`TAB` by default):
`nl -s {{separator}} {{path/to/file}}`

View File

@@ -8,15 +8,15 @@ source: https://github.com/tldr-pages/tldr.git
> Merge lines of files.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/paste-invocation.html>.
- Join all the lines into a single line, using TAB as delimiter:
- Join all the lines into a single line, using `TAB` as delimiter:
`paste {{[-s|--serial]}} {{path/to/file}}`
- Join all the lines into a single line, using the specified delimiter:
`paste {{[-sd|--serial --delimiters]}} {{delimiter}} {{path/to/file}}`
`paste {{[-s|--serial]}} {{[-d|--delimiters]}} {{delimiter}} {{path/to/file}}`
- Merge two files side by side, each in its column, using TAB as delimiter:
- Merge two files side by side, each in its column, using `TAB` as delimiter:
`paste {{path/to/file1}} {{path/to/file2}}`

View File

@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
---
# printenv
> Print values of all or environment variables.
> Print values of environment variables.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/printenv-invocation.html>.
- Display key-value pairs of all environment variables:

View File

@@ -36,4 +36,5 @@ source: https://github.com/tldr-pages/tldr.git
- Print a hexadecimal, octal and scientific number:
`printf "{{hex=%x octal=%o scientific=%e}}" 0x{{FF}} 0{{377}} {{100000}}`
`printf "{{hex=%x octal=%o scientific=%e
}}" 0x{{FF}} 0{{377}} {{100000}}`

View File

@@ -8,18 +8,26 @@ source: https://github.com/tldr-pages/tldr.git
> Output a sequence of numbers to `stdout`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html>.
- Sequence from 1 to 10:
- Print a sequence from 1 to 10:
`seq 10`
- Every 3rd number from 5 to 20:
- Print a sequence from 10 to 20:
`seq 10 20`
- Print every 3rd number from 5 to 20:
`seq 5 3 20`
- Separate the output with a space instead of a newline:
`seq {{[-s|--separator]}} " " 5 3 20`
`seq {{[-s|--separator]}} " " {{5 3 20}}`
- Format output width to a minimum of 4 digits padding with zeros as necessary:
`seq {{[-f|--format]}} "%04g" 5 3 20`
`seq {{[-f|--format]}} "%04g" {{5 3 20}}`
- Print all numbers with the same width:
`seq {{[-w|--equal-width]}} {{5 3 20}}`

View File

@@ -30,4 +30,4 @@ source: https://github.com/tldr-pages/tldr.git
- Overwrite a file 100 times, add a final overwrite with zeros, remove the file after overwriting it and show verbose progress on the screen:
`shred {{[-vzun|--verbose --zero --remove --iterations]}} 100 {{path/to/file}}`
`shred {{[-vzu|--verbose --zero --remove]}} {{[-n|--iterations]}} 100 {{path/to/file}}`

View File

@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
---
# stty
> Set options for a terminal device interface.
> Set or get options for a terminal device interface.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/stty-invocation.html>.
- Display current terminal size:

View File

@@ -7,6 +7,7 @@ source: https://github.com/tldr-pages/tldr.git
> Check file types and compare values.
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false.
> See also: `[`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/test-invocation.html>.
- Test if a given variable is equal to a given string:

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# touch
> Create files and set access/modification times.
> More information: <https://manned.org/touch>.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/touch-invocation.html>.
- Create specific files:

View File

@@ -26,4 +26,4 @@ source: https://github.com/tldr-pages/tldr.git
- Empty the file's content, but do not create the file if it does not exist:
`truncate {{[-cs|--no-create --size]}} 0 {{path/to/file}}`
`truncate {{[-s|--size]}} 0 {{[-c|--no-create]}} {{path/to/file}}`

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# users
> Display a list of logged in users.
> See also: `useradd`, `userdel`, `usermod`.
> See also: `who`, `w`, `useradd`, `userdel`, `usermod`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/users-invocation.html>.
- Print logged in usernames:

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# vdir
> Verbosely list directory contents.
> Drop-in replacement for `ls -l -b`.
> Drop-in replacement for `ls -l --escape`.
> More information: <https://manned.org/vdir>.
- List files and directories in the current directory, one per line, with details:

1
tldr/w
View File

@@ -6,6 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# w
> Display who is logged in and their processes.
> See also: `who`, `users`.
> More information: <https://manned.org/w>.
- Display information about all users who are currently logged in:

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# who
> Display who is logged in and related data (processes, boot time).
> See also: `whoami`.
> See also: `users`, `w`, `whoami`.
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/who-invocation.html>.
- Display the username, line, and time of all currently logged-in sessions: