From e9c1654811bc185f6bfed56b99714b44f35ccf23 Mon Sep 17 00:00:00 2001 From: ivuorinen Date: Tue, 9 Dec 2025 00:21:17 +0000 Subject: [PATCH] Update cheatsheets --- tldr/[ | 1 + tldr/chgrp | 1 + tldr/chown | 5 +++++ tldr/chroot | 6 +++++- tldr/dirname | 2 +- tldr/install | 2 +- tldr/linux/mknod | 2 +- tldr/linux/nl | 2 +- tldr/linux/pivot_root | 18 ++++++++++++++++++ tldr/mkfifo | 2 +- tldr/nh | 6 +++++- tldr/nix-build | 2 +- tldr/nix-collect-garbage | 6 +++++- tldr/nix-shell | 2 +- tldr/nix-store | 2 +- tldr/nl | 2 +- tldr/paste | 6 +++--- tldr/printenv | 2 +- tldr/printf | 3 ++- tldr/seq | 16 ++++++++++++---- tldr/shred | 2 +- tldr/stty | 2 +- tldr/test | 1 + tldr/touch | 2 +- tldr/truncate | 2 +- tldr/users | 2 +- tldr/vdir | 2 +- tldr/w | 1 + tldr/who | 2 +- 29 files changed, 76 insertions(+), 28 deletions(-) create mode 100644 tldr/linux/pivot_root diff --git a/tldr/[ b/tldr/[ index caf88088..dea790ef 100644 --- a/tldr/[ +++ b/tldr/[ @@ -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: . - Test if a given variable is equal/not equal to the specified string: diff --git a/tldr/chgrp b/tldr/chgrp index 29e48d81..51d0c906 100644 --- a/tldr/chgrp +++ b/tldr/chgrp @@ -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: . - Change the owner group of a file/directory: diff --git a/tldr/chown b/tldr/chown index 1d3ec74c..550ee76f 100644 --- a/tldr/chown +++ b/tldr/chown @@ -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: . - 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}}` diff --git a/tldr/chroot b/tldr/chroot index fe4fd8b5..96435de8 100644 --- a/tldr/chroot +++ b/tldr/chroot @@ -8,10 +8,14 @@ source: https://github.com/tldr-pages/tldr.git > Run command or interactive shell with special root directory. > More information: . +- 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}}` diff --git a/tldr/dirname b/tldr/dirname index 11a56369..48912780 100644 --- a/tldr/dirname +++ b/tldr/dirname @@ -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: . - Calculate the parent directory of a given path: diff --git a/tldr/install b/tldr/install index 8cae3c7c..85498746 100644 --- a/tldr/install +++ b/tldr/install @@ -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: . - Copy files to the destination: diff --git a/tldr/linux/mknod b/tldr/linux/mknod index 81c96d72..4c37187e 100644 --- a/tldr/linux/mknod +++ b/tldr/linux/mknod @@ -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}}` diff --git a/tldr/linux/nl b/tldr/linux/nl index ff758071..e9b2b16d 100644 --- a/tldr/linux/nl +++ b/tldr/linux/nl @@ -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}}` diff --git a/tldr/linux/pivot_root b/tldr/linux/pivot_root new file mode 100644 index 00000000..e2845760 --- /dev/null +++ b/tldr/linux/pivot_root @@ -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: . + +- 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]}}` diff --git a/tldr/mkfifo b/tldr/mkfifo index f3988726..decba6b1 100644 --- a/tldr/mkfifo +++ b/tldr/mkfifo @@ -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: . - Create a named pipe at a given path: diff --git a/tldr/nh b/tldr/nh index 73ee4bdc..40ee37be 100644 --- a/tldr/nh +++ b/tldr/nh @@ -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}}` diff --git a/tldr/nix-build b/tldr/nix-build index 8ae878a9..0d663a91 100644 --- a/tldr/nix-build +++ b/tldr/nix-build @@ -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` diff --git a/tldr/nix-collect-garbage b/tldr/nix-collect-garbage index 25ece059..a434690d 100644 --- a/tldr/nix-collect-garbage +++ b/tldr/nix-collect-garbage @@ -9,7 +9,7 @@ source: https://github.com/tldr-pages/tldr.git > Generations can be listed using `nix-env --list-generations`. > More information: . -- 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]}}` diff --git a/tldr/nix-shell b/tldr/nix-shell index d87222d6..4033af09 100644 --- a/tldr/nix-shell +++ b/tldr/nix-shell @@ -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` diff --git a/tldr/nix-store b/tldr/nix-store index af935ea0..8cb5ee9a 100644 --- a/tldr/nix-store +++ b/tldr/nix-store @@ -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` diff --git a/tldr/nl b/tldr/nl index c7330dee..9084b5f7 100644 --- a/tldr/nl +++ b/tldr/nl @@ -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}}` diff --git a/tldr/paste b/tldr/paste index f01ec098..726b3894 100644 --- a/tldr/paste +++ b/tldr/paste @@ -8,15 +8,15 @@ source: https://github.com/tldr-pages/tldr.git > Merge lines of files. > More information: . -- 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}}` diff --git a/tldr/printenv b/tldr/printenv index 23fc7030..8d67d0d5 100644 --- a/tldr/printenv +++ b/tldr/printenv @@ -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: . - Display key-value pairs of all environment variables: diff --git a/tldr/printf b/tldr/printf index 0f541507..c34906e1 100644 --- a/tldr/printf +++ b/tldr/printf @@ -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}}` diff --git a/tldr/seq b/tldr/seq index eddfcbc2..212f4d65 100644 --- a/tldr/seq +++ b/tldr/seq @@ -8,18 +8,26 @@ source: https://github.com/tldr-pages/tldr.git > Output a sequence of numbers to `stdout`. > More information: . -- 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}}` diff --git a/tldr/shred b/tldr/shred index 957534f0..26864288 100644 --- a/tldr/shred +++ b/tldr/shred @@ -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}}` diff --git a/tldr/stty b/tldr/stty index 1bf49489..b391a0d2 100644 --- a/tldr/stty +++ b/tldr/stty @@ -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: . - Display current terminal size: diff --git a/tldr/test b/tldr/test index bd1c0f85..d89c2f41 100644 --- a/tldr/test +++ b/tldr/test @@ -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: . - Test if a given variable is equal to a given string: diff --git a/tldr/touch b/tldr/touch index c4ccac52..9fca15c5 100644 --- a/tldr/touch +++ b/tldr/touch @@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git # touch > Create files and set access/modification times. -> More information: . +> More information: . - Create specific files: diff --git a/tldr/truncate b/tldr/truncate index e928104b..6c7e7096 100644 --- a/tldr/truncate +++ b/tldr/truncate @@ -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}}` diff --git a/tldr/users b/tldr/users index be9914d8..8be3fa11 100644 --- a/tldr/users +++ b/tldr/users @@ -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: . - Print logged in usernames: diff --git a/tldr/vdir b/tldr/vdir index 490e444d..ea84d6d0 100644 --- a/tldr/vdir +++ b/tldr/vdir @@ -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: . - List files and directories in the current directory, one per line, with details: diff --git a/tldr/w b/tldr/w index 1fc9fde4..d03fce44 100644 --- a/tldr/w +++ b/tldr/w @@ -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: . - Display information about all users who are currently logged in: diff --git a/tldr/who b/tldr/who index ba2c23f2..795b9f55 100644 --- a/tldr/who +++ b/tldr/who @@ -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: . - Display the username, line, and time of all currently logged-in sessions: