Update cheatsheets

This commit is contained in:
ivuorinen
2025-03-14 00:18:08 +00:00
parent 904f7fe0c1
commit 605e1cdfd8
20 changed files with 97 additions and 68 deletions

View File

@@ -14,19 +14,19 @@ source: https://github.com/tldr-pages/tldr.git
- Start `htop` displaying processes owned by a specific user:
`htop --user {{username}}`
`htop {{[-u|--user]}} {{username}}`
- Display processes hierarchically in a tree view to show the parent-child relationships:
`htop --tree`
`htop {{[-t|--tree]}}`
- Sort processes by a specified `sort_item` (use `htop --sort help` for available options):
`htop --sort {{sort_item}}`
`htop {{[-s|--sort]}} {{sort_item}}`
- Start `htop` with the specified delay between updates, in tenths of a second (i.e. 50 = 5 seconds):
`htop --delay {{50}}`
`htop {{[-d|--delay]}} {{50}}`
- See interactive commands while running htop:
@@ -38,4 +38,4 @@ source: https://github.com/tldr-pages/tldr.git
- Display help:
`htop --help`
`htop {{[-h|--help]}}`

View File

@@ -14,19 +14,19 @@ source: https://github.com/tldr-pages/tldr.git
- Display the current user identity:
`id -un`
`id {{[-un|--user --name]}}`
- Display the current user identity as a number:
`id -u`
`id {{[-u|--user]}}`
- Display the current primary group identity:
`id -gn`
`id {{[-gn|--group --name]}}`
- Display the current primary group identity as a number:
`id -g`
`id {{[-g|--group]}}`
- Display an arbitrary user's ID (UID), group ID (GID) and groups to which they belong:

View File

@@ -10,19 +10,19 @@ source: https://github.com/tldr-pages/tldr.git
- Open a given serial port:
`sudo cu --line {{/dev/ttyXYZ}}`
`sudo cu {{[-l|--line]}} {{/dev/ttyXYZ}}`
- Open a given serial port with a given baud rate:
`sudo cu --line {{/dev/ttyXYZ}} --speed {{115200}}`
`sudo cu {{[-l|--line]}} {{/dev/ttyXYZ}} {{[-s|--speed]}} {{115200}}`
- Open a given serial port with a given baud rate and echo characters locally (half-duplex mode):
`sudo cu --line {{/dev/ttyXYZ}} --speed {{115200}} --halfduplex`
`sudo cu {{[-l|--line]}} {{/dev/ttyXYZ}} {{[-s|--speed]}} {{115200}} {{[-h|--halfduplex]}}`
- Open a given serial port with a given baud rate, parity, and no hardware or software flow control:
`sudo cu --line {{/dev/ttyXYZ}} --speed {{115200}} --parity={{even|odd|none}} --nortscts --nostop`
`sudo cu {{[-l|--line]}} {{/dev/ttyXYZ}} {{[-s|--speed]}} {{115200}} --parity={{even|odd|none}} {{[-f|--nortscts]}} --nostop`
- Exit the `cu` session when in connection:

View File

@@ -14,15 +14,15 @@ source: https://github.com/tldr-pages/tldr.git
- Show kernel error messages:
`sudo dmesg --level err`
`sudo dmesg {{[-l|--level]}} err`
- Show kernel messages and keep reading new ones, similar to `tail -f` (available in kernels 3.5.0 and newer):
`sudo dmesg -w`
`sudo dmesg {{[-w|--follow]}}`
- Show how much physical memory is available on this system:
`sudo dmesg | grep -i memory`
`sudo dmesg | grep {{[-i|--ignore-case]}} memory`
- Show kernel messages 1 page at a time:
@@ -30,12 +30,12 @@ source: https://github.com/tldr-pages/tldr.git
- Show kernel messages with a timestamp (available in kernels 3.5.0 and newer):
`sudo dmesg -T`
`sudo dmesg {{[-T|--ctime]}}`
- Show kernel messages in human-readable form (available in kernels 3.5.0 and newer):
`sudo dmesg -H`
`sudo dmesg {{[-H|--human]}}`
- Colorize output (available in kernels 3.5.0 and newer):
`sudo dmesg -L`
`sudo dmesg {{[-L|--color]}}`

View File

@@ -14,7 +14,7 @@ source: https://github.com/tldr-pages/tldr.git
- Power off the system (same as `poweroff`):
`halt --poweroff`
`halt {{[-p|--poweroff]}}`
- Reboot the system (same as `reboot`):
@@ -22,8 +22,8 @@ source: https://github.com/tldr-pages/tldr.git
- Halt immediately without contacting the system manager:
`halt --force`
`halt {{[-f|--force]}}`
- Write the wtmp shutdown entry without halting the system:
`halt --wtmp-only`
`halt {{[-w|--wtmp-only]}}`

View File

@@ -18,7 +18,7 @@ source: https://github.com/tldr-pages/tldr.git
- Display CPU statistics:
`iostat -c`
`iostat {{[-c|--compact]}}`
- Display disk statistics with disk names (including LVM):

View File

@@ -11,24 +11,24 @@ source: https://github.com/tldr-pages/tldr.git
- View chains, rules, packet/byte counters and line numbers for the filter table:
`sudo iptables --verbose --numeric --list --line-numbers`
`sudo iptables {{[-vnL --line-numbers|--verbose --numeric --list --line-numbers]}}`
- Set chain [P]olicy rule:
- Set chain policy rule:
`sudo iptables --policy {{chain}} {{rule}}`
`sudo iptables {{[-P|--policy]}} {{chain}} {{rule}}`
- [A]ppend rule to chain policy for IP:
- Append rule to chain policy for IP:
`sudo iptables --append {{chain}} --source {{ip}} --jump {{rule}}`
`sudo iptables {{[-A|--append]}} {{chain}} {{[-s|--source]}} {{ip}} {{[-j|--jump]}} {{rule}}`
- [A]ppend rule to chain policy for IP considering [p]rotocol and port:
- Append rule to chain policy for IP considering protocol and port:
`sudo iptables --append {{chain}} --source {{ip}} --protocol {{tcp|udp|icmp|...}} --dport {{port}} --jump {{rule}}`
`sudo iptables {{[-A|--append]}} {{chain}} {{[-s|--source]}} {{ip}} {{[-p|--protocol]}} {{tcp|udp|icmp|...}} --dport {{port}} {{[-j|--jump]}} {{rule}}`
- Add a NAT rule to translate all traffic from the `192.168.0.0/24` subnet to the host's public IP:
`sudo iptables --table {{nat}} --append {{POSTROUTING}} --source {{192.168.0.0/24}} --jump {{MASQUERADE}}`
`sudo iptables {{[-t|--table]}} {{nat}} {{[-A|--append]}} {{POSTROUTING}} {{[-s|--source]}} {{192.168.0.0/24}} {{[-j|--jump]}} {{MASQUERADE}}`
- [D]elete chain rule:
- Delete chain rule:
`sudo iptables --delete {{chain}} {{rule_line_number}}`
`sudo iptables {{[-D|--delete]}} {{chain}} {{rule_line_number}}`

View File

@@ -10,15 +10,15 @@ source: https://github.com/tldr-pages/tldr.git
- Open a given serial port:
`sudo minicom --device {{/dev/ttyXYZ}}`
`sudo minicom {{[-D|--device]}} {{/dev/ttyXYZ}}`
- Open a given serial port with a given baud rate:
`sudo minicom --device {{/dev/ttyXYZ}} --baudrate {{115200}}`
`sudo minicom {{[-D|--device]}} {{/dev/ttyXYZ}} {{[-b|--baudrate]}} {{115200}}`
- Enter the configuration menu before communicating with a given serial port:
`sudo minicom --device {{/dev/ttyXYZ}} --setup`
`sudo minicom {{[-D|--device]}} {{/dev/ttyXYZ}} {{[-s|--setup]}}`
- Exit minicom:

View File

@@ -14,7 +14,7 @@ source: https://github.com/tldr-pages/tldr.git
- Power off the system (same as `poweroff`):
`reboot --poweroff`
`reboot {{[-p|--poweroff]}}`
- Halt (terminates all processes and shuts down the CPU) the system (same as `halt`):
@@ -22,8 +22,8 @@ source: https://github.com/tldr-pages/tldr.git
- Reboot immediately without contacting the system manager:
`reboot --force`
`reboot {{[-f|--force]}}`
- Write the wtmp shutdown entry without rebooting the system:
`reboot --wtmp-only`
`reboot {{[-w|--wtmp-only]}}`

View File

@@ -15,4 +15,4 @@ source: https://github.com/tldr-pages/tldr.git
- Remove specific nested directories recursively:
`rmdir --parents {{path/to/directory1 path/to/directory2 ...}}`
`rmdir {{[-p|--parents]}} {{path/to/directory1 path/to/directory2 ...}}`

View File

@@ -14,11 +14,11 @@ source: https://github.com/tldr-pages/tldr.git
- [r]eboot immediately:
`shutdown -r now`
`shutdown {{[-r|--reboot]}} now`
- [r]eboot in 5 minutes:
`shutdown -r +{{5}} &`
`shutdown {{[-r|--reboot]}} +{{5}} &`
- Shutdown at 1:00 pm (Uses 24[h] clock):

View File

@@ -10,19 +10,19 @@ source: https://github.com/tldr-pages/tldr.git
- Start tracing a specific [p]rocess by its PID:
`strace -p {{pid}}`
`strace {{[-p|--attach]}} {{pid}}`
- Trace a [p]rocess and filt[e]r output by system call:
- Trace a [p]rocess and filter output by system call [e]xpression:
`strace -p {{pid}} -e {{system_call,system_call2,...}}`
`strace {{[-p|--attach]}} {{pid}} -e {{system_call,system_call2,...}}`
- Count time, calls, and errors for each system call and report a summary on program exit:
`strace -p {{pid}} -c`
`strace {{[-p|--attach]}} {{pid}} {{[-c|--summary-only]}}`
- Show the [T]ime spent in every system call and specify the maximum string [s]ize to print:
- Show the time spent in every system call and specify the maximum string size to print:
`strace -p {{pid}} -T -s {{32}}`
`strace {{[-p|--attach]}} {{pid}} {{[-T|--syscall-times]}} {{[-s|--string-limit]}} {{32}}`
- Start tracing a program by executing it:
@@ -32,6 +32,6 @@ source: https://github.com/tldr-pages/tldr.git
`strace -e trace=file {{program}}`
- Start tracing network operations of a program as well as all its [f]orked and child processes, saving the [o]utput to a file:
- Start tracing network operations of a program as well as all its forked and child processes, saving the output to a file:
`strace -f -e trace=network -o {{trace.txt}} {{program}}`
`strace {{[-f|--follow-forks]}} -e trace=network {{[-o|--output]}} {{trace.txt}} {{program}}`

View File

@@ -34,7 +34,7 @@ source: https://github.com/tldr-pages/tldr.git
- List all service/socket/automount units filtering by running/failed state:
`systemctl list-units --type={{service|socket|automount}} --state={{failed|running}}`
`systemctl list-units {{[-t|--type]}} {{service|socket|automount}} --state {{failed|running}}`
- Show the contents & absolute path of a unit file:

View File

@@ -14,7 +14,7 @@ source: https://github.com/tldr-pages/tldr.git
- Connect to a serial console with a specified baud rate:
`sudo picocom {{/dev/ttyXYZ}} --baud {{baud_rate}}`
`sudo picocom {{/dev/ttyXYZ}} {{[-b|--baud]}} {{baud_rate}}`
- Map special characters (e.g. `LF` to `CRLF`):

View File

@@ -22,4 +22,4 @@ source: https://github.com/tldr-pages/tldr.git
- Execute a command as another user:
`su - {{username}} -c "{{command}}"`
`su - {{username}} {{[-c|--command]}} "{{command}}"`

29
tldr/sunos/share Normal file
View File

@@ -0,0 +1,29 @@
---
syntax: markdown
tags: [tldr, sunos]
source: https://github.com/tldr-pages/tldr.git
---
# share
> Make local resource/filesystem available for mounting by remote systems.
> More information: <https://docs.oracle.com/cd/E36784_01/html/E36825/gntjt.html>.
- List all currently shared file systems:
`share`
- Share a directory with read/write access:
`share -F nfs -o rw {{/path/to/directory}}`
- Share a directory with read-only access:
`share -F nfs -o ro {{/path/to/directory}}`
- Share a directory with specific options (e.g., allow root access from a specific host):
`share -F nfs -o rw,root={{hostname}} {{/path/to/directory}}`
- Make sharing persistent by adding entries to `/etc/dfs/dfstab`:
`echo "share -F nfs -o rw {{/path/to/directory}}" >> /etc/dfs/dfstab`

View File

@@ -10,11 +10,11 @@ source: https://github.com/tldr-pages/tldr.git
- List available network interfaces:
`tcpdump -D`
`tcpdump {{[-D|--list-interfaces]}}`
- Capture the traffic of a specific interface:
`tcpdump -i {{eth0}}`
`sudo tcpdump {{[-i|--interface]}} {{eth0}}`
- Capture all TCP traffic showing contents (ASCII) in console:
@@ -26,7 +26,7 @@ source: https://github.com/tldr-pages/tldr.git
- Capture the traffic from a specific interface, source, destination and destination port:
`tcpdump -i {{eth0}} src {{192.168.1.1}} and dst {{192.168.1.2}} and dst port {{80}}`
`tcpdump {{[-i|--interface]} {{eth0}} src {{192.168.1.1}} and dst {{192.168.1.2}} and dst port {{80}}`
- Capture the traffic of a network:

View File

@@ -15,16 +15,16 @@ source: https://github.com/tldr-pages/tldr.git
- Display only unique lines:
`sort {{path/to/file}} | uniq -u`
`sort {{path/to/file}} | uniq {{[-u|--unique]}}`
- Display only duplicate lines:
`sort {{path/to/file}} | uniq -d`
`sort {{path/to/file}} | uniq {{[-d|--repeated]}}`
- Display number of occurrences of each line along with that line:
`sort {{path/to/file}} | uniq -c`
`sort {{path/to/file}} | uniq {{[-c|--count]}}`
- Display number of occurrences of each line, sorted by the most frequent:
`sort {{path/to/file}} | uniq -c | sort -nr`
`sort {{path/to/file}} | uniq {{[-c|--count]}} | sort {{[-nr|--numeric-sort --reverse]}}`

10
tldr/wc
View File

@@ -10,19 +10,19 @@ source: https://github.com/tldr-pages/tldr.git
- Count all lines in a file:
`wc --lines {{path/to/file}}`
`wc {{[-l|--lines]}} {{path/to/file}}`
- Count all words in a file:
`wc --words {{path/to/file}}`
`wc {{[-w|--words]}} {{path/to/file}}`
- Count all bytes in a file:
`wc --bytes {{path/to/file}}`
`wc {{[-c|--bytes]}} {{path/to/file}}`
- Count all characters in a file (taking multi-byte characters into account):
`wc --chars {{path/to/file}}`
`wc {{[-m|--chars]}} {{path/to/file}}`
- Count all lines, words and bytes from `stdin`:
@@ -30,4 +30,4 @@ source: https://github.com/tldr-pages/tldr.git
- Count the length of the longest line in number of characters:
`wc --max-line-length {{path/to/file}}`
`wc {{[-L|--max-line-length]}} {{path/to/file}}`

View File

@@ -19,11 +19,11 @@ source: https://github.com/tldr-pages/tldr.git
- Gzip all files with `.log` extension taking advantage of multiple threads (`-print0` uses a null character to split file names, and `-0` uses it as delimiter):
`find . -name '*.log' -print0 | xargs -0 -P {{4}} -n 1 gzip`
`find . -name '*.log' -print0 | xargs {{[-0|--null]}} {{[-P|--max-procs]}} {{4}} {{[-n|--max-args]}} 1 gzip`
- Execute the command once per argument:
`{{arguments_source}} | xargs -n1 {{command}}`
`{{arguments_source}} | xargs {{-n|--max-args}} 1 {{command}}`
- Execute the command once for each input line, replacing any occurrences of the placeholder (here marked as `_`) with the input line:
@@ -31,4 +31,4 @@ source: https://github.com/tldr-pages/tldr.git
- Parallel runs of up to `max-procs` processes at a time; the default is 1. If `max-procs` is 0, xargs will run as many processes as possible at a time:
`{{arguments_source}} | xargs -P {{max-procs}} {{command}}`
`{{arguments_source}} | xargs {{[-P|--max-procs]}} {{max-procs}} {{command}}`