commit 9a9fcfcacf4a2ea086ae2295db27a0a86b2bf848 Author: Grok Date: Sat Aug 9 13:22:24 2025 +0000 Initial commit of various cheatsheets diff --git a/git-cheatsheet.md b/git-cheatsheet.md new file mode 100644 index 0000000..ff54690 --- /dev/null +++ b/git-cheatsheet.md @@ -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 `: Clone an existing repository + +## Basic Snapshotting +- `git status`: Show the working tree status +- `git add `: 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 `: Create a new branch +- `git checkout `: Switch to a branch +- `git checkout -b `: Create and switch to a new branch +- `git merge `: Merge a branch into the current branch +- `git branch -d `: Delete a branch + +## Remote Repositories +- `git remote add `: Add a remote repository (e.g., origin) +- `git push `: Push changes to a remote branch +- `git pull `: 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 `: Show details of a commit + +## Undoing Changes +- `git reset --hard`: Reset to the last commit, discarding changes +- `git revert `: Create a new commit that undoes a previous commit +- `git checkout -- `: 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 \ No newline at end of file diff --git a/removing-files-from-git-history.md b/removing-files-from-git-history.md new file mode 100644 index 0000000..092749d --- /dev/null +++ b/removing-files-from-git-history.md @@ -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 -- + ``` + This lists commits involving the file. + +2. **Remove the File from History**: + ``` + git filter-repo --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 + ``` + +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 -- + ``` + 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] \ No newline at end of file diff --git a/stratis_cheatsheet.md b/stratis_cheatsheet.md new file mode 100644 index 0000000..ec49236 --- /dev/null +++ b/stratis_cheatsheet.md @@ -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 /dev/ [/dev/]` + - Example: `sudo stratis pool create mypool /dev/sdb` +- List pools: `sudo stratis pool list` +- Destroy pool: `sudo stratis pool destroy ` (unmount filesystems first) +- Add data device: `sudo stratis pool add-data /dev/` +- Initialize cache: `sudo stratis pool init-cache /dev/` +- Add cache device: `sudo stratis pool add-cache /dev/` + +## Filesystem Management +- Create filesystem: `sudo stratis filesystem create ` + - Example: `sudo stratis filesystem create mypool myfs` +- List filesystems: `sudo stratis filesystem list []` +- Destroy filesystem: `sudo stratis filesystem destroy ` +- Mount: Filesystems are at `/stratis//`. Use `sudo mount /stratis// /mnt/point` +- Unmount: `sudo umount /mnt/point` + +## Snapshot Management +- Create snapshot: `sudo stratis filesystem snapshot ` + - 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 ` + +## Encryption +Stratis supports encrypted pools (available in RHEL 9+ and confirmed for 10). +- Create encrypted pool: `sudo stratis key set --keyfile-path ` +- Then: `sudo stratis pool create --key-desc /dev/` +- Unlock pool: `sudo stratis pool unlock ` +- 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 []` +- 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. \ No newline at end of file diff --git a/vim_cheatsheet.md b/vim_cheatsheet.md new file mode 100644 index 0000000..9e39d49 --- /dev/null +++ b/vim_cheatsheet.md @@ -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! \ No newline at end of file