<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Larvitz Blog - Unix</title><link href="https://hofstede.it/" rel="alternate"/><link href="https://hofstede.it/feeds/unix.atom.xml" rel="self"/><id>https://hofstede.it/</id><updated>2026-03-26T00:00:00+01:00</updated><subtitle>FreeBSD, Linux, all things cleanly engineered</subtitle><entry><title>Shell Tricks That Actually Make Life Easier (And Save Your Sanity)</title><link href="https://hofstede.it/shell-tricks-that-actually-make-life-easier-and-save-your-sanity/" rel="alternate"/><published>2026-03-26T00:00:00+01:00</published><updated>2026-03-26T00:00:00+01:00</updated><author><name>Larvitz</name></author><id>tag:blog.hofstede.it,2026-03-26:/shell-tricks-that-actually-make-life-easier-and-save-your-sanity/</id><summary type="html">&lt;p&gt;Watch someone backspace 40 characters instead of pressing &lt;span class="caps"&gt;CTRL&lt;/span&gt;+W, and you&amp;#8217;ll understand why this list exists. A collection of shell tricks-grouped by what works everywhere and what&amp;#8217;s Bash/Zsh-specific-that save keystrokes and&amp;nbsp;time.&lt;/p&gt;</summary><content type="html">&lt;p&gt;There is a distinct, visceral kind of pain in watching an otherwise brilliant engineer hold down the Backspace key for six continuous seconds to fix a typo at the beginning of a&amp;nbsp;line. &lt;/p&gt;
&lt;p&gt;We’ve all been there. We&amp;nbsp;learn &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;,&amp;nbsp;and &lt;code&gt;grep&lt;/code&gt;, and then we sort of&amp;#8230; stop. The terminal becomes a place we live in-but we rarely bother to arrange the furniture. We accept that certain tasks take forty keystrokes, completely unaware that the shell authors solved our exact frustration sometime in&amp;nbsp;1989.&lt;/p&gt;
&lt;p&gt;Here are some tricks that aren&amp;#8217;t exactly secret, but aren&amp;#8217;t always taught either. To keep the peace in our extended Unix family, I’ve split these into two camps: the universal tricks that work on almost any &lt;span class="caps"&gt;POSIX&lt;/span&gt;-ish shell&amp;nbsp;(like &lt;code&gt;sh&lt;/code&gt; on FreeBSD&amp;nbsp;or &lt;code&gt;ksh&lt;/code&gt; on OpenBSD), and the quality-of-life additions specific to interactive shells like Bash or&amp;nbsp;Zsh.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-works-almost-everywhere-club"&gt;The &amp;#8220;Works (Almost) Everywhere&amp;#8221;&amp;nbsp;Club&lt;/h2&gt;
&lt;p&gt;These tricks rely on standard terminal line disciplines, generic Bourne shell behaviors, or &lt;span class="caps"&gt;POSIX&lt;/span&gt; features. If you &lt;span class="caps"&gt;SSH&lt;/span&gt; into an embedded router from 2009, a fresh OpenBSD box, or a minimal Alpine container, these will still have your&amp;nbsp;back.&lt;/p&gt;
&lt;h3 id="the-backspace-replacements"&gt;The Backspace&amp;nbsp;Replacements&lt;/h3&gt;
&lt;p&gt;Why shuffle character-by-character when you can teleport? These are standard Emacs-style line-editing bindings (via Readline or similar), enabled by default in most modern&amp;nbsp;shells.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + W&lt;/code&gt;&lt;/strong&gt;: You&amp;#8217;re&amp;nbsp;typing &lt;code&gt;/var/log/nginx/&lt;/code&gt; but you actually&amp;nbsp;meant &lt;code&gt;/var/log/apache2/&lt;/code&gt;. You have two choices: hold down Backspace until your soul leaves your body, or&amp;nbsp;hit &lt;code&gt;CTRL + W&lt;/code&gt; to instantly delete the word before the cursor. Once you get used to this, holding Backspace feels like digging a hole with a&amp;nbsp;spoon.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + U&lt;/code&gt; and &lt;code&gt;CTRL + K&lt;/code&gt;&lt;/strong&gt;: You typed out a beautifully crafted,&amp;nbsp;80-character &lt;code&gt;rsync&lt;/code&gt; command, but suddenly realize you need to check if the destination directory actually exists first. You don&amp;#8217;t want to delete it, but you don&amp;#8217;t want to run it.&amp;nbsp;Hit &lt;code&gt;CTRL + U&lt;/code&gt; to cut everything from the cursor to the beginning of the line. Check your directory, and then hit &lt;strong&gt;&lt;code&gt;CTRL + Y&lt;/code&gt;&lt;/strong&gt; to paste (&amp;#8220;yank&amp;#8221;) your masterpiece right back into the prompt.&amp;nbsp;(&lt;code&gt;CTRL + K&lt;/code&gt; does the same thing, but cuts from the cursor to the &lt;em&gt;end&lt;/em&gt; of the&amp;nbsp;line.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + A&lt;/code&gt; and &lt;code&gt;CTRL + E&lt;/code&gt;&lt;/strong&gt;: Jump instantly to the beginning&amp;nbsp;(&lt;code&gt;A&lt;/code&gt;) or end&amp;nbsp;(&lt;code&gt;E&lt;/code&gt;) of the line. Stop reaching for the Home and End keys; they are miles away from the home row&amp;nbsp;anyway.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;ALT + B&lt;/code&gt; and &lt;code&gt;ALT + F&lt;/code&gt;&lt;/strong&gt;: Move backward&amp;nbsp;(&lt;code&gt;B&lt;/code&gt;) or forward&amp;nbsp;(&lt;code&gt;F&lt;/code&gt;) one entire word at a time. It&amp;#8217;s the arrow key&amp;#8217;s much faster, much cooler sibling. &lt;em&gt;(Mac users: you usually have to tweak your terminal settings to use Option as Meta for this to&amp;nbsp;work).&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="the-oh-no-binary-output-fix"&gt;The &amp;#8220;Oh No, Binary Output&amp;#8221;&amp;nbsp;Fix&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;reset&lt;/code&gt; (or &lt;code&gt;stty sane&lt;/code&gt;)&lt;/strong&gt;: While strictly more of a terminal recovery tip than an interactive shell trick, it belongs here. We’ve all done it: you meant&amp;nbsp;to &lt;code&gt;cat&lt;/code&gt; a text file, but you&amp;nbsp;accidentally &lt;code&gt;cat&lt;/code&gt; a compiled binary or a compressed tarball. Suddenly, your terminal is spitting out ancient runes and Wingdings, and your prompt is completely illegible. Instead of closing the terminal window in shame,&amp;nbsp;type &lt;code&gt;reset&lt;/code&gt; (even if you can&amp;#8217;t see the letters you&amp;#8217;re typing) and hit enter. Your terminal will heal&amp;nbsp;itself.&lt;/p&gt;
&lt;h3 id="the-emergency-exits"&gt;The Emergency&amp;nbsp;Exits&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + C&lt;/code&gt;&lt;/strong&gt;: Cancel the current command immediately. Your emergency exit when a command hangs, or you realize you&amp;#8217;re tailing the wrong log&amp;nbsp;file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + D&lt;/code&gt;&lt;/strong&gt;: Sends an &lt;span class="caps"&gt;EOF&lt;/span&gt; (End of File) signal. If you&amp;#8217;re typing input to a command that expects it, this closes the stream. But if the command line is empty, it logs you out of the shell completely-be careful where you press&amp;nbsp;it.&lt;/p&gt;
&lt;h3 id="the-screen-cleaner"&gt;The Screen&amp;nbsp;Cleaner&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + L&lt;/code&gt;&lt;/strong&gt;: Your terminal is cluttered with stack traces, compiler spaghetti, and pure digital noise. Running&amp;nbsp;the &lt;code&gt;clear&lt;/code&gt; command works, but what if you&amp;#8217;re already halfway through typing a new&amp;nbsp;command? &lt;code&gt;CTRL + L&lt;/code&gt; wipes the slate clean, throwing your current prompt right up to the top without interrupting your train of&amp;nbsp;thought.&lt;/p&gt;
&lt;h3 id="the-previous-directory-ping-pong"&gt;The Previous Directory&amp;nbsp;Ping-Pong&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;cd -&lt;/code&gt;&lt;/strong&gt;: The classic channel-flipper. You&amp;#8217;re deep down&amp;nbsp;in &lt;code&gt;/usr/local/etc/postfix&lt;/code&gt; and you need to check something&amp;nbsp;in &lt;code&gt;/var/log&lt;/code&gt;. You&amp;nbsp;type &lt;code&gt;cd /var/log&lt;/code&gt;, look at the logs, and now you want to go back. Instead of typing that long path again,&amp;nbsp;type &lt;code&gt;cd -&lt;/code&gt;. It switches you to your previous directory. Run it again, and you&amp;#8217;re back in logs. Perfect for toggling back and&amp;nbsp;forth.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;pushd&lt;/code&gt; and &lt;code&gt;popd&lt;/code&gt;&lt;/strong&gt;:&amp;nbsp;If &lt;code&gt;cd -&lt;/code&gt; is a toggle&amp;nbsp;switch, &lt;code&gt;pushd&lt;/code&gt; is a stack. Need to juggle multiple&amp;nbsp;directories? &lt;code&gt;pushd /etc&lt;/code&gt; changes&amp;nbsp;to &lt;code&gt;/etc&lt;/code&gt; but saves your previous directory to a hidden stack. When you&amp;#8217;re done,&amp;nbsp;type &lt;code&gt;popd&lt;/code&gt; to pop it off the stack and return exactly where you left&amp;nbsp;off.&lt;/p&gt;
&lt;h3 id="the-instant-truncate"&gt;The Instant&amp;nbsp;Truncate&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;gt; file.txt&lt;/code&gt;&lt;/strong&gt;: This empties a file completely without deleting and recreating it. Why does this matter? It preserves file permissions, ownership, and doesn’t interrupt processes that already have the file open. It&amp;#8217;s much cleaner&amp;nbsp;than &lt;code&gt;echo "" &amp;gt; file.txt&lt;/code&gt; (which actually leaves a newline character)&amp;nbsp;or &lt;code&gt;rm file &amp;amp;&amp;amp; touch file&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="the-last-argument-variable"&gt;The &amp;#8220;Last Argument&amp;#8221;&amp;nbsp;Variable&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;$_&lt;/code&gt;&lt;/strong&gt;: In most&amp;nbsp;shells, &lt;code&gt;$_&lt;/code&gt; expands to the last argument of the previous command-especially useful interactively or in simple scripts when you need to operate on the same long path&amp;nbsp;twice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;/some/ridiculously/long/path/newdir&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;No more re-typing paths or declaring temporary variables to enter a directory you created a second&amp;nbsp;ago.&lt;/p&gt;
&lt;h3 id="scripting-sanity-savers"&gt;Scripting Sanity&amp;nbsp;Savers&lt;/h3&gt;
&lt;p&gt;If you are writing shell scripts, put these at the top immediately after your shebang. It will save you from deploying chaos to&amp;nbsp;production.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;set -e&lt;/code&gt;&lt;/strong&gt;: Exit on error. Very useful, but notoriously weird with edge cases (especially inside conditionals&amp;nbsp;like &lt;code&gt;if&lt;/code&gt; statements, &lt;code&gt;while&lt;/code&gt; loops, and pipelines). Don&amp;#8217;t rely on it blindly as it can create false confidence. &lt;em&gt;(Pro-tip:&amp;nbsp;consider &lt;code&gt;set -euo pipefail&lt;/code&gt; for a more robust safety net, but learn its caveats&amp;nbsp;first.)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;set -u&lt;/code&gt;&lt;/strong&gt;: Treats referencing an unset variable as an error. This protects you from catastrophic disasters&amp;nbsp;like &lt;code&gt;rm -rf /usr/local/${MY_TYPO_VAR}/*&lt;/code&gt; accidentally expanding&amp;nbsp;into &lt;code&gt;rm -rf /usr/local/*&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="the-bash-zsh-comfort-zone"&gt;The Bash &lt;span class="amp"&gt;&amp;amp;&lt;/span&gt; Zsh Comfort&amp;nbsp;Zone&lt;/h2&gt;
&lt;p&gt;If you&amp;#8217;re on a Linux box or using a modern interactive shell, these are the tools that make the &lt;span class="caps"&gt;CLI&lt;/span&gt; feel less like a rusty bicycle and more like something that actually responds when you&amp;nbsp;steer.&lt;/p&gt;
&lt;h3 id="the-history-hunter"&gt;The History&amp;nbsp;Hunter&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + R&lt;/code&gt;&lt;/strong&gt;: Reverse incremental search. Stop pressing the up arrow forty times to find that&amp;nbsp;one &lt;code&gt;awk&lt;/code&gt; command you used last Tuesday.&amp;nbsp;Press &lt;code&gt;CTRL + R&lt;/code&gt;, start typing a keyword from the command, and it magically pulls it from your history.&amp;nbsp;Press &lt;code&gt;CTRL + R&lt;/code&gt; again to cycle backwards through&amp;nbsp;matches. &lt;/p&gt;
&lt;h3 id="the-oops-sudo-move"&gt;The &amp;#8220;Oops, Sudo&amp;#8221;&amp;nbsp;Move&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;!!&lt;/code&gt;&lt;/strong&gt;: This expands to the entirety of your previous command. 
Its most famous use case is the &amp;#8220;Permission denied&amp;#8221; walk of shame. You confidently&amp;nbsp;type &lt;code&gt;systemctl restart nginx&lt;/code&gt;, hit enter, and the system laughs at your lack of privileges. Instead of retyping it,&amp;nbsp;run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;!!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It&amp;#8217;s your way of telling the shell, &amp;#8220;Do what I said, but this time with&amp;nbsp;authority.&amp;#8221;&lt;/p&gt;
&lt;h3 id="the-ultimate-editor-escape-hatch"&gt;The Ultimate Editor Escape&amp;nbsp;Hatch&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + X&lt;/code&gt;,&amp;nbsp;then &lt;code&gt;CTRL + E&lt;/code&gt;&lt;/strong&gt;: You start typing a quick one-liner. Then you add a pipe. Then&amp;nbsp;an &lt;code&gt;awk&lt;/code&gt; statement. Soon, you&amp;#8217;re editing a four-line monster inside your prompt and navigation is getting difficult.&amp;nbsp;Hit &lt;code&gt;CTRL + X&lt;/code&gt; followed&amp;nbsp;by &lt;code&gt;CTRL + E&lt;/code&gt; (in Bash; in Zsh, this needs configuring). This drops your current command into your default text editor (like Vim or Nano). You can edit it with all the power of a proper editor, save, and exit. The shell then executes the command&amp;nbsp;instantly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;fc&lt;/code&gt;&lt;/strong&gt;: The highly portable, traditional sibling&amp;nbsp;to &lt;code&gt;CTRL+X CTRL+E&lt;/code&gt;.&amp;nbsp;Running &lt;code&gt;fc&lt;/code&gt; opens your previous command in&amp;nbsp;your &lt;code&gt;$EDITOR&lt;/code&gt;. It works across most shells and is a fantastic hidden gem for fixing complex, multi-line commands that went&amp;nbsp;wrong.&lt;/p&gt;
&lt;h3 id="the-last-argument-interactive-edition"&gt;The Last Argument (Interactive&amp;nbsp;Edition)&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;ESC + .&lt;/code&gt;&lt;/strong&gt; (or &lt;strong&gt;&lt;code&gt;ALT + .&lt;/code&gt;&lt;/strong&gt;): Inserts the last argument of the previous command right at your cursor. Press it repeatedly to cycle further back through your history, dropping the exact filename or parameter you need right into your current&amp;nbsp;command.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;!$&lt;/code&gt;&lt;/strong&gt;: The non-interactive sibling&amp;nbsp;of &lt;code&gt;ESC + .&lt;/code&gt;.&amp;nbsp;Unlike &lt;code&gt;ESC + .&lt;/code&gt; (which inserts the text live at your cursor for you to review or&amp;nbsp;edit), &lt;code&gt;!$&lt;/code&gt; expands blindly at the exact moment you hit enter. 
&lt;em&gt;(Pro-Tip: For scripting or&amp;nbsp;standard &lt;code&gt;sh&lt;/code&gt;, use&amp;nbsp;the &lt;code&gt;$_&lt;/code&gt; variable mentioned earlier&amp;nbsp;instead!)&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="the-renaming-trick-brace-expansion"&gt;The Renaming Trick &lt;span class="amp"&gt;&amp;amp;&lt;/span&gt; Brace&amp;nbsp;Expansion&lt;/h3&gt;
&lt;p&gt;Brace expansion is pure magic for avoiding repetitive typing, especially when doing quick backups or&amp;nbsp;renames.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Backup Expansion&lt;/strong&gt;:
Need to edit a critical config file and want to make a quick backup&amp;nbsp;first?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cp&lt;span class="w"&gt; &lt;/span&gt;pf.conf&lt;span class="o"&gt;{&lt;/span&gt;,.bak&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The shell expands this seamlessly&amp;nbsp;into &lt;code&gt;cp pf.conf pf.conf.bak&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Rename Trick&lt;/strong&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mv&lt;span class="w"&gt; &lt;/span&gt;filename.&lt;span class="o"&gt;{&lt;/span&gt;txt,md&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This expands&amp;nbsp;to &lt;code&gt;mv filename.txt filename.md&lt;/code&gt;. Fast, elegant, and makes you look like a&amp;nbsp;wizard. &lt;/p&gt;
&lt;p&gt;Need multiple&amp;nbsp;directories? &lt;code&gt;mkdir -p project/{src,tests,docs}&lt;/code&gt; creates all three at&amp;nbsp;once.&lt;/p&gt;
&lt;h3 id="process-substitution"&gt;Process&amp;nbsp;Substitution&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;(command)&lt;/code&gt;&lt;/strong&gt;: Treats the output of a command as if it were a file. 
Say you want to diff the sorted versions of two files. Traditionally, you&amp;#8217;d sort them into temporary files, diff those, and clean up. Process substitution skips the&amp;nbsp;middleman:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;diff&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;sort&lt;span class="w"&gt; &lt;/span&gt;file1.txt&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;sort&lt;span class="w"&gt; &lt;/span&gt;file2.txt&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id="the-ultimate-glob"&gt;The Ultimate&amp;nbsp;Glob&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;**&lt;/code&gt; (Globstar)&lt;/strong&gt;: &lt;code&gt;find&lt;/code&gt; is a great command, but sometimes it feels like overkill. If you&amp;nbsp;run &lt;code&gt;shopt -s globstar&lt;/code&gt; in Bash (it&amp;#8217;s enabled by default in&amp;nbsp;Zsh), &lt;code&gt;**&lt;/code&gt; matches files recursively in all subdirectories. 
Need to find all JavaScript files in your current directory and everything beneath&amp;nbsp;it? &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ls&lt;span class="w"&gt; &lt;/span&gt;**/*.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;No &lt;code&gt;find&lt;/code&gt; command&amp;nbsp;required.&lt;/p&gt;
&lt;h3 id="backgrounding-and-disowning"&gt;Backgrounding and&amp;nbsp;Disowning&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;CTRL + Z&lt;/code&gt;&lt;/strong&gt;, then &lt;strong&gt;&lt;code&gt;bg&lt;/code&gt;&lt;/strong&gt;, then &lt;strong&gt;&lt;code&gt;disown&lt;/code&gt;&lt;/strong&gt;:
You started a massive, hour-long database import task, but you forgot to run it&amp;nbsp;in &lt;code&gt;tmux&lt;/code&gt; or &lt;code&gt;screen&lt;/code&gt;. It&amp;#8217;s tying up your terminal, and if your &lt;span class="caps"&gt;SSH&lt;/span&gt; connection drops, the process dies. Panic sets&amp;nbsp;in.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Hit &lt;code&gt;CTRL + Z&lt;/code&gt; to suspend (pause) the&amp;nbsp;process.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;bg&lt;/code&gt; to let it resume running in the background. Your prompt is&amp;nbsp;free!&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;disown&lt;/code&gt; to detach it from your shell entirely. You can safely close your laptop, grab a coffee, and the process will&amp;nbsp;survive.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="the-everything-logger"&gt;The&amp;nbsp;Everything-Logger&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;command |&amp;amp; tee file.log&lt;/code&gt;&lt;/strong&gt;: Standard pipes&amp;nbsp;(&lt;code&gt;|&lt;/code&gt;) only catch standard output&amp;nbsp;(&lt;code&gt;stdout&lt;/code&gt;). If a script throws an error&amp;nbsp;(&lt;code&gt;stderr&lt;/code&gt;), it skips the pipe and bleeds directly onto your screen, missing the log&amp;nbsp;file. &lt;code&gt;|&amp;amp;&lt;/code&gt; pipes &lt;em&gt;both&lt;/em&gt; stdout and stderr (it&amp;#8217;s a helpful shorthand&amp;nbsp;for &lt;code&gt;2&amp;gt;&amp;amp;1 |&lt;/code&gt;). &lt;/p&gt;
&lt;p&gt;Throw&amp;nbsp;in &lt;code&gt;tee&lt;/code&gt;, and you get to watch the output on your screen while simultaneously saving it to a log file. It’s the equivalent of watching live &lt;span class="caps"&gt;TV&lt;/span&gt; while recording it to your &lt;span class="caps"&gt;DVR&lt;/span&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;The shell is a toolbox, not an obstacle course. You don&amp;#8217;t need to memorize all of these today. Pick just one trick, force it into your daily habits for a week, and then pick another. Stop letting the terminal push you around, and start rearranging the furniture. It&amp;#8217;s your house&amp;nbsp;now.&lt;/p&gt;</content><category term="Unix"/><category term="shell"/><category term="bash"/><category term="unix"/><category term="sysadmin"/><category term="freebsd"/><category term="linux"/></entry></feed>