<?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/linux/</link><description>Recent content in Linux on Chen Kai Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 02 Apr 2022 09:00:00 +0000</lastBuildDate><atom:link href="https://www.chenk.top/en/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Linux 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>The biggest productivity jump on Linux is not memorising more commands. It is 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 &amp;ndash; &lt;code>stdin&lt;/code>, &lt;code>stdout&lt;/code>, &lt;code>stderr&lt;/code> and the file descriptors behind them &amp;ndash; 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 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>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 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>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 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>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 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>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 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>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 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>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 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>The &amp;ldquo;difficulty&amp;rdquo; of Linux rarely lives in the commands themselves. The hard part is whether you have a clear &lt;em>map&lt;/em> of the system: why it dominates servers, what multi-user and per-file permissions actually buy you, what changes when you switch 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 &amp;ndash; philosophy, distributions, the FHS tree &amp;ndash; 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>; depth lives 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>