<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CLI on Benjamin Italiaander</title><link>https://tlnd.org/Linux/cli/</link><description>Recent content in CLI on Benjamin Italiaander</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 01 Jan 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://tlnd.org/Linux/cli/index.xml" rel="self" type="application/rss+xml"/><item><title>Generate a QR code from a pipe in the Linux CLI</title><link>https://tlnd.org/Linux/cli/qrcode/</link><pubDate>Mon, 01 Jan 2024 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/qrcode/</guid><description>&lt;h1 id="create-a-qr-code-from-command-output"&gt;Create a QR code from command output&lt;/h1&gt;
&lt;p&gt;I needed to turn the output of a command into a QR code. Here is a short guide on how to generate a QR code from a pipe in the Linux CLI:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qrencode -t ansiutf8 &amp;lt; ./somefile.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I manage my passwords with &lt;code&gt;pass&lt;/code&gt; and wanted to get a password onto my phone with a QR code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pass work/someaccount &lt;span class="p"&gt;|&lt;/span&gt; head -n1 &lt;span class="p"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;&amp;#39;\n&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; qrencode -t ansiutf8
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;tr&lt;/code&gt; removes the newline that is added at the end.&lt;/p&gt;</description></item><item><title>Kitty Terminal: My Working Config</title><link>https://tlnd.org/Linux/cli/kitty_terminal/</link><pubDate>Mon, 27 Feb 2023 14:12:45 +0100</pubDate><guid>https://tlnd.org/Linux/cli/kitty_terminal/</guid><description>&lt;blockquote&gt;
&lt;p&gt;📦 &lt;em&gt;This page comes from my GitHub repository &lt;a href="https://github.com/Benjamin-Italiaander/kitty_terminal_working_config_example" class="external-link" target="_blank" rel="noopener"&gt;kitty_terminal_working_config_example&lt;/a&gt; and is updated automatically when I change it there.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="-kitty-terminal-my-working-config"&gt;🐱 Kitty Terminal: My Working Config&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://sw.kovidgoyal.net/kitty/" class="external-link" target="_blank" rel="noopener"&gt;kitty&lt;/a&gt; is a fast, GPU-accelerated terminal for Linux and macOS. I switched to it from GNOME Terminal + &lt;a href="https://zellij.dev/" class="external-link" target="_blank" rel="noopener"&gt;Zellij&lt;/a&gt;, because kitty does everything I used a multiplexer for (tabs, splits, layouts) and a lot more: it shows images, makes file names clickable, and has small built-in tools called &lt;strong&gt;kittens&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Read Markdown in the CLI</title><link>https://tlnd.org/Linux/cli/read_markdown_in_cli/</link><pubDate>Tue, 22 Nov 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/read_markdown_in_cli/</guid><description>&lt;h1 id="reading-markdown-files-on-the-linux-command-line"&gt;Reading Markdown files on the Linux command line&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/charmbracelet/glow" class="external-link" target="_blank" rel="noopener"&gt;Glow&lt;/a&gt;: a handy tool I came across. Well maintained and easy to use.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Textualize/frogmouth" class="external-link" target="_blank" rel="noopener"&gt;Frogmouth&lt;/a&gt;: a simple Markdown viewer for the CLI, built with &lt;a href="https://github.com/Textualize/textual" class="external-link" target="_blank" rel="noopener"&gt;Textual&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ttscoff/mdless" class="external-link" target="_blank" rel="noopener"&gt;mdless&lt;/a&gt;: doesn&amp;rsquo;t look like it is maintained regularly, but it renders Markdown files nicely in the CLI.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/markdownlint/markdownlint" class="external-link" target="_blank" rel="noopener"&gt;Markdown lint tool&lt;/a&gt;: for the Markdown purists, a tool to check your Markdown files. Not well maintained.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Copy and Paste in the CLI</title><link>https://tlnd.org/Linux/cli/copy-and-paste-in-cli/</link><pubDate>Thu, 03 Nov 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/copy-and-paste-in-cli/</guid><description>&lt;h1 id="copying-and-pasting-in-the-linux-terminal-is-easy-with-xclip"&gt;Copying and pasting in the Linux terminal is easy with xclip&lt;/h1&gt;
&lt;h3 id="a-simple-command"&gt;A simple command&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Copy whatever is piped in to the clipboard&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xclip -selection c
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="making-it-a-function"&gt;Making it a function&lt;/h3&gt;
&lt;p&gt;I keep forgetting the command, so I added a function to my &lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Use it by piping something into copy-to-clipboard&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy-to-clipboard&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; xclip -selection c
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# For example:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat some-file.txt &lt;span class="p"&gt;|&lt;/span&gt; copy-to-clipboard
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="on-wayland"&gt;On Wayland&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;xclip&lt;/code&gt; only works with X11. Most desktops (GNOME on Fedora and Ubuntu) now use &lt;strong&gt;Wayland&lt;/strong&gt;, where you need &lt;code&gt;wl-copy&lt;/code&gt; from the &lt;code&gt;wl-clipboard&lt;/code&gt; package:&lt;/p&gt;</description></item><item><title>ImageMagick</title><link>https://tlnd.org/Linux/cli/ImageMagick/</link><pubDate>Mon, 10 Oct 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/ImageMagick/</guid><description>&lt;h1 id="using-imagemagick"&gt;Using ImageMagick&lt;/h1&gt;
&lt;p&gt;If you ever need to do some quick image or document conversions, ImageMagick is a command-line tool that can save you a ton of time. Here&amp;rsquo;s a quick guide on how to install it and use it to convert images, PDFs and more. Perfect for automating repetitive tasks.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;💡 In ImageMagick 7 the &lt;code&gt;convert&lt;/code&gt; command is called &lt;code&gt;magick&lt;/code&gt; (e.g. &lt;code&gt;magick input.psd output.jpg&lt;/code&gt;). &lt;code&gt;convert&lt;/code&gt; still works but is deprecated.&lt;/p&gt;</description></item><item><title>Put every word on its own line</title><link>https://tlnd.org/Linux/cli/remove-blank-spaces/</link><pubDate>Tue, 04 Oct 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/remove-blank-spaces/</guid><description>&lt;h1 id="put-every-word-on-its-own-line"&gt;Put every word on its own line&lt;/h1&gt;
&lt;p&gt;If you have a file with text like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;abcd efdg ijklm sfgsdf
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sdgf gfgf gdfg dgdffdg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and you want each word on a separate line, the easiest way is &lt;code&gt;xargs&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xargs -n &lt;span class="m"&gt;1&lt;/span&gt; &amp;lt; ./somefile.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Extract a Column</title><link>https://tlnd.org/Linux/cli/Filter_from_tab/</link><pubDate>Fri, 03 Jun 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/Filter_from_tab/</guid><description>&lt;h1 id="extracting-a-specific-column-in-the-linux-cli"&gt;Extracting a Specific Column in the Linux CLI&lt;/h1&gt;
&lt;p&gt;Sometimes you may need to extract a specific column (or tab-separated field) from a file in the Linux command line.&lt;/p&gt;
&lt;h3 id="example-file"&gt;Example File&lt;/h3&gt;
&lt;p&gt;Let&amp;rsquo;s say we have a file (&lt;code&gt;file.txt&lt;/code&gt;) with the following content:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;A B C 
D E F 
G H I 
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="extracting-the-first-column"&gt;Extracting the First Column&lt;/h3&gt;
&lt;p&gt;To extract the first column from each line, you can use &lt;code&gt;awk&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;awk &lt;span class="s1"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt; file.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;A 
D 
G 
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="extracting-the-second-column"&gt;Extracting the Second Column&lt;/h3&gt;
&lt;p&gt;To extract the second column, modify the command:&lt;/p&gt;</description></item><item><title>Diff: compare two files</title><link>https://tlnd.org/Linux/cli/diff/</link><pubDate>Wed, 11 May 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/diff/</guid><description>&lt;h1 id="show-the-differences-between-two-files"&gt;Show the differences between two files&lt;/h1&gt;
&lt;p&gt;Side-by-side output, in two columns:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;diff --side-by-side file_one.txt file_two.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Side-by-side output, showing only the lines that differ:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;diff --side-by-side --suppress-common-lines file_one.txt file_two.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;-y&lt;/code&gt; is the short form of &lt;code&gt;--side-by-side&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>List outgoing connections</title><link>https://tlnd.org/Linux/cli/outgoing_connections/</link><pubDate>Sat, 02 Apr 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/outgoing_connections/</guid><description>&lt;h1 id="how-to-list-outgoing-connections-on-the-linux-cli"&gt;How to list outgoing connections on the Linux CLI&lt;/h1&gt;
&lt;p&gt;A small example of how to show the remote addresses of your connections.&lt;/p&gt;
&lt;p&gt;Outgoing TCP connections:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;netstat -atn &lt;span class="p"&gt;|&lt;/span&gt; tr -s &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; cut -f5 -d &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;&amp;#39;127.0.0.1&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Outgoing UDP connections:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;netstat -aun &lt;span class="p"&gt;|&lt;/span&gt; tr -s &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; cut -f5 -d &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;&amp;#39;127.0.0.1&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On newer systems &lt;code&gt;netstat&lt;/code&gt; may not be installed; &lt;code&gt;ss -tn&lt;/code&gt; (TCP) and &lt;code&gt;ss -un&lt;/code&gt; (UDP) give similar output.&lt;/p&gt;
&lt;h3 id="with-ss-the-modern-way"&gt;With &lt;code&gt;ss&lt;/code&gt; (the modern way)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;ss&lt;/code&gt; is installed everywhere and can filter by state itself. Only established connections, without the header, with the program that owns them:&lt;/p&gt;</description></item><item><title>Bye Bye Screen, Hello Zellij</title><link>https://tlnd.org/Linux/cli/bye-bye-screen-hello-zellij/</link><pubDate>Mon, 28 Mar 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/cli/bye-bye-screen-hello-zellij/</guid><description>&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;This note is old.&lt;/strong&gt; I don&amp;rsquo;t use Zellij on my desktop any more: I now use the
&lt;a href="https://tlnd.org/Linux/cli/kitty_terminal/"&gt;kitty terminal&lt;/a&gt;, whose tabs, splits and layouts do everything I used
Zellij for. Zellij (or tmux) is still a good choice on a server, when you need sessions
that keep running after you close the terminal or lose your SSH connection.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="zellij-is-a-great-alternative-to-screen"&gt;&lt;a href="https://zellij.dev/" class="external-link" target="_blank" rel="noopener"&gt;Zellij&lt;/a&gt; is a great alternative to screen!&lt;/h1&gt;
&lt;p&gt;I recently came across Zellij, a really nice replacement for terminal multiplexers like tmux and screen. I instantly became a fan!&lt;/p&gt;</description></item></channel></rss>