<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Htop – Serverküche</title><link>https://serverkueche.de/en/tags/htop/</link><description>Htop – Neueste Beiträge von Serverküche</description><generator>Hugo</generator><language>en-US</language><managingEditor>feedback@serverkueche.de (Serverküche)</managingEditor><webMaster>feedback@serverkueche.de (Serverküche)</webMaster><copyright>2026 Serverküche</copyright><lastBuildDate>Wed, 22 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://serverkueche.de/en/tags/htop/index.xml" rel="self" type="application/rss+xml"/><item><title>The essential terminal commands for your server</title><link>https://serverkueche.de/en/tutorials/essential-terminal-commands/</link><pubDate>Wed, 22 Jul 2026 00:00:00 +0000</pubDate><author>feedback@serverkueche.de (Serverküche)</author><guid>https://serverkueche.de/en/tutorials/essential-terminal-commands/</guid><description>The toolbox for the server terminal: from htop, btop and ncdu for debugging to tmux, rsync and dig for daily work – with real examples.</description><content:encoded><![CDATA[<p>Whoever runs their own server lives (at least occasionally) in the terminal. This article
is your toolbox: the commands you really need – once for <strong>debugging</strong> when the server
suddenly crawls, and once for <strong>daily work</strong>. Not a dry manual, but the selection that has
proven itself in everyday use.</p>
<h2 id="what-are-we-building">What are we building?</h2>
<p>No setup this time, but a <strong>battle-tested reference</strong>. We go through two toolboxes:</p>
<ol>
<li><strong>Debugging performance</strong> – when the server gets sluggish: <code>top</code>, <code>htop</code>, <code>btop</code>,
<code>ctop</code>, <code>iotop</code>, <code>nload</code>, <code>ncdu</code> and <code>kill</code>. With these you find out <em>what</em> is eating
the resources, and intervene.</li>
<li><strong>Daily work</strong> – the commands you type constantly: <code>ls</code>, <code>cd</code>, <code>nano</code>, <code>wget</code>, <code>curl</code>,
<code>dig</code>, <code>tmux</code>, <code>history</code>, <code>sudo</code>, <code>scp</code>, <code>rsync</code>, <code>dd</code> and <code>ssh-agent</code>.</li>
</ol>
<p>All examples ran on a real <strong>Debian 13</strong> server; the outputs shown are real. The
interactive full-screen tools (top, htop, btop, ctop, nload, ncdu) we additionally show
you in a picture, so you recognize the interface – the copyable single commands stay
deliberately as text to type out.</p>
<h2 id="prerequisites">Prerequisites</h2>
<ul>
<li>A server you can log into via SSH – e.g. from
<a href="/en/tutorials/first-steps-netcup-vps/">First steps with the netcup VPS</a>.</li>
<li>A user with <code>sudo</code> rights to install packages.</li>
<li>No fear of the command line – we&rsquo;ll shed that together here.</li>
</ul>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-herb-400 bg-herb-50 dark:border-herb-700 dark:bg-herb-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">🧑‍🍳</span>Install first, then use
  </p>
  <div class="prose-kitchen text-sm"><p><code>top</code>, <code>kill</code>, <code>ls</code>, <code>curl</code>, <code>dig</code>, <code>scp</code>, <code>dd</code> and <code>ssh-agent</code> are usually already there
on Debian. The more comfortable tools you install in one go:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt update <span class="o">&amp;&amp;</span> sudo apt install -y htop btop iotop nload ncdu tmux rsync</span></span></code></pre></div>
</div>
<p><code>ctop</code> is not in the package sources – we&rsquo;ll fetch it directly as a ready-made file in the
corresponding section.</p>
</div>
</div>
<h2 id="step-by-step">Step by step</h2>
<p>First the debugging toolbox – the commands for the moment the server is stuck. Then the
tools for daily work.</p>
<h3 id="top-and-htop-the-first-look">top and htop: the first look</h3>
<p><code>top</code> is present on every Linux and shows the running processes live, sorted by CPU load.
For a quick look it&rsquo;s enough:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">top</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-top_hu_4809f616e06b7cb8.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-top_hu_1335ebccce922b20.webp 480w, /en/tutorials/essential-terminal-commands/terminal-top_hu_4809f616e06b7cb8.webp 768w, /en/tutorials/essential-terminal-commands/terminal-top_hu_4c40fc62fc61344d.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-top_hu_953e02ee8fa74fd.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="758"
    data-full="/en/tutorials/essential-terminal-commands/terminal-top_hu_e40d7531757b2c1.webp"
    alt="The top output with CPU state line, memory line and the process list sorted by CPU load" title="top: the %Cpu(s) line reveals what the CPU is busy with right now"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">top: the %Cpu(s) line reveals what the CPU is busy with right now</figcaption></figure></p>
<p>At the top you see load average, memory and the process list. The most important – and
most cryptic – line is <strong><code>%Cpu(s)</code></strong>. Its eight values tell you <em>what</em> the CPU is busy
with:</p>
<ul>
<li><strong><code>us</code></strong> (user) – normal programs in userspace (your apps, container processes).</li>
<li><strong><code>sy</code></strong> (system) – the kernel itself (system calls, drivers, network stack).</li>
<li><strong><code>ni</code></strong> (nice) – userspace processes with lowered priority (started via <code>nice</code>).</li>
<li><strong><code>id</code></strong> (idle) – idling. <strong>High <code>id</code> = plenty of headroom</strong>, low <code>id</code> = the CPU is
maxed out.</li>
<li><strong><code>wa</code></strong> (io-wait) – the CPU is <strong>waiting for the disk</strong>. Consistently high means: your
bottleneck is the disk, not the compute power (then continue with <code>iotop</code>, see below).</li>
<li><strong><code>hi</code></strong> (hardware interrupts) – time for hardware interrupts (devices reporting in).</li>
<li><strong><code>si</code></strong> (software interrupts) – time for software interrupts (often network
processing).</li>
<li><strong><code>st</code></strong> (steal) – <strong>only on VPS/virtual servers</strong>: compute time the hypervisor
&ldquo;stole&rdquo; from your VM because other guests ran on the same host. Consistently high <code>st</code>
means the host is oversubscribed – a reason to question the plan or provider.</li>
</ul>
<p>With <code>q</code> you quit the view. But <code>top</code> is spartan – the successor <code>htop</code> is much more
readable: colored bars per CPU core, mouse operation and easy sorting.</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">htop</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-htop_hu_d9e4772c3c92bc7a.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-htop_hu_83a2ed0bf41e737a.webp 480w, /en/tutorials/essential-terminal-commands/terminal-htop_hu_d9e4772c3c92bc7a.webp 768w, /en/tutorials/essential-terminal-commands/terminal-htop_hu_8b21d29b4afcb7c3.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-htop_hu_f675f4223d58accb.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="462"
    data-full="/en/tutorials/essential-terminal-commands/terminal-htop_hu_b74118bcea1a6bb7.webp"
    alt="The htop dashboard with colored CPU and memory bars and the process list" title="htop: colored usage bars plus a sortable and searchable process list"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">htop: colored usage bars plus a sortable and searchable process list</figcaption></figure></p>
<p>At the top, watch the <strong>CPU bars</strong> (one bar per core) and the <strong>Mem</strong> bar. In the list you
sort with <code>F6</code> by a column (e.g. <code>%MEM</code>), search a process with <code>F3</code> and end it with <code>F9</code>.
Exactly here you find the service that&rsquo;s currently slowing everything down.</p>
<h3 id="btop-the-fancy-system-monitor">btop: the fancy system monitor</h3>
<p><code>btop</code> (version 1.3.2 in the test) goes one step further: CPU, memory, disk I/O and
network in one pretty, mouse-operable dashboard – all at a glance.</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">btop</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-btop_hu_939dc132b7e88178.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-btop_hu_9aee6dd6ef165c90.webp 480w, /en/tutorials/essential-terminal-commands/terminal-btop_hu_939dc132b7e88178.webp 768w, /en/tutorials/essential-terminal-commands/terminal-btop_hu_6650a3a99015791f.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-btop_hu_a4b760c923e1618a.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="378"
    data-full="/en/tutorials/essential-terminal-commands/terminal-btop_hu_e94da5d4550e8414.webp"
    alt="The btop dashboard with a CPU usage graph, memory, disk and network display plus a process list" title="btop: CPU graph, RAM, disks, network and processes in one picture – three cores under load here"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">btop: CPU graph, RAM, disks, network and processes in one picture – three cores under load here</figcaption></figure></p>
<p>For the daily health check, <code>btop</code> is our favorite because you see network and disk right
along and don&rsquo;t need several tools. Quit with <code>q</code> or <code>Esc</code>.</p>
<h3 id="ctop-monitor-docker-containers-live">ctop: monitor Docker containers live</h3>
<p>If your server runs with Docker, you want to know which <strong>container</strong> draws how much.
<code>htop</code> only shows processes – <code>ctop</code> shows containers. It&rsquo;s not in the package sources, so
we fetch the ready-made file (version 0.7.7):</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo curl -L -o /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64
</span></span><span class="line"><span class="cl">sudo chmod +x /usr/local/bin/ctop</span></span></code></pre></div>
</div>
<p>We deliberately download the file with a full path and make it executable – no blind
<code>curl … | bash</code>. Then you simply start it:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ctop</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-ctop_hu_f534ab25314cb648.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-ctop_hu_131d335f81994847.webp 480w, /en/tutorials/essential-terminal-commands/terminal-ctop_hu_f534ab25314cb648.webp 768w, /en/tutorials/essential-terminal-commands/terminal-ctop_hu_df3d963f87473c17.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-ctop_hu_5d36591f1273be2f.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="86"
    data-full="/en/tutorials/essential-terminal-commands/terminal-ctop_hu_bda915ba30010c5d.webp"
    alt="The ctop overview with one row per container and columns for CPU, memory, network and I/O" title="ctop: each container one row – here \&#34;demo-busy\&#34; draws 104% CPU"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">ctop: each container one row – here \&#34;demo-busy\&#34; draws 104% CPU</figcaption></figure></p>
<p>You get one row per container with CPU, RAM, network and disk I/O, updated live. With Enter
on a container you open a menu to stop, restart or show logs – ideal when a single service
runs amok.</p>
<h3 id="iotop-and-nload-disk-and-network">iotop and nload: disk and network</h3>
<p>Sometimes the problem isn&rsquo;t the CPU but the <strong>disk</strong>. <code>iotop</code> shows which process is
currently reading and writing (needs root):</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo iotop</span></span></code></pre></div>
</div>
<p>Sorted by write/read rate you immediately spot the I/O hog – often a backup, a database or
a log gone out of control. For the <strong>network</strong>, <code>nload</code> does the same: incoming and
outgoing throughput in real time, with a small graph.</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">nload</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-nload_hu_36e8040aacbc1b3c.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-nload_hu_5a2a952957237444.webp 480w, /en/tutorials/essential-terminal-commands/terminal-nload_hu_36e8040aacbc1b3c.webp 768w, /en/tutorials/essential-terminal-commands/terminal-nload_hu_537efd90521ed53c.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-nload_hu_e15a01eaa91e433c.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="378"
    data-full="/en/tutorials/essential-terminal-commands/terminal-nload_hu_788b51bf7390e6d2.webp"
    alt="The nload view with bar graphs for incoming and outgoing network throughput on eth0" title="nload: incoming (here 1.98 Gbit/s) and outgoing throughput per interface, with a live graph"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">nload: incoming (here 1.98 Gbit/s) and outgoing throughput per interface, with a live graph</figcaption></figure></p>
<p>With the arrow keys you switch between the network interfaces (or you specify the desired
one directly, e.g. <code>nload eth0</code>). Handy to check whether a large upload is running – or
whether unexpected traffic is clogging the connection.</p>
<h3 id="ncdu-find-the-storage-hog">ncdu: find the storage hog</h3>
<p>The most common cause of a broken server is a <strong>full disk</strong>. The rough overview is given by
<code>df</code>:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">df -h /</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Filesystem      Size  Used Avail Use% Mounted on
</span></span><span class="line"><span class="cl">/dev/vda4       251G   11G  230G   5% /</span></span></code></pre></div>
</div>
<p><code>df</code> tells you <em>that</em> it&rsquo;s getting tight, but not <em>where</em>. That&rsquo;s what <code>ncdu</code> does – an
interactive directory analyzer that shows you which folders take up the space:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo ncdu /</span></span></code></pre></div>
</div>
<p><figure class="my-6"><img src="/en/tutorials/essential-terminal-commands/terminal-ncdu_hu_c500db131512f21a.webp" srcset="/en/tutorials/essential-terminal-commands/terminal-ncdu_hu_5f2baf134af0eead.webp 480w, /en/tutorials/essential-terminal-commands/terminal-ncdu_hu_c500db131512f21a.webp 768w, /en/tutorials/essential-terminal-commands/terminal-ncdu_hu_bfd5160972b38684.webp 1200w, /en/tutorials/essential-terminal-commands/terminal-ncdu_hu_1b0563a1c785d7f5.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="378"
    data-full="/en/tutorials/essential-terminal-commands/terminal-ncdu_hu_7c791fd9b0c1fef9.webp"
    alt="The ncdu view with the largest directories under /usr, each with a bar and size" title="ncdu: the largest directories at the top, sorted with bars – here a scan of /usr"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">ncdu: the largest directories at the top, sorted with bars – here a scan of /usr</figcaption></figure></p>
<p><code>ncdu</code> scans and lists the largest directories at the top. With the arrow keys you navigate
in, with <code>d</code> you delete specifically (careful!). This is how you find the huge log file or
the forgotten backup folder in seconds.</p>
<h3 id="kill-end-hanging-processes">kill: end hanging processes</h3>
<p>If in <code>htop</code> or <code>top</code> you found the <strong>PID</strong> (process ID) of the culprit, you end it with
<code>kill</code>:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">kill</span> <span class="m">12345</span></span></span></code></pre></div>
</div>
<p>That sends a polite &ldquo;please quit&rdquo; (signal <code>TERM</code>) that allows the process to clean up
properly. If it doesn&rsquo;t react, the hard variant follows:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">kill</span> -9 <span class="m">12345</span></span></span></code></pre></div>
</div>
<p><code>-9</code> (signal <code>KILL</code>) ends immediately and mercilessly. <strong>Use it only as a last resort</strong> –
the process can no longer save any data. If you only know the name, <code>pkill nginx</code> helps,
which hits all matching processes.</p>
<p>That ends the debugging box. Now the tools for daily work.</p>
<h3 id="ls-cd-and-nano-navigate-and-edit">ls, cd and nano: navigate and edit</h3>
<p>The basic framework of every terminal session. <code>cd</code> changes the directory, <code>ls</code> lists the
contents. Most useful is <code>ls</code> with options:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ls -lh</span></span></code></pre></div>
</div>
<p><code>-l</code> shows details (permissions, owner, size, date), <code>-h</code> makes the sizes readable (<code>4.0K</code>
instead of <code>4096</code>). With <code>ls -la</code> you also see hidden files (those starting with <code>.</code>). For
editing configuration files, <code>nano</code> is the most beginner-friendly editor:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo nano /etc/hosts</span></span></code></pre></div>
</div>
<p>At the bottom are the shortcuts: <code>Ctrl+O</code> saves (&ldquo;WriteOut&rdquo;), <code>Ctrl+X</code> quits. No cryptic
vim – exactly right to quickly change a line.</p>
<h3 id="wget-curl-and-dig-fetch-data-and-check-the-network">wget, curl and dig: fetch data and check the network</h3>
<p><code>wget</code> downloads files – ideal for downloads:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">wget https://YOUR_SOURCE/datei.tar.gz</span></span></code></pre></div>
</div>
<p><code>curl</code> is the Swiss Army knife for HTTP. Especially valuable: viewing only the <strong>response
headers</strong> to check what a server returns:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -I https://example.com</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">HTTP/2 200
</span></span><span class="line"><span class="cl">date: Sat, 18 Jul 2026 09:55:49 GMT
</span></span><span class="line"><span class="cl">content-type: text/html
</span></span><span class="line"><span class="cl">server: cloudflare</span></span></code></pre></div>
</div>
<p>Status <code>200</code> means &ldquo;all ok&rdquo;, <code>301</code>/<code>302</code> are redirects, <code>404</code> &ldquo;not found&rdquo;. For DNS
questions, <code>dig</code> is the tool – e.g. to check whether your domain points to the right
server:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">dig +short example.com A</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">172.66.147.243
</span></span><span class="line"><span class="cl">104.20.23.154</span></span></code></pre></div>
</div>
<p><code>+short</code> delivers only the pure answer (the IP address). Without the switch you see the
full report including response time – indispensable before Traefik can fetch a certificate
(see <a href="/en/tutorials/connect-domain-to-server/">connecting a domain to your server</a>).</p>
<h3 id="tmux-the-session-that-never-breaks-off">tmux: the session that never breaks off</h3>
<p>The most important tool for remote maintenance. If you start a long command (update,
backup, compiling) over SSH and your connection breaks, <strong>normally your process dies too</strong>.
<code>tmux</code> solves that: it keeps your session alive on the server, whether or not you&rsquo;re
connected.</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">tmux</span></span></code></pre></div>
</div>
<p>You land in a tmux session and work normally. If the connection breaks off (or you
deliberately close with <code>Ctrl+B</code>, then <code>D</code> – &ldquo;detach&rdquo;), everything keeps running. On the
next login you attach again:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">tmux attach</span></span></code></pre></div>
</div>
<p>tmux can do much more (split windows, several panes). The shortcuts all begin with the
&ldquo;prefix&rdquo; <code>Ctrl+B</code>. A compact overview of all shortcuts is on the
<a href="https://tmuxcheatsheet.com/">tmux cheatsheet</a> – worth printing out.</p>
<h3 id="scp-rsync-and-dd-copy-and-transfer">scp, rsync and dd: copy and transfer</h3>
<p><code>scp</code> copies files over SSH – from the local machine to the server and back:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">scp datei.txt YOUR_USER@YOUR_SERVER_IP:/opt/ziel/</span></span></code></pre></div>
</div>
<p>For anything beyond single files, <code>rsync</code> is superior: it transfers only <em>changes</em>, can
resume, and synchronizes entire directory trees. Always test first with <code>-n</code> (dry run)
before you really copy:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">rsync -avn /quelle/ /ziel/</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">sending incremental file list
</span></span><span class="line"><span class="cl">created directory /ziel
</span></span><span class="line"><span class="cl">./
</span></span><span class="line"><span class="cl">datei.txt
</span></span><span class="line"><span class="cl">sub/
</span></span><span class="line"><span class="cl">sub/mehr.txt
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">sent 147 bytes  received 63 bytes  420.00 bytes/sec
</span></span><span class="line"><span class="cl">total size is 11  speedup is 0.05 (DRY RUN)</span></span></code></pre></div>
</div>
<p><code>-a</code> preserves permissions and timestamps, <code>-v</code> is verbose, <code>-n</code> only shows <em>what would
happen</em>. If it looks good, you leave out the <code>-n</code>. <code>rsync</code> also works over SSH
(<code>rsync -av /quelle/ user@server:/ziel/</code>) and is thus the backbone of many backup scripts.</p>
<p><code>dd</code>, finally, copies <strong>raw, block by block</strong> – e.g. to write a boot image onto a USB
stick. It&rsquo;s powerful and merciless (more on that below):</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo dd <span class="k">if</span><span class="o">=</span>image.iso <span class="nv">of</span><span class="o">=</span>/dev/sdX <span class="nv">bs</span><span class="o">=</span>4M <span class="nv">status</span><span class="o">=</span>progress</span></span></code></pre></div>
</div>
<h3 id="history-sudo-and-ssh-agent-the-little-helpers">history, sudo and ssh-agent: the little helpers</h3>
<p><code>history</code> shows your most recently typed commands with a number – handy to find a long
command from yesterday again:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">history</span> <span class="p">|</span> grep docker</span></span></code></pre></div>
</div>
<p>With <code>!123</code> you run the command with number 123 again, with <code>Ctrl+R</code> you search
interactively backwards. <code>sudo</code> runs a single command with administrator rights – always
only as much privilege as needed:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart docker</span></span></code></pre></div>
</div>
<p><code>ssh-agent</code>, finally, remembers your SSH key password for the session so you don&rsquo;t have to
retype it on every connection:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">eval</span> <span class="s2">&#34;</span><span class="k">$(</span>ssh-agent -s<span class="k">)</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">ssh-add ~/.ssh/id_ed25519</span></span></code></pre></div>
</div>
<p>After that you log in without entering the passphrase again – until you log out. More on
secure SSH keys is in <a href="/en/tutorials/harden-ssh/">hardening SSH</a>.</p>
<h2 id="when-things-go-wrong">When things go wrong</h2>
<div class="troubleshoot not-prose">
<p><strong><code>dd</code> overwrote the wrong disk – data gone.</strong> <code>dd</code> doesn&rsquo;t ask and isn&rsquo;t mockingly called
&ldquo;disk destroyer&rdquo; for nothing. Check the target (<code>of=</code>) <strong>always</strong> beforehand with <code>lsblk</code>,
and never confuse <code>sda</code> with <code>sdb</code>. There&rsquo;s no undo – when in doubt, read it three times.</p>
<p><strong><code>kill -9</code> ended a service, but the database is corrupted afterwards.</strong> <code>-9</code> gives the
process no chance to close cleanly. Always first use <code>kill</code> without <code>-9</code> and give the
process a few seconds. Only when it really hangs does the hard variant follow.</p>
<p><strong><code>rsync</code> copied (or deleted) much more than expected.</strong> The <strong>trailing slash</strong> decides:
<code>rsync -a /quelle/</code> copies the <em>contents</em> of <code>quelle</code>, <code>rsync -a /quelle</code> copies the
<em>folder</em> along with it. And <code>--delete</code> deletes everything in the target that&rsquo;s missing in
the source. Test with <code>-n</code> first, always.</p>
<p><strong>A tool reports &ldquo;command not found&rdquo;.</strong> The package isn&rsquo;t installed. Install it (see tip
box above) or check the name. Some tools like <code>iotop</code> additionally need <code>sudo</code> to see any
data at all.</p>
<p><strong>After <code>tmux</code>, on the next login &ldquo;everything is gone&rdquo;.</strong> You started a <em>new</em> session
instead of attaching. <code>tmux ls</code> lists running sessions, <code>tmux attach -t 0</code> attaches you to
the first. Just <code>tmux</code> on its own creates a fresh one every time.</p>

</div>

<h2 id="maintenance--backups">Maintenance &amp; backups</h2>
<ul>
<li><strong>These commands are your backup tool.</strong> <code>rsync</code>, <code>scp</code> and <code>dd</code> are the foundation of
every backup strategy. For real, encrypted off-site backups you build on this – see
<a href="/en/tutorials/restic-backups/">backups with Restic</a>, which internally uses the same
logic.</li>
<li><strong>Help yourself.</strong> Every command brings its own docs: <code>man rsync</code> opens the manual,
<code>rsync --help</code> shows the options compactly. For brief practical examples the package
<code>tldr</code> is worth it (<code>sudo apt install tldr</code>), which instead of pages-long man pages shows
the three or four most common use cases.</li>
<li><strong>Stay current.</strong> Keep the tools fresh via <code>sudo apt update &amp;&amp; sudo apt upgrade</code>; <code>ctop</code>
you update by downloading the new release file again. The versions are named deliberately
(state of the test) – newer ones generally work just the same.</li>
<li><strong>Honest about the effort:</strong> you don&rsquo;t have to memorize this reference. Bookmark it and
come back when the server is stuck. After a few weeks the most important moves stick on
their own.</li>
</ul>
]]></content:encoded></item></channel></rss>