LuoJia's Technical Blog
website·Indexed 30 days ago
https://blog.luojia.workA collection of technical guides and tutorials covering Linux and macOS command-line efficiency, shell scripting (sed, awk, grep), network tools (curl, wget, OpenSSH), containerization with Docker and Vagrant, and development workflows involving Node.js, VSCode, and Unity.
What's inside LuoJia Blog
- FFmpeg is a cross-platform open-source multimedia framework consisting of two main parts: command-line applications for end-users and underlying libraries for developers.
Overview of VS Code Neovim extension
The VS Code Neovim extension (
asvetliakov.vscode-neovim) differs from simulation plugins likevscode-vimby embedding a native Neovim instance as a backend. This allows for nearly 100% compatibility with Vim/Neovim operations, including support forinit.vim/init.luaconfigurations and Neovim-specific plugins, while maintaining VS Code's native features like LSP diagnostics, auto-completion, and debugging.Key benefits include:
- Full coverage of native Neovim functions and complex commands (e.g.,
:normal!,@macros). - Seamless Insert mode handled by VS Code (supporting native snippets and auto-completion).
- Better performance by avoiding key-interception latency common in simulators.
- Full coverage of native Neovim functions and complex commands (e.g.,
Overview of OpenSSL and SSL/TLS
OpenSSL is an open-source toolkit and command-line suite providing end-to-end secure communication. It implements the SSL (Secure Sockets Layer) and TLS (Transport Layer Security) protocols to ensure:
- Data Encryption: Using symmetric keys to prevent interception.
- Identity Authentication: Using digital certificates to prevent Man-in-the-Middle (MITM) attacks.
- Integrity Verification: Using hash algorithms to ensure data has not been tampered with.
Modern implementations primarily use TLS 1.2 and 1.3.
Overview of You-Get command-line downloader
You-Get is a lightweight, cross-platform command-line download tool designed to extract videos, audio, images, and subtitles/danmaku from major domestic and international platforms such as Bilibili, YouTube, Douyin, and Tencent Video.Overview of Vagrant for VirtualBox
Vagrant is a virtualization environment management tool developed in Ruby. Its primary purpose is to provide a "standardized development environment" by defining virtual machine parameters—such as system images, network settings, and hardware resources—within a configuration file called theVagrantfile.Understand AWK core syntax and execution flow
AWK operates on a "PATTERN { ACTION STATEMENTS }" framework.
- PATTERN: Determines when the action is triggered (e.g., matching a specific line, field, or range). If omitted, the action is executed for every line.
- ACTION: A sequence of statements (separated by semicolons) defining what to do when a pattern matches.
- Execution Flow: AWK reads input line by line; if a line matches the pattern, the corresponding action is executed.
Understand LVM Architecture (PV, VG, LV)
LVM (Logical Volume Manager) allows for dynamic disk space management by abstracting physical storage into a flexible pool. It consists of three layers:
- Physical Volume (PV): The smallest storage unit. It is a physical partition (e.g.,
/dev/sdb1) or an entire disk initialized with LVM metadata. - Volume Group (VG): A storage pool created by combining one or more PVs. A PV can only belong to one VG.
- Logical Volume (LV): The final usable unit carved out of a VG. LVs can be formatted with a file system (e.g., ext4, xfs) and mounted as directories. They support dynamic expansion and reduction.
- Physical Volume (PV): The smallest storage unit. It is a physical partition (e.g.,
Use the until loop for reverse logic repetition
Theuntilloop in Shell scripts executes a block of commands repeatedly as long as the test command returns a non-zero value (condition is false). The loop terminates immediately once the test command returns 0 (condition becomes true). This is the opposite of awhileloop, which runs as long as the condition is true.Manually install OpenSSL 3.4.0 on MacOS M1/M2 (Monterey)
When Homebrew fails to upgrade OpenSSL due to dependency conflicts or repository issues on M1/M2 Macs running MacOS Monterey, a manual compilation from source is required. This process ensures the correct architecture (arm64) is used and avoids system compatibility problems.
Prerequisites
- Hardware: M1/M2 chip (arm64).
- OS: MacOS Monterey (12.x).
- Tools:
wget(orcurl) andmake. Ifmakeis missing, install Xcode Command Line Tools viaxcode-select --install.
Installation Steps
- Remove existing Homebrew OpenSSL: Prevent path conflicts by forcing removal of existing versions.
- Download Source: Fetch the stable source package from the official OpenSSL website.
- Configure: Use the
darwin64-arm64-cctarget for M1/M2 chips and specify a prefix path (e.g.,/opt/homebrew/Cellar/openssl@3/3.4.0) to avoid permission issues in/usr/local. - Compile: Run
makewith parallel jobs (e.g.,-j4or-j8) to speed up the process. - Install: Use
sudo make installwith specific manual directory (MANDIR) and suffix (MANSUFFIX) settings. - Path Configuration: Manually move the binary, include, lib, and ssl directories to the prefix path and create a symbolic link to
/usr/local/bin/opensslso the system can locate the command.
# 1. Uninstall old Homebrew versions brew uninstall --force openssl openssl@3 # 2. Download and extract wget https://www.openssl.org/source/openssl-3.4.0.tar.gz tar -xvf openssl-3.4.0.tar.gz cd openssl-3.4.0 # 3. Configure for M1/M2 (arm64) ./Configure darwin64-arm64-cc --prefix=/opt/homebrew/Cellar/openssl@3/3.4.0 # 4. Compile and Install make -j4 sudo make install MANDIR=/opt/homebrew/Cellar/openssl@3/3.4.0/share/man MANSUFFIX=ssl # 5. Organize files and create symlink sudo mkdir -p /opt/homebrew/Cellar/openssl@3/3.4.0/bin sudo mv ./apps/openssl /opt/homebrew/Cellar/openssl@3/3.4.0/bin/ sudo mv ./include /opt/homebrew/Cellar/openssl@3/3.4.0/ sudo mv ./lib /opt/homebrew/Cellar/openssl@3/3.4.0/ sudo mv ./ssl /opt/homebrew/Cellar/openssl@3/3.4.0/ sudo rm -f /usr/local/bin/openssl sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/bin/openssl /usr/local/bin/opensslInstall CloudWatch Agent on Ubuntu
Install the CloudWatch Agent using the official AWS S3 deb package for amd64 architecture. If dependency errors occur during installation, useapt -f installto resolve them.# Download the latest CloudWatch Agent for Ubuntu amd64 wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb # Install the package sudo dpkg -i -E ./amazon-cloudwatch-agent.deb # Fix unmet dependencies if they occur sudo apt update && sudo apt -f install -yOpenSSL Component Architecture
OpenSSL consists of three primary components:
- libcrypto: The core library implementing symmetric, asymmetric, and hashing algorithms. It provides C language interfaces for developers.
- libssl: The protocol library built on top of libcrypto. It handles SSL/TLS handshakes, session management, and certificate verification.
- openssl CLI: The command-line tool used by administrators to generate keys, sign certificates, encrypt files, and calculate hashes.
Basic gawk command syntax and usage
gawk (GNU awk) is a lightweight programming language used for structured text processing, such as extracting columns, performing calculations, and generating reports. The basic command structure is:gawk [options] 'program' file(s). If no file is specified, gawk reads from standard input (STDIN).gawk [options] 'program' file(s)