<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on Chen Kai Blog</title><link>https://www.chenk.top/en/tags/linux/</link><description>Recent content in Linux on Chen Kai Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 28 Jun 2023 09:00:00 +0000</lastBuildDate><atom:link href="https://www.chenk.top/en/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>LAMP Stack on Alibaba Cloud ECS: From Fresh Instance to Production-Ready Web Server</title><link>https://www.chenk.top/en/standalone/lamp-on-ecs/</link><pubDate>Wed, 28 Jun 2023 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/lamp-on-ecs/</guid><description>&lt;p>You have a fresh ECS instance and SSH access. Your goal is to run a public website with Apache, PHP, and MySQL. Three common issues often trip up beginners:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Network reachability&lt;/strong> — packets are silently dropped by the cloud security group, the OS firewall, or the listening socket, and the symptom is always the same: nothing happens.&lt;/li>
&lt;li>&lt;strong>Service wiring&lt;/strong> — Apache, PHP, and MySQL are separate processes that need to find each other through file extensions, Unix sockets, and TCP ports. Each interface has its own way to fail.&lt;/li>
&lt;li>&lt;strong>Identity and permissions&lt;/strong> — Apache runs as &lt;code>www-data&lt;/code>, MySQL runs as &lt;code>mysql&lt;/code>, files are owned by &lt;code>root&lt;/code> after &lt;code>wget&lt;/code>. The wrong combination produces 403, &amp;ldquo;Access denied&amp;rdquo;, or &lt;code>chmod 777&lt;/code> desperation.&lt;/li>
&lt;/ol>
&lt;p>This guide covers these issues in the order you&amp;rsquo;ll encounter them on day one and continues with topics that arise later, such as TLS, virtual hosts, backups, source compilation, and when to stop running everything on a single box.&lt;/p></description></item><item><title>Docker and Containers (1): Why Containers — The Problem VMs Didn't Solve</title><link>https://www.chenk.top/en/docker-containers/01-why-containers/</link><pubDate>Fri, 16 Jun 2023 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/docker-containers/01-why-containers/</guid><description>&lt;p>Every developer has heard the phrase &amp;ldquo;it works on my machine.&amp;rdquo; Virtual machines were supposed to fix that, and they did — at the cost of gigabytes of RAM, minutes of boot time, and an entire duplicate operating system per application. Containers asked a different question: what if we could isolate applications without duplicating the kernel?&lt;/p>
&lt;hr>
&lt;h2 id="the-actual-problem" class="heading-anchor">The Actual Problem&lt;a href="#the-actual-problem" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;p>Consider deploying a Python web application. You need Python 3.11, specific pip packages, a particular version of libssl, and some system-level configuration. Your colleague&amp;rsquo;s app needs Python 3.9 and a conflicting libssl version. The staging server runs Ubuntu 20.04 while production runs Amazon Linux 2.&lt;/p></description></item><item><title>Operating System Fundamentals: A Deep Dive</title><link>https://www.chenk.top/en/standalone/operating-system-fundamentals-deep-dive/</link><pubDate>Thu, 07 Apr 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/operating-system-fundamentals-deep-dive/</guid><description>&lt;p>Open a terminal and type &lt;code>cat hello.txt&lt;/code>. The instant you press Enter, at least seven layers of machinery wake up: bash parses the line, fork+execve launches the cat process, the kernel hands it a virtual address space, cat issues a &lt;code>read()&lt;/code> syscall, the CPU traps into kernel mode, VFS dispatches to ext4, the block layer queues an NVMe request, the SSD DMA-writes the bytes back, an interrupt wakes cat, the bytes are copied through the page cache into the user buffer, and finally something appears on your screen.&lt;/p></description></item><item><title>Linux (9): Vim Essentials</title><link>https://www.chenk.top/en/linux/09-vim-essentials/</link><pubDate>Sat, 02 Apr 2022 10:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/09-vim-essentials/</guid><description>&lt;p>Most people quit Vim because they try to memorize shortcuts. That&amp;rsquo;s the wrong approach. Vim is a &lt;em>small language&lt;/em>: learn the grammar — &lt;strong>operator + motion&lt;/strong> — and you can express any edit without ever opening a cheat sheet. This guide covers the 80% of Vim you&amp;rsquo;ll use daily and shows how the remaining 20% naturally follows from the same basic rules.&lt;/p>
&lt;hr>
&lt;h2 id="what-you-will-learn" class="heading-anchor">What You Will Learn&lt;a href="#what-you-will-learn" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;ul>
&lt;li>The single core idea: &lt;strong>modes&lt;/strong> plus &lt;strong>composable operations&lt;/strong> (operator + motion)&lt;/li>
&lt;li>The handful of motions, text objects, and operators that cover almost everything&lt;/li>
&lt;li>File operations, search &amp;amp; replace, macros, marks, registers&lt;/li>
&lt;li>Buffers vs windows vs tabs — the mental model people most often get wrong&lt;/li>
&lt;li>A minimal &lt;code>.vimrc&lt;/code> and a one-week deliberate-practice plan to build muscle memory&lt;/li>
&lt;/ul>
&lt;h2 id="prerequisites" class="heading-anchor">Prerequisites&lt;a href="#prerequisites" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;ul>
&lt;li>Any terminal (Vim ships with virtually every Unix-like system)&lt;/li>
&lt;li>A willingness to feel slow for about a week&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="the-core-idea--modes-plus-a-tiny-grammar" class="heading-anchor">The core idea — modes plus a tiny grammar&lt;a href="#the-core-idea--modes-plus-a-tiny-grammar" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/standalone/vim-essentials/fig1_mode_state_diagram.png" alt="The Four Modes of Vim" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p></description></item><item><title>Linux (8): Pipelines and File Operations — Composing Tools into Data Flows</title><link>https://www.chenk.top/en/linux/pipelines/</link><pubDate>Sat, 02 Apr 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/pipelines/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/pipelines/illustration_1.png" alt="Linux (8): Pipelines and File Operations: Composing Tools into Data Flows — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>The biggest productivity boost on Linux isn&amp;rsquo;t memorizing more commands. It&amp;rsquo;s learning to &lt;strong>compose small tools&lt;/strong> into clean data flows. The pipe operator &lt;code>|&lt;/code> is the embodiment of the Unix philosophy: each tool does one thing and does it well (&lt;code>grep&lt;/code> only filters, &lt;code>awk&lt;/code> only extracts fields, &lt;code>sort&lt;/code> only sorts), and you chain them into a pipeline that is readable, debuggable, and obvious to maintain. This article starts from the data-flow model — &lt;code>stdin&lt;/code>, &lt;code>stdout&lt;/code>, &lt;code>stderr&lt;/code> and the file descriptors behind them — then walks through every common redirection form (&lt;code>&amp;gt;&lt;/code>, &lt;code>&amp;gt;&amp;gt;&lt;/code>, &lt;code>&amp;lt;&lt;/code>, &lt;code>2&amp;gt;&lt;/code>, &lt;code>2&amp;gt;&amp;amp;1&lt;/code>, &lt;code>&amp;amp;&amp;gt;&lt;/code>), builds up the text-processing toolchain (&lt;code>grep&lt;/code>, &lt;code>awk&lt;/code>, &lt;code>sed&lt;/code>, &lt;code>cut&lt;/code>, &lt;code>tr&lt;/code>, &lt;code>sort&lt;/code>, &lt;code>uniq&lt;/code>, &lt;code>xargs&lt;/code>, &lt;code>tee&lt;/code>), and ends with two patterns most introductions skip: named pipes (FIFOs) and process substitution. By the end you should be able to replace many &amp;ldquo;I need to write a script&amp;rdquo; tasks with one or two readable command lines, and read other people&amp;rsquo;s one-liners without squinting.&lt;/p></description></item><item><title>Linux (7): Process and Resource Management: From `top` to cgroups</title><link>https://www.chenk.top/en/linux/process-resource-management/</link><pubDate>Sun, 20 Mar 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/process-resource-management/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/process-resource-management/illustration_1.png" alt="Linux (7): Process and Resource Management: From top to cgroups — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>The job of a Linux operator is rarely &amp;ldquo;memorise more commands&amp;rdquo;. It is to take a fuzzy symptom — &lt;em>the site feels slow, the API timed out, the box is unresponsive&lt;/em> — and quickly &lt;strong>map it to the right axis&lt;/strong>: is the CPU saturated, is memory being eaten by cache (which is fine) or by a runaway process (which is not), is the disk queue full, is some socket leaking? Once the axis is named, the tool follows almost mechanically.&lt;/p></description></item><item><title>Linux (6): Service Management — systemd, systemctl, and journald</title><link>https://www.chenk.top/en/linux/service-management/</link><pubDate>Mon, 07 Mar 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/service-management/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/service-management/illustration_1.png" alt="Linux (6): Service Management: systemd, systemctl, and journald — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>A &amp;ldquo;service&amp;rdquo; on Linux is a long-running background process whose
job is to be there when something needs it: synchronise the clock,
listen for SSH connections, accept HTTP requests, run a backup at 3 AM.
You almost never start one of these by hand. Something has to start
them at boot, restart them when they crash, capture their logs, decide
what depends on what, and shut everything down cleanly when the machine
powers off. On every modern distribution that something is
&lt;strong>systemd&lt;/strong>.&lt;/p></description></item><item><title>Linux (5): User Management — Users, Groups, sudo, and Security</title><link>https://www.chenk.top/en/linux/user-management/</link><pubDate>Tue, 22 Feb 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/user-management/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/user-management/illustration_1.png" alt="Linux (5): User Management: Users, Groups, sudo, and Security — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>If you only ever ran &lt;code>useradd&lt;/code> and &lt;code>passwd&lt;/code> on a single laptop, you can probably get away without thinking about any of this. The moment more than one human (or more than one service) shares a host, &amp;ldquo;user management&amp;rdquo; stops being paperwork and starts being the security model: it decides who can log in, which UID owns the files a process writes, which commands &lt;code>sudo&lt;/code> will lift to root, and how long a stolen password remains useful.&lt;/p></description></item><item><title>Linux (4): Package Management — apt, dnf, pacman, and Building from Source</title><link>https://www.chenk.top/en/linux/package-management/</link><pubDate>Wed, 09 Feb 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/package-management/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/package-management/illustration_1.png" alt="Linux (4): Package Management: apt, dnf, pacman, and Building from Source — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>Most people learn package management as three commands: &lt;code>install&lt;/code>, &lt;code>remove&lt;/code>, &lt;code>upgrade&lt;/code>. That works until something goes wrong - a dependency conflict, an upgrade that won&amp;rsquo;t apply, a kernel that doesn&amp;rsquo;t boot, a mirror that times out from inside China. At that point you need a model of what is actually happening: what a &lt;em>package&lt;/em> contains, what the &lt;em>manager&lt;/em> is solving for, where it stores state, and how the difference between Debian&amp;rsquo;s &lt;code>apt/dpkg&lt;/code> and Red Hat&amp;rsquo;s &lt;code>dnf/rpm&lt;/code> shows up at 2 a.m. on a production box.&lt;/p></description></item><item><title>Linux (3): Disk Management — Partitions, Filesystems, LVM, and the Mount Stack</title><link>https://www.chenk.top/en/linux/disk-management/</link><pubDate>Thu, 27 Jan 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/disk-management/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/disk-management/illustration_1.png" alt="Linux (3): Disk Management: Partitions, Filesystems, LVM, and the Mount Stack — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>Disk problems in production almost never have a one-line fix. You are
usually navigating a layered stack: the &lt;strong>block device&lt;/strong> (a physical
or virtual disk), the &lt;strong>partition table&lt;/strong> (MBR or GPT), an optional
&lt;strong>LVM&lt;/strong> layer that decouples filesystems from disks, the
&lt;strong>filesystem driver&lt;/strong> (ext4, xfs, btrfs) that gives meaning to the
raw bytes, and finally the &lt;strong>mount point&lt;/strong> in the directory tree that
applications actually open files through. Most outages I have seen
become tractable the moment you can name which layer is misbehaving.&lt;/p></description></item><item><title>Linux (2): File Permissions — rwx, chmod, chown, and Beyond</title><link>https://www.chenk.top/en/linux/file-permissions/</link><pubDate>Fri, 14 Jan 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/file-permissions/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/file-permissions/illustration_1.png" alt="Linux (2): File Permissions: rwx, chmod, chown, and Beyond — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>File permissions look elementary — &lt;code>chmod 755&lt;/code>, done — but they remain one of the top causes of production incidents I see: a service won&amp;rsquo;t start, a deploy script silently does nothing, Nginx returns &lt;code>403&lt;/code>, a shared directory leaks, or &lt;code>rm&lt;/code> refuses on a file that &amp;ldquo;should&amp;rdquo; be removable. Memorising magic numbers does not get you out of any of these. What does is understanding three things at the same time:&lt;/p></description></item><item><title>Linux (1): Basics — Core Concepts and Essential Commands</title><link>https://www.chenk.top/en/linux/basics/</link><pubDate>Sat, 01 Jan 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/linux/basics/</guid><description>&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/linux/basics/illustration_1.png" alt="Linux (1): Basics: Core Concepts and Essential Commands — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;p>The difficulty with Linux rarely lies in the commands themselves. The hard part is having a clear &lt;em>map&lt;/em> of the system: why it dominates servers, what multi-user and per-file permissions offer, what changes when switching between Debian and Red Hat lineages, and what to do in the first ten minutes after an SSH prompt opens. This post is the &lt;strong>entry guide&lt;/strong> for the entire Linux series. It first builds the mental model — philosophy, distributions, the FHS tree — and then walks you through the commands you will use ten times an hour: &lt;code>cd ls pwd&lt;/code>, &lt;code>cp mv rm mkdir&lt;/code>, &lt;code>cat less head tail&lt;/code>, &lt;code>find grep&lt;/code>, plus pipelines, redirection, SSH, and a quick taste of permissions and processes. Each topic is intentionally &lt;strong>kept short&lt;/strong>; deeper details are in the dedicated articles (File Permissions, Disk Management, User Management, Service Management, Process Management, Package Management, Advanced File Operations).&lt;/p></description></item></channel></rss>