hsianglee Personal Notes

website·Indexed 31 days ago

https://docs.hsianglee.cn/

A collection of personal technical notes and cheat sheets built with VitePress. It covers a wide range of common commands and configurations for tools and environments including Docker, Git, Nginx, MySQL, AutoHotkey, PowerShell, WSL, and various Linux distributions like CentOS, Ubuntu, and Debian, as well as guides for GitLab Runner, Jenkins, and GitHub Actions.

Tokens
26.2K
Snippets
188
Records
206
Agent score
48%

What's inside hsianglee Notes

  1. Install Docker using official scripts

    Docker can be installed on Linux systems using the following convenience scripts, including an option for Aliyun mirrors.
    # Standard installation with Aliyun mirror
    curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
    
    # Alternative installation script
    curl -sSL https://get.daocloud.io/docker | sh
  2. Manage WSL distributions using the wsl CLI

    Use the wsl command-line tool to install, list, export, import, and manage Linux distributions on Windows. This includes controlling the power state of distributions and setting default users.
    # Install WSL
    wsl --install
    
    # List installed distributions and their versions
    wsl -l -v
    
    # Set a specific distribution as the default
    wsl --set-default Ubuntu
    
    # Export a distribution to a tar file
    wsl --export Ubuntu f:\wsl\Ubuntu.tar
    
    # Unregister/Delete a distribution
    wsl --unregister Ubuntu
    
    # Import a distribution from a tar file to a new path
    wsl --import Ubuntu F:\wsl\ F:\wsl\Ubuntu.tar --version 2
    
    # Set the default login user for a distribution
    Ubuntu config --default-user lx/root
    
    # Start a specific distribution
    wsl -d Centos
    
    # Start a specific distribution as the root user
    wsl -d centos --user root
    
    # Terminate a specific distribution
    wsl -t centos
    
    # Shut down all running distributions
    wsl --shutdown
  3. Merge a feature branch into master using rebase

    To integrate changes from a feature branch (e.g., test) into the master branch while maintaining a linear history, use a rebase followed by a merge. This avoids the 'merge commit' and keeps the history serial rather than parallel.
    git checkout test
    git rebase master
    git checkout master
    git merge test
  4. Manage applications with Scoop CLI

    Scoop provides a set of commands to install, update, and manage software packages. Key operations include installing specific versions, holding updates to prevent a package from being upgraded, and managing software sources (buckets).
    # Installation and Removal
    scoop install <app>                     # Install an app
    scoop install <app>@<version>           # Install a specific version
    scoop uninstall <app>                   # Uninstall an app
    
    # Updates and Versioning
    scoop status                            # Check for available updates
    scoop update                            # Update Scoop itself
    scoop update <appName>                  # Update a specific app
    scoop reset <app>@<version>             # Switch to a specific installed version
    
    # App Control
    scoop hold <app>                        # Prevent an app from being updated
    scoop unhold <app>                      # Allow an app to be updated again
    
    # Information and Search
    scoop list                              # List installed apps
    scoop search <query>                     # Search for apps
    scoop info <app>                        # View app details
    scoop home <app>                        # Open app homepage in browser
    
    # Bucket (Repository) Management
    scoop bucket known                      # List all known buckets
    scoop bucket add <bucket>               # Add a new bucket
    
    # Maintenance
    scoop cache rm <app>                    # Remove app cache
  5. Install and use mkcert for local SSL certificates

    mkcert is used to create locally-trusted development certificates. The process involves downloading the binary, granting execution permissions, and moving it to the system path.
    # Download mkcert binary (v1.4.4 example)
    wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64
    # Grant execution permissions
    chmod +x mkcert
    # Move to system path
    sudo mv mkcert /usr/local/bin/
    
    # Install local CA
    mkcert -install
    
    # View CA root path
    mkcert -CAROOT
    
    # Generate certificate and key for a specific IP/Domain
    mkcert -cert-file bitwarden.pem -key-file bitwardenkey.pem 192.168.x.x
  6. Upgrade CentOS 8 to CentOS Stream

    Migrate a CentOS 8 installation to CentOS Stream by updating the repository URLs from the standard mirrorlist to the vault and installing the stream release package.
    # Update repo files to use vault.centos.org
    sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
    sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
    
    # Install stream release and sync distribution
    dnf install centos-release-stream -y
    dnf swap centos-{linux,stream}-repos -y
    dnf distro-sync -y
  7. Install incr auto-suggestions for Zsh

    Install the incr plugin to provide automatic command suggestions in Zsh. This involves downloading the plugin script, placing it in the Oh My Zsh plugins directory, and sourcing it in the .zshrc configuration file.
    wget http://mimosa-pudica.net/src/incr-0.2.zsh
    mkdir ~/.oh-my-zsh/plugins/incr
    mv incr-0.2.zsh ~/.oh-my-zsh/plugins/incr/incr.plugin.zsh
    
    echo 'source ~/.oh-my-zsh/plugins/incr/incr*.zsh' >> ~/.zshrc
    source ~/.zshrc
  8. Add Windows Terminal to Windows Right-Click Context Menu

    Use ContextMenuManager.NET to add shortcuts for opening Windows Terminal from the folder background. For Windows 11 25H2, the mshta method may be unavailable; use the PowerShell command instead for administrator access.
    # Standard User Access (via mshta)
    mshta vbscript:createobject("shell.application").shellexecute("C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\wt.exe","","","",1)(close)
    
    # Administrator Access (Windows 11 25H2 compatible)
    powershell -WindowStyle Hidden -NoProfile -Command "Start-Process wt -WorkingDirectory . -Verb RunAs"
  9. Upgrade OpenWrt firmware and restore configuration

    To upgrade OpenWrt firmware on x86/64 targets:

    1. Download the latest firmware image (e.g., generic-ext4-combined-efi.img.gz).
    2. Navigate to System -> Backup and Update and click Generate backup to save current data.
    3. Click Flash firmware and upload the downloaded image.
    4. After the update is complete, return to Backup and Update and click Upload backup to restore the previous configuration.
  10. Uninstall GitLab Runner from Linux

    To completely remove GitLab Runner, stop the service, disable automatic startup, uninstall the service, and clean up the configuration files and the dedicated user.
    # Stop and uninstall service
    gitlab-runner stop
    chkconfig gitlab-runner off
    gitlab-runner uninstall
    
    # Clean up files
    rm -rf /etc/gitlab-runner
    rm -rf /usr/local/bin/gitlab-runner
    rm -rf /usr/bin/gitlab-runner
    rm -rf /etc/sudoers.d/gitlab-runner
    
    # Remove user
    userdel -r gitlab-runner
  11. Change Ubuntu APT sources to Aliyun mirror

    To switch the Ubuntu package source to the Aliyun mirror, edit the sources configuration file, update the URLs, and refresh the package list.
    # 1. Edit the sources file
    vim /etc/apt/sources.list.d/ubuntu.sources
    # 2. Change the URLs to http://mirrors.aliyun.com/ubuntu/
    # 3. Update and upgrade packages
    apt update && apt upgrade -y
  12. Install and configure Starship prompt for Zsh

    Starship is a customizable shell prompt. To install it, run the installation script and add the initialization command to your ~/.zshrc file. Configuration is managed via a TOML file located at ~/.config/starship.toml.
    # Install Starship
    curl -sS https://starship.rs/install.sh | sh
    
    # Add to ~/.zshrc
    echo 'eval "$(starship init zsh)"' >> ~/.zshrc
    
    # Create config file
    touch ~/.config/starship.toml