Initial commit of various cheatsheets

This commit is contained in:
Grok CLI
2025-08-09 13:22:24 +00:00
commit 53710f43e1
4 changed files with 229 additions and 0 deletions

51
git-cheatsheet.md Normal file
View File

@@ -0,0 +1,51 @@
# Git Cheatsheet
This is a quick reference for common Git commands.
## Configuration
- `git config --global user.name "Your Name"`: Set your username
- `git config --global user.email "your.email@example.com"`: Set your email
- `git config --list`: View configuration
## Creating Repositories
- `git init`: Initialize a new Git repository in the current directory
- `git clone <repository-url>`: Clone an existing repository
## Basic Snapshotting
- `git status`: Show the working tree status
- `git add <file>`: Add a file to the staging area
- `git add .`: Add all changes in the current directory to the staging area
- `git commit -m "commit message"`: Commit staged changes with a message
- `git commit -a -m "commit message"`: Commit all tracked changes with a message (skips staging)
## Branching and Merging
- `git branch`: List all branches
- `git branch <branch-name>`: Create a new branch
- `git checkout <branch-name>`: Switch to a branch
- `git checkout -b <branch-name>`: Create and switch to a new branch
- `git merge <branch-name>`: Merge a branch into the current branch
- `git branch -d <branch-name>`: Delete a branch
## Remote Repositories
- `git remote add <name> <url>`: Add a remote repository (e.g., origin)
- `git push <remote> <branch>`: Push changes to a remote branch
- `git pull <remote> <branch>`: Pull changes from a remote branch
- `git fetch`: Fetch changes from remote without merging
## Inspection and Comparison
- `git log`: Show commit history
- `git log --oneline`: Show commit history in one line per commit
- `git diff`: Show changes between commits, commit and working tree, etc.
- `git show <commit>`: Show details of a commit
## Undoing Changes
- `git reset --hard`: Reset to the last commit, discarding changes
- `git revert <commit>`: Create a new commit that undoes a previous commit
- `git checkout -- <file>`: Discard changes in a file
## Stashing
- `git stash`: Stash changes in a dirty working directory
- `git stash apply`: Apply stashed changes
- `git stash list`: List stashed changes
For more details, refer to the official Git documentation: https://git-scm.com/docs

View File

@@ -0,0 +1,50 @@
# Removing Files from Git History
This document outlines a secure, resource-efficient method to completely remove a file (and its traces) from a Git repository's history using `git-filter-repo`. This is useful for privacy-sensitive operations, such as removing accidentally committed secrets or sensitive data.
## Prerequisites
- Git installed.
- `git-filter-repo` installed (install via `sudo apt install git-filter-repo` on Debian-based systems if needed).
- Admin access to the repository and remote (e.g., Gitea).
## Steps
1. **Verify the File in History**:
```
cd /path/to/repo
git log -- <file-path>
```
This lists commits involving the file.
2. **Remove the File from History**:
```
git filter-repo --path <file-path> --invert-paths
```
- `--invert-paths` excludes the specified path from all commits.
- This rewrites history and removes remotes as a safety measure.
3. **Re-add Remote (if removed)**:
```
git remote add origin <remote-url>
```
4. **Force Push Changes**:
```
git push origin --force --all
```
- Use `--force` to overwrite remote history. Caution: This can break shared repos.
5. **Verify Removal**:
```
git log -- <file-path>
```
No output means the file is gone.
## Security Notes
- Always back up your repo before rewriting history.
- Use secure remotes (e.g., SSH).
- Avoid if the repo is public or has multiple collaborators without coordination.
- Follow least privilege: Run without sudo unless necessary.
This method is lightweight and respects resource constraints (low RAM/CPU usage).
Last updated: [Current Date]

64
stratis_cheatsheet.md Normal file
View File

@@ -0,0 +1,64 @@
# Stratis Cheatsheet for RHEL 10
This cheatsheet covers common Stratis commands for storage management on Red Hat Enterprise Linux 10, based on official documentation and recent guides (e.g., RHEL 9/10 RHCSA resources from 2025). Stratis simplifies local storage with pools, thin provisioning, snapshots, and encryption. It builds on LVM and XFS.
**Prerequisites**: Ensure block devices are available and not in use. Stratis requires stratisd service running.
## Installation
- Install packages: `sudo dnf install stratisd stratis-cli`
- Enable and start service: `sudo systemctl enable --now stratisd`
- Verify: `sudo systemctl status stratisd`
## Pool Management
- Create a pool: `sudo stratis pool create <pool_name> /dev/<blockdev> [/dev/<another>]`
- Example: `sudo stratis pool create mypool /dev/sdb`
- List pools: `sudo stratis pool list`
- Destroy pool: `sudo stratis pool destroy <pool_name>` (unmount filesystems first)
- Add data device: `sudo stratis pool add-data <pool_name> /dev/<blockdev>`
- Initialize cache: `sudo stratis pool init-cache <pool_name> /dev/<cachedev>`
- Add cache device: `sudo stratis pool add-cache <pool_name> /dev/<cachedev>`
## Filesystem Management
- Create filesystem: `sudo stratis filesystem create <pool_name> <fs_name>`
- Example: `sudo stratis filesystem create mypool myfs`
- List filesystems: `sudo stratis filesystem list [<pool_name>]`
- Destroy filesystem: `sudo stratis filesystem destroy <pool_name> <fs_name>`
- Mount: Filesystems are at `/stratis/<pool_name>/<fs_name>`. Use `sudo mount /stratis/<pool_name>/<fs_name> /mnt/point`
- Unmount: `sudo umount /mnt/point`
## Snapshot Management
- Create snapshot: `sudo stratis filesystem snapshot <pool_name> <source_fs> <snapshot_name>`
- Example: `sudo stratis filesystem snapshot mypool myfs mysnapshot`
- List snapshots: Included in `stratis filesystem list`
- Revert to snapshot: Destroy current FS and rename snapshot, or use as needed (snapshots are writable)
- Destroy snapshot: `sudo stratis filesystem destroy <pool_name> <snapshot_name>`
## Encryption
Stratis supports encrypted pools (available in RHEL 9+ and confirmed for 10).
- Create encrypted pool: `sudo stratis key set --keyfile-path <keyfile> <key_desc>`
- Then: `sudo stratis pool create --key-desc <key_desc> <pool_name> /dev/<blockdev>`
- Unlock pool: `sudo stratis pool unlock <key_desc>`
- List keys: `sudo stratis key list`
- For TPM: Use `--capture-key` or specific options for binding.
## Monitoring and Status
- List block devices: `sudo stratis blockdev list [<pool_name>]`
- Daemon rediscover: `sudo stratis daemon rediscover`
- Version: `sudo stratis daemon version`
- Check service: `sudo systemctl status stratisd`
- Debug: `sudo journalctl -u stratisd`
## Advanced Features
- Thin provisioning: Enabled by default; overprovision with care (pools can grow dynamically).
- Expand pool: Add devices with `add-data` or `add-cache`.
- Rename pool: Not directly supported; export/import or recreate.
- Integration with VDO: Can be used underlying, but Stratis manages on top.
## Tips and Best Practices
- Always back up data before destructive operations.
- Monitor pool usage: Use `stratis pool list` for free space.
- For RHEL 10 specifics: Commands are consistent with RHEL 9; check `man stratis` for updates.
- Resources: Red Hat Documentation (Chapter on Stratis in Managing File Systems), stratis-storage.github.io.
- Common error: If pool not found, run `stratis daemon rediscover`.
For more details, refer to `man stratis` or Red Hat's official docs.

64
vim_cheatsheet.md Normal file
View File

@@ -0,0 +1,64 @@
# Vim Cheatsheet
This is a quick reference guide for common Vim commands. Vim has several modes: Normal (default), Insert, Visual, and Command-line.
## Modes
- **Normal Mode**: Default mode for navigation and commands (press `Esc` to return).
- **Insert Mode**: For typing text (enter with `i`, `a`, etc.).
- **Visual Mode**: For selecting text (enter with `v`, `V`, or `Ctrl-v`).
- **Command Mode**: For extended commands (enter with `:` from Normal mode).
## Basic Navigation (Normal Mode)
- `h` / `j` / `k` / `l`: Move left/down/up/right.
- `w` / `b`: Jump to next/previous word.
- `0` / `$`: Start/end of line.
- `gg` / `G`: Top/bottom of file.
- `Ctrl-f` / `Ctrl-b`: Page down/up.
- `{number}G`: Go to line {number}.
## Editing Commands (Normal Mode)
- `i`: Insert before cursor.
- `a`: Append after cursor.
- `o` / `O`: New line below/above.
- `x`: Delete character under cursor.
- `dd`: Delete current line.
- `yy`: Yank (copy) current line.
- `p` / `P`: Paste after/before cursor.
- `u`: Undo last change.
- `Ctrl-r`: Redo.
- `.`: Repeat last command.
## Visual Mode
- `v`: Start visual selection (character-wise).
- `V`: Start visual selection (line-wise).
- `Ctrl-v`: Start visual block selection.
- Use navigation to select, then apply commands like `d` (delete), `y` (yank).
## Saving and Quitting (Command Mode)
- `:w`: Save file.
- `:q`: Quit (if no changes or saved).
- `:wq` or `ZZ`: Save and quit.
- `:q!`: Quit without saving.
- `:wqa`: Save and quit all.
## Search and Replace
- `/pattern`: Search forward for pattern.
- `?pattern`: Search backward.
- `n` / `N`: Next/previous match.
- `:%s/old/new/g`: Replace all occurrences of 'old' with 'new' in file.
- `:s/old/new/`: Replace in current line.
## Other Useful Commands
- `:set number`: Show line numbers.
- `:set nonumber`: Hide line numbers.
- `:help {topic}`: Open help for topic.
- `Ctrl-w v` / `Ctrl-w s`: Split window vertically/horizontally.
- `Ctrl-w w`: Switch between windows.
## Tips
- Use counts: e.g., `5dd` deletes 5 lines.
- Combine motions: e.g., `dw` deletes to end of word.
- Record macros: `q{letter}` to start, `q` to stop, `@{letter}` to replay.
- Vim is highly customizable via `.vimrc`.
For more, type `:help` in Vim!