<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on ./Sam_Stelfox.sh</title><link>https://stelfox.net/notes/linux/</link><description>Recent content in Linux on ./Sam_Stelfox.sh</description><generator>Hugo</generator><language>en-US</language><copyright>Copyright © 2008, Sam Stelfox, all rights reserved.</copyright><atom:link href="https://stelfox.net/notes/linux/atom.xml" rel="self" type="application/rss+xml"/><item><title>Cron Daemon</title><link>https://stelfox.net/notes/linux/cron/</link><pubDate>Thu, 26 Oct 2017 17:35:42 -0400</pubDate><guid>https://stelfox.net/notes/linux/cron/</guid><description>&lt;p&gt;Cron is a pretty standard utility and there isn't much to it. I generally use &lt;code&gt;cronie&lt;/code&gt; as my cron daemon with the associated &lt;code&gt;anacron&lt;/code&gt; helper for systems that aren't always on such as laptops and desktops. Cron runs tasks periodically, and anacron helps ensure that a missed task will get run if it was off or power-cycled when it would have otherwise run.&lt;/p&gt;
&lt;h2 id="file-format"&gt;File Format&lt;/h2&gt;&lt;p&gt;The configuration format differs slightly between crontabs, regular cron files, and anacron entries. At the beginning of all the files environment variables can be set using key/value pairs to tweak the settings of followed by entries for that file one to a line. The first five portions of the cron and crontab entry format consist of numbers, steps, ranges, lists, or the wildcard (*) character.&lt;/p&gt;</description></item><item><title>Server Naming Convention</title><link>https://stelfox.net/notes/linux/naming-scheme/</link><pubDate>Fri, 20 Oct 2017 19:59:02 -0400</pubDate><guid>https://stelfox.net/notes/linux/naming-scheme/</guid><description>&lt;p&gt;Over the years I've found myself using many different naming schemes for
servers under my control. I came across a &lt;a href="http://mnx.io/blog/a-proper-server-naming-scheme/"&gt;naming convention&lt;/a&gt; that finally
feels correct. That blog post is quite well written and will let it stand on
its own. In the event it ever disappears the important bits (and those where
I've personalized it) are included here.&lt;/p&gt;
&lt;p&gt;There are ultimately two or three DNS names that each host receives. The first
is a permanent unique identifier for the host. The blog post offers the
&lt;a href="http://web.archive.org/web/20090918202746/http://tothink.com/mnemonic/wordlist.html"&gt;mnemonic encoding&lt;/a&gt; project as a way to generate the hostnames. I've built
&lt;a href="https://github.com/sstelfox/dotfiles/blob/master/bin/server_name_generator"&gt;my own generator&lt;/a&gt; that accomplishes the same effect with a vastly larger
potential space (not that I need it). It has the added bonus of generating
interesting names that are easy to talk about. Some samples (none real):&lt;/p&gt;</description></item><item><title>Mutt</title><link>https://stelfox.net/notes/linux/mutt/</link><pubDate>Fri, 20 Oct 2017 12:51:00 -0400</pubDate><guid>https://stelfox.net/notes/linux/mutt/</guid><description>&lt;p&gt;I keep a copy of my mutt config &lt;a href="https://stelfox.net/note_files/mutt/muttrc"&gt;here on the site&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="vim"&gt;Vim&lt;/h2&gt;&lt;p&gt;Since I use vim as my editor I also added the following line to my vim
configuration file to autowrap my lines at 72 characters, but only for mutt
composed messsages.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;au BufRead /tmp/mutt-* set tw=72&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Time</title><link>https://stelfox.net/notes/linux/time/</link><pubDate>Fri, 13 Oct 2017 12:30:23 -0400</pubDate><guid>https://stelfox.net/notes/linux/time/</guid><description>&lt;p&gt;This is a very basic operation on a Linux system, but I have to interact with
it so rarely since I run chrony on all my machines.
Occasionally, I find a device that needs a helping hand.&lt;/p&gt;
&lt;p&gt;On a device with a known good time (or approximate enough):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date +%s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This will get you the current unix timestamp. On the target system needing
updating as root (replacing &lt;code&gt;&amp;lt;unix timestamp&amp;gt;&lt;/code&gt; with the results from the last
command):&lt;/p&gt;</description></item><item><title>Disk Errors</title><link>https://stelfox.net/notes/linux/disk-errors/</link><pubDate>Mon, 09 Oct 2017 23:05:43 +0000</pubDate><guid>https://stelfox.net/notes/linux/disk-errors/</guid><description>&lt;p&gt;A collection of disk-related errors and their fixes.&lt;/p&gt;
&lt;h2 id="block-size-mismatch-warning"&gt;Block Size Mismatch Warning&lt;/h2&gt;&lt;p&gt;After writing an ISO to a flash drive, partitioning tools may complain:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&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;Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This happens when a tool like dd writes at the ISO's native 2048-byte block size onto a device that uses 512-byte sectors. Zeroing the first few blocks sometimes helps:&lt;/p&gt;</description></item><item><title>Data Recovery</title><link>https://stelfox.net/notes/linux/data-recovery/</link><pubDate>Tue, 01 Jan 2013 00:00:01 +0000</pubDate><guid>https://stelfox.net/notes/linux/data-recovery/</guid><description>&lt;h2 id="recovering-data-from-swap"&gt;Recovering Data from Swap&lt;/h2&gt;&lt;p&gt;Sometimes useful bits of information can be recovered from swap. Whether it's encryption keys, documents that were being worked on or anything else that might've ended up in RAM. To search through the swap for interesting bits (and depending on the size this might take a while) you can execute the following command as root or sudo to do it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;#&lt;/span&gt; strings &lt;span class="sb"&gt;`&lt;/span&gt;/bin/swapon -s &lt;span class="p"&gt;|&lt;/span&gt; tail -1 &lt;span class="p"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; less
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The command above uses the swapon utility to list all of the swap devices in use; look at the last line of the output (most people only have one swap device); extract only the path to the device node. Run the strings utility (which prints only printable strings of text from whatever you run through it) on the swap device. Break the output down by pages.&lt;/p&gt;</description></item><item><title>Gatekeeper Script for SSH</title><link>https://stelfox.net/notes/linux/gatekeeper-script-for-ssh/</link><pubDate>Tue, 01 Jan 2013 00:00:01 +0000</pubDate><guid>https://stelfox.net/notes/linux/gatekeeper-script-for-ssh/</guid><description>&lt;p&gt;The gatekeeper pattern adds a post-authentication challenge to SSH sessions
using ForceCommand. The concept was inspired by a scene in a movie where a
system required answering riddles before granting access. While not a substitute
for proper multi-factor authentication, it adds a lightweight additional
verification step.&lt;/p&gt;
&lt;p&gt;If you have already set up SSH key authentication with a passphrase on your key,
you have a decent form of multi-factor authentication already. The gatekeeper
script layers on one more check by prompting the user with a challenge after
they have authenticated.&lt;/p&gt;</description></item><item><title>GPSd</title><link>https://stelfox.net/notes/linux/gpsd/</link><pubDate>Tue, 01 Jan 2013 00:00:01 +0000</pubDate><guid>https://stelfox.net/notes/linux/gpsd/</guid><description>&lt;h2 id="installation"&gt;Installation&lt;/h2&gt;&lt;p&gt;Install gpsd and optionally the client tools. On a headless server you'll probably want to skip &lt;code&gt;gpsd-clients&lt;/code&gt; as they pull in X dependencies for &lt;code&gt;xgps&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;span class="lnt" id="2"&gt;&lt;a class="lnlinks" href="#2"&gt;2&lt;/a&gt;
&lt;/span&gt;&lt;span class="lnt" id="3"&gt;&lt;a class="lnlinks" href="#3"&gt;3&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; pacman -S gpsd &lt;span class="c1"&gt;# Arch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; apt install gpsd &lt;span class="c1"&gt;# Debian/Ubuntu&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; dnf install gpsd &lt;span class="c1"&gt;# Fedora&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="configuration"&gt;Configuration&lt;/h2&gt;&lt;p&gt;My GPS device is identified by udev as a serial port, which is fairly common as NMEA specifies a serial connection with a baud rate of 4800. There is an issue, however, with a program running in the background called &lt;code&gt;modem-manager&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>libvirtd</title><link>https://stelfox.net/notes/linux/libvirtd/</link><pubDate>Tue, 01 Jan 2013 00:00:01 +0000</pubDate><guid>https://stelfox.net/notes/linux/libvirtd/</guid><description>&lt;p&gt;libvirt is an open source API and management tool for managing platform
virtualization. It is used to manage Linux KVM and Xen virtual machines through
graphical interfaces such as Virtual Machine Manager and higher level tools
such as oVirt. In this case the backend is KVM.&lt;/p&gt;
&lt;h2 id="security-notes"&gt;Security Notes&lt;/h2&gt;&lt;p&gt;Since libvirtd distributes resources to guest machines a tight control needs to
be placed on the guests to prevent the host from becoming unmanageable. Luckily
through the use of CGroups this can be accomplished.&lt;/p&gt;</description></item><item><title>LM Sensors</title><link>https://stelfox.net/notes/linux/lm-sensors/</link><pubDate>Tue, 01 Jan 2013 00:00:01 +0000</pubDate><guid>https://stelfox.net/notes/linux/lm-sensors/</guid><description>&lt;p&gt;Useful for monitoring system statistics such as CPU core temperatures, fan speeds, and voltages.&lt;/p&gt;
&lt;h2 id="setup"&gt;Setup&lt;/h2&gt;&lt;p&gt;After installing the &lt;code&gt;lm_sensors&lt;/code&gt; package, run &lt;code&gt;sensors-detect&lt;/code&gt; as root to walk through loading any kernel modules necessary to read sensor data:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;#&lt;/span&gt; sensors-detect
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This will probe for hardware monitoring chips and offer to add the detected modules to your system's module loading configuration. Once done, run &lt;code&gt;sensors&lt;/code&gt; to see the output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt" id="1"&gt;&lt;a class="lnlinks" href="#1"&gt;1&lt;/a&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; sensors
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="watching-values"&gt;Watching Values&lt;/h2&gt;&lt;p&gt;For continuous monitoring, use the &lt;code&gt;-u&lt;/code&gt; flag for raw values or watch for changes:&lt;/p&gt;</description></item></channel></rss>