<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tip on Benjamin Italiaander</title><link>https://tlnd.org/genre/tip/</link><description>Recent content in Tip 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/genre/tip/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>Benchmark write speed</title><link>https://tlnd.org/Linux/benchmark/</link><pubDate>Mon, 27 Feb 2023 14:12:45 +0100</pubDate><guid>https://tlnd.org/Linux/benchmark/</guid><description>&lt;h1 id="-benchmark-write-speed-to-a-disk"&gt;💾 Benchmark Write Speed to a Disk&lt;/h1&gt;
&lt;p&gt;Sometimes you need to test how fast a (network) disk can handle writes.&lt;/p&gt;
&lt;p&gt;A common method is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write &lt;strong&gt;one large file&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Split it into &lt;strong&gt;many small files&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Benchmark copying them using &lt;code&gt;rsync&lt;/code&gt; or &lt;code&gt;cp&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Why?
Some storage systems handle large sequential writes very well, but struggle with many small files (metadata overhead, IOPS limits, etc.).&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-create-a-large-random-file"&gt;1️⃣ Create a Large Random File&lt;/h2&gt;
&lt;p&gt;Generate a large file locally:&lt;/p&gt;</description></item><item><title>Date command in bash</title><link>https://tlnd.org/Linux/bash_tricks/date_command/</link><pubDate>Mon, 27 Feb 2023 14:12:45 +0100</pubDate><guid>https://tlnd.org/Linux/bash_tricks/date_command/</guid><description>&lt;h1 id="a-few-small-examples-of-the-date-command"&gt;A few small examples of the date command&lt;/h1&gt;
&lt;p&gt;Show the day of the week as a number (1 = Monday), which is always handy to know:&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;date +%u
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Show the quarter of the year:&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;date +%q
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In a script:&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="cp"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;todayWeekday&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;date +%u&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;todayQuarter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;date +%q&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Today is weekday &lt;/span&gt;&lt;span class="nv"&gt;$todayWeekday&lt;/span&gt;&lt;span class="s2"&gt;, in quarter &lt;/span&gt;&lt;span class="nv"&gt;$todayQuarter&lt;/span&gt;&lt;span class="s2"&gt; of the year.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Count logged-in users</title><link>https://tlnd.org/Linux/bash_tricks/display_number_of_loggedin_users/</link><pubDate>Fri, 01 Jan 2021 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/bash_tricks/display_number_of_loggedin_users/</guid><description>&lt;h1 id="display-the-number-of-logged-in-users-with-the-who-command"&gt;Display the number of logged-in users with the who command&lt;/h1&gt;
&lt;p&gt;Keeping track of the number of users logged into a system can be very useful. This short Bash command shows the exact number of active users:&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;who -q &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;&amp;#34;users=&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sed &lt;span class="s1"&gt;&amp;#39;s/# users=//g&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For a continuous, real-time update of the user count, run it with &lt;code&gt;watch&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;watch &lt;span class="s2"&gt;&amp;#34;who -q | grep &amp;#39;users=&amp;#39; | sed &amp;#39;s/# users=//g&amp;#39;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Permissions for SSH Files</title><link>https://tlnd.org/Linux/ssh/chmod_ssh_files/</link><pubDate>Fri, 09 Dec 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssh/chmod_ssh_files/</guid><description>&lt;h1 id="permissions-for-ssh-files"&gt;Permissions for SSH files&lt;/h1&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;What&lt;/th&gt;
 &lt;th&gt;Path&lt;/th&gt;
 &lt;th&gt;chmod&lt;/th&gt;
 &lt;th&gt;Result&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;SSH folder&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;~/.ssh&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;700&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;drwx------&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Public key&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;~/.ssh/id_ed25519.pub&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;644&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;-rw-r--r--&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Private key&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;~/.ssh/id_ed25519&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;600&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;-rw-------&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Authorized keys&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;~/.ssh/authorized_keys&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;600&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;-rw-------&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Config&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;~/.ssh/config&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;600&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;-rw-------&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="home-folder"&gt;Home folder&lt;/h2&gt;
&lt;p&gt;Your home folder must not be writable by others, or SSH will refuse your keys. 755 (&lt;code&gt;drwxr-xr-x&lt;/code&gt;) is the most it may be:&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;chmod g-w,o-w ~
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The same goes for every other key you have, such as &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; (older RSA keys) or &lt;code&gt;~/.ssh/yubikey&lt;/code&gt;: private keys 600, public keys 644. Set it all at once:&lt;/p&gt;</description></item><item><title>Git notes</title><link>https://tlnd.org/Linux/git/</link><pubDate>Wed, 30 Nov 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/git/</guid><description>&lt;h1 id="git"&gt;Git&lt;/h1&gt;
&lt;h2 id="configure-git"&gt;Configure Git&lt;/h2&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;git config --global user.email &lt;span class="s2"&gt;&amp;#34;you@example.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git config --global user.name &lt;span class="s2"&gt;&amp;#34;Your Name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="use-an-ssh-key-for-a-specific-remote"&gt;Use an SSH key for a specific remote&lt;/h2&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;git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="list-the-configured-remotes"&gt;List the configured remotes&lt;/h2&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;git remote -v
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&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>Allow a User to Access Serial (TTY) Devices</title><link>https://tlnd.org/Linux/bash_tricks/allow_tty/</link><pubDate>Mon, 14 Nov 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/bash_tricks/allow_tty/</guid><description>&lt;h1 id="allow-a-user-to-access-serial-tty-devices"&gt;Allow a user to access serial (TTY) devices&lt;/h1&gt;
&lt;p&gt;On Ubuntu, create the user and add them to the &lt;code&gt;dialout&lt;/code&gt; group. &lt;code&gt;dialout&lt;/code&gt; normally grants access to serial devices such as &lt;code&gt;/dev/ttyUSB0&lt;/code&gt;, &lt;code&gt;/dev/ttyACM0&lt;/code&gt; and &lt;code&gt;/dev/ttyS0&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;# Create the user&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo adduser username
&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;# Allow access to serial/TTY devices&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo usermod -aG dialout username
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check:&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;groups username
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should see something like:&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;username : username dialout
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The user needs to &lt;strong&gt;log out and back in&lt;/strong&gt; before the new group membership takes effect.&lt;/p&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>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>Shortcuts on the Fedora desktop</title><link>https://tlnd.org/Linux/fedora/fedora_desktop_shortcut/</link><pubDate>Wed, 28 Sep 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/fedora/fedora_desktop_shortcut/</guid><description>&lt;h1 id="shortcuts-on-the-fedora-desktop"&gt;Shortcuts on the Fedora desktop&lt;/h1&gt;
&lt;h4 id="move-the-selected-window-to-the-workspace-on-the-left"&gt;Move the selected window to the workspace on the left&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Super + Shift + Page Up&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="move-the-selected-window-to-the-workspace-on-the-right"&gt;Move the selected window to the workspace on the right&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Super + Shift + Page Down&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Find Files, Excluding Hidden Files</title><link>https://tlnd.org/Linux/find_exclude_hidden_files/</link><pubDate>Tue, 20 Sep 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/find_exclude_hidden_files/</guid><description>&lt;h2 id="find-files-and-ignore-hidden--files"&gt;Find files and ignore hidden (&lt;code&gt;.*&lt;/code&gt;) files&lt;/h2&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;find /home/user ! -path &lt;span class="s1"&gt;&amp;#39;*/.*&amp;#39;&lt;/span&gt; -type f
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;/home/user&lt;/code&gt; with the folder you want to search.&lt;/li&gt;
&lt;li&gt;Change &lt;code&gt;-type f&lt;/code&gt; (files) to &lt;code&gt;-type d&lt;/code&gt; to find directories instead.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Virsh: find the display port of a VM</title><link>https://tlnd.org/Linux/kvm/</link><pubDate>Tue, 13 Sep 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/kvm/</guid><description>&lt;h1 id="get-the-local-display-port-of-a-vm"&gt;Get the local display port of a VM&lt;/h1&gt;
&lt;p&gt;List all running VMs:&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;# virsh list&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Id Name State
&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="m"&gt;1&lt;/span&gt; debian12 running
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;4&lt;/span&gt; AGENDA running
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Find the local display port:&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;# virsh domdisplay --domain debian12&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;spice://127.0.0.1:5900
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Bash OTP Generator</title><link>https://tlnd.org/Linux/bash_otp_generator/</link><pubDate>Sun, 05 Jun 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/bash_otp_generator/</guid><description>&lt;h1 id="create-an-otp-mfa-tool-in-the-bash-terminal"&gt;Create an OTP MFA Tool in the Bash Terminal&lt;/h1&gt;
&lt;p&gt;I was tired of using &lt;strong&gt;Google Authenticator&lt;/strong&gt;, so I found a simple way to generate my own &lt;strong&gt;OTP (One-Time Password)&lt;/strong&gt; codes directly in &lt;strong&gt;Bash&lt;/strong&gt;.&lt;br&gt;
Just replace the example string below (&lt;code&gt;JHJH...&lt;/code&gt;) with your own secret key.&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;/usr/bin/oathtool -b --totp &lt;span class="s1"&gt;&amp;#39;JHJHJHJHJHJHJHJHJHJHJHJHJ&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to copy the token directly to your clipboard, just use &lt;strong&gt;xclip&lt;/strong&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;/usr/bin/oathtool -b --totp &lt;span class="s1"&gt;&amp;#39;JHJHJHJHJHJHJHJHJHJHJHJHJ&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; xclip -selection c
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This way, you can easily run your own OTP generator right in the terminal.&lt;/p&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>Extract the Public Key from a Private Key with OpenSSL</title><link>https://tlnd.org/Linux/ssl/extract-publickey-from-privatekey-openssl/</link><pubDate>Fri, 15 Apr 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/extract-publickey-from-privatekey-openssl/</guid><description>&lt;h1 id="extract-the-rsa-public-key-from-a-private-key"&gt;Extract the RSA public key from a private key&lt;/h1&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;# write the public key to a file (works for RSA, EC and Ed25519 keys)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl pkey -in domain.tld.key -pubout -out domain.tld.pubkey
&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;# show the public key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl pkey -in domain.tld.pubkey -pubin -noout -text
&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;# the same with the RSA-only command&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl rsa -in domain.tld.key -pubout -out domain.tld.pubkey
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&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>Permissions</title><link>https://tlnd.org/Linux/permissions/</link><pubDate>Sat, 12 Mar 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/permissions/</guid><description>&lt;h1 id="copy-permissions-and-ownership-from-one-file-to-another"&gt;Copy permissions and ownership from one file to another&lt;/h1&gt;
&lt;h2 id="chmod"&gt;chmod&lt;/h2&gt;
&lt;p&gt;To copy the permissions of one file to another, use &lt;code&gt;chmod&lt;/code&gt; with the &lt;code&gt;--reference&lt;/code&gt; option. Instead of specifying a mode (such as octal permissions like &lt;code&gt;644&lt;/code&gt;), you point to a reference file whose permissions are copied:&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;chmod --reference&lt;span class="o"&gt;=&lt;/span&gt;reference_file target_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="chown"&gt;chown&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;chown&lt;/code&gt; works the same way for the owner and group:&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;chown --reference&lt;span class="o"&gt;=&lt;/span&gt;reference_file target_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add &lt;code&gt;-R&lt;/code&gt; to apply it recursively to a whole directory.&lt;/p&gt;</description></item><item><title>SSL Rehash and File Permissions</title><link>https://tlnd.org/Linux/ssl/ssl-rehash-and-filepermissions/</link><pubDate>Sun, 06 Mar 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/ssl-rehash-and-filepermissions/</guid><description>&lt;h1 id="rehash-certificates-and-set-file-permissions"&gt;Rehash certificates and set file permissions&lt;/h1&gt;
&lt;p&gt;A script I use in a certificate folder. It:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;creates the OpenSSL hash links (&lt;code&gt;&amp;lt;hash&amp;gt;.0&lt;/code&gt;) for the CA bundle and the certificate bundles,&lt;/li&gt;
&lt;li&gt;builds &lt;code&gt;ssl-bundle.crt&lt;/code&gt; (certificate + CA bundle),&lt;/li&gt;
&lt;li&gt;makes certificates read-only (&lt;code&gt;0444&lt;/code&gt;) and keys readable by the owner only (&lt;code&gt;0400&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;gives the files to the web server user (default &lt;code&gt;nginx&lt;/code&gt;, or the user/group you pass as arguments).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Run it inside the certificate folder: &lt;code&gt;./rehash.sh [user] [group]&lt;/code&gt;&lt;/p&gt;</description></item></channel></rss>