<?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>Linux on rooiratel</title><link>https://rooiratel.red/categories/linux/</link><description>Stephan Snyman's personal website</description><language>en-gb</language><generator>Hugo</generator><atom:link href="https://rooiratel.red/categories/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>When being root is not enough</title><link>https://rooiratel.red/posts/when-being-root-is-not-enough/</link><pubDate>Fri, 25 Nov 2022 15:19:31 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/when-being-root-is-not-enough/</guid><description>The other day, when I logged into my server, I realised that I hadn’t upgraded it in a while. Fedora 37 had just been released, so it was a good time for an upgrade. The process went smoothly, but I noticed after rebooting that the Caddy service failed to start. At first I thought that maybe something in the config was no longer compatible with the new version of Caddy. Everything checked out fine. When I manually executed the command in the caddy.service file then the service would start up without any issues.</description><content:encoded><![CDATA[<p>The other day, when I logged into my server, I realised that I hadn&rsquo;t upgraded it in a while. Fedora 37 had just been released, so it was a good time for an upgrade. The process went smoothly, but I noticed after rebooting that the <a href="https://caddyserver.com/">Caddy</a> service failed to start. At first I thought that maybe something in the config was no longer compatible with the new version of Caddy. Everything checked out fine. When I manually executed the command in the caddy.service file then the service would start up without any issues.</p>
<p>That was strange. The Caddyfile is owned by root, the caddy.service file is owned by root, and the service is executed and run as root. So it wasn&rsquo;t a permission issue.</p>
<p>Let&rsquo;s see what systemd has to say for itself.</p>
<p>I ran the command <code>journalctl -u caddy --no-pager | less</code>, and that is when I saw this:</p>
<p><code>caddy[736]: run: reading config file: open /the/path/to/Caddyfile: permission denied</code></p>
<p>So it was a permission issue after all. But how? Is being root not enough?</p>
<p>I furiously started searching the web and eventually stumbled upon <a href="https://stackoverflow.com/questions/51209967/systemd-service-file-failed-to-execute-command-permission-denied">this StackOverflow post</a>, which suggested that SELinux could cause this type of behaviour.</p>
<p>I temporarily disabled SELinux with <code>sudo setenforce Permissive</code> to see if it would fix my issue ‒ and it did. Cool, but why would SELinux cause the issue in the first place? What didn&rsquo;t it like about my caddy.service file?</p>
<p>To find out, I started with the <code>semanage fcontext --list</code> command. This is when I realised that I was storing my Caddyfile in a directory that SELinux didn&rsquo;t approve of. So my final solution was just to move it to a directory that SELinux was happy with. The last thing I needed to do was update the caddy.service file to point to the new location of the Caddyfile and restart the service.</p>
]]></content:encoded></item><item><title>2021 — Year of the Wayland</title><link>https://rooiratel.red/posts/2021-year-of-the-wayland/</link><pubDate>Wed, 24 Mar 2021 18:53:09 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/2021-year-of-the-wayland/</guid><description>Recently, I decided to replace the hard drive that was running my OS. It was getting old, and I don’t want to deal with boot issues if the drive starts failing. I decided that when my new hard drive was delivered, I would not just copy everything from the old one to the new one. It’s a chance for a fresh start — maybe I’ll try a new window manager, and I think it’s about time I switched to Wayland since the xorg devs have largely abandoned that project. I’ve also been hearing cool things about PipeWire, so why not give that a shot as well?</description><content:encoded><![CDATA[<p>Recently, I decided to replace the hard drive that was running my OS. It was getting old, and I don&rsquo;t want to deal with boot issues if the drive starts failing. I decided that when my new hard drive was delivered, I would not just copy everything from the old one to the new one. It&rsquo;s a chance for a fresh start &mdash; maybe I&rsquo;ll try a new window manager, and I think it&rsquo;s about time I switched to Wayland since the xorg devs have largely abandoned that project. I&rsquo;ve also been hearing cool things about PipeWire, so why not give that a shot as well?</p>
<p>So that&rsquo;s exactly what I did, and with some rather pleasant results, which led me to believe that 2021 really is the year of the Wayland desktop.</p>
<h1 id="history">History</h1>
<p>When I first heard about Wayland in about 2011, I really hoped that it would succeed, as I hated dealing with xorg.conf. Version 1.0 was released on 22 October 2012 and was met with many complaints that it couldn&rsquo;t perform basic tasks expected by users. It was also around this time that RebeccaBlackOS, a joke distro, became the first distro to support Wayland officially. [0][1] So Wayland was at least stable enough to be used as a meme but not yet for everyday use.</p>
<p>I waited a little bit longer.</p>
<p>At the end of 2016, Fedora 25 was released with official Wayland support. [2] So it was getting serious. However, I still saw a number of complaints on Hacker News and Reddit about things that sounded like deal-breakers to me.</p>
<p>I waited a little bit longer.</p>
<h1 id="2021">2021</h1>
<p>From 2016 onwards, I saw sporadic posts online by people who used Wayland everyday without any issues. My general impression was that unless you had very specific requirements, it should work for you.</p>
<p>At this point, I wanted to see for myself. I had a chuckle when, the day after I ordered my new hard drive, <a href="http://www.fosskers.ca/en/blog/wayland">this</a> blog post showed up on Hacker News and Reddit; the following day I found <a href="https://shibumi.dev/posts/wayland-in-2021/">this one</a>. It seems many people are switching to Wayland in 2021, which is why I am dubbing it the &ldquo;Year of the Wayland&rdquo;.</p>
<p>Not only that, but I see a lot of activity in the development world for supporting Wayland. Recently, one of the <a href="https://obsproject.com/">OBS Studio</a> devs got it working natively on Wayland.[3] That&rsquo;s great news for streamers. I also see that even XFCE is looking into adding Wayland support soon! [4]</p>
<h1 id="before-vs-after">Before vs After</h1>
<p>The biggest visual change to my setup would be my window manger. I was using <a href="https://github.com/baskerville/bspwm">BSPWM</a> before, but it didn&rsquo;t support Wayland. As far as I could tell, <a href="https://swaywm.org/">Sway</a> was the most mature tiling window manager. It works really well and I&rsquo;ve had zero issues with it so far.</p>
<p>As for <a href="https://pipewire.org/">PipeWire</a> vs PulseAudio, I am blown away by how well PipeWire is working considering how new it is. All I had to do was install the <code>pipewire</code> package and my sound worked out of the box. The only small snag was that some software <em>requires</em> PulseAudio (Firefox for example). But I just installed the <code>pipewire-pulse</code> package, and everything worked perfectly.</p>
<h1 id="software-that-required-some-tweaks">Software That Required Some Tweaks</h1>
<h3 id="browser">Browser</h3>
<p>I only use Firefox as my browser. To get native Wayland support for Firefox, all I had to do was set the following environment variable <code>MOZ_ENABLE_WAYLAND=1</code>. After restarting Firefox, you can confirm that your changes have been applied by going to the <code>about:support</code> page and checking that the value of &ldquo;Window Protocol&rdquo; is &ldquo;wayland&rdquo;.</p>
<p>Even while Firefox was still running through <code>xorg-xwayland</code> it was fast, and I didn&rsquo;t notice any weird behaviour.</p>
<h3 id="music">Music</h3>
<p>I previously used <a href="https://quodlibet.readthedocs.io/en/latest/">quodlibet</a> as my music player. However, for the last few months I&rsquo;ve been trying out <a href="https://tauonmusicbox.rocks/">Tauon Music Box</a>, which I prefer. It&rsquo;s made entirely in <a href="https://www.libsdl.org/">SDL</a>, meaning it also works natively on Wayland.</p>
<p>To get any SDL software to run natively on Wayland, it&rsquo;s as easy as setting the <code>SDL_VIDEODRIVER=wayland</code> environment variable.</p>
<h3 id="gaming">Gaming</h3>
<p>I enjoy gaming, but I would by no means call myself a serious gamer. I almost exclusively play games via Steam, and I thank Valve for all the investment they have put into the Linux ecosystem over the years. (If a studio only publishes their game on a platform that doesn&rsquo;t support Linux, then I guess they don&rsquo;t want my money.)</p>
<p>A lot of Linux games on Steam come bundled with SDL. Some of them make use of the SDL library that is part of the Steam Runtime, others use their own. To get them to work (without interfering with other SDL applications), just add <code>SDL_VIDEODRIVER=x11 %command%</code> to the launch options for the game. This worked on every game I tried.</p>
<p>I noticed that for CS:GO I was getting the same FPS as I was before switching to Wayland.</p>
<p>For DOTA2 (the Vulkan version) the game was getting capped at 60FPS, even with V-sync turned off. There are workarounds for this. I&rsquo;m personally not bothered by it, but if you are, you can read a detailed explanation <a href="https://www.reddit.com/r/linux_gaming/comments/1upn39/sdl2_adds_dynamic_api_magic_to_allow_updating_it/">here</a>. Either way, I&rsquo;m sure valve will update the SDL lib bundled with DOTA2 in the future.</p>
<h1 id="thoughts-so-far">Thoughts So Far</h1>
<p>Wayland works so well I don&rsquo;t even notice it. Most of the software I used before functions fine on Wayland (or via <code>xorg-xwayland</code>); for the software that doesn&rsquo;t work, there are replacements. [7] There are still a few programs that need to run through <code>xorg-xwayland</code>, but it doesn&rsquo;t really make a significant difference.</p>
<p>I can safely say that 2021 is the &ldquo;Year of the Wayland&rdquo; since, for most common use cases, you can use it everyday without a single complaint. As for the remaining edge cases there are plenty of developers who are devoting a lot of their time to addressing those concerns.</p>
<h1 id="references">References</h1>
<pre><code>[0] https://www.ubuntuvibes.com/2012/02/live-os-running-wayland-display-server.html
[1] https://www.phoronix.com/scan.php?page=news_item&amp;px=Wayland-RBOS-2020-Release
[2] https://fossbytes.com/new-features-fedora-25-linux-releasing-november-15/
[3] https://feaneron.com/2021/03/30/obs-studio-on-wayland/
[4] https://wiki.xfce.org/releng/wayland_roadmap
[5] https://www.theregister.com/2020/10/30/x_server_lead_maintainer_declares/
[6] https://www.phoronix.com/scan.php?page=news_item&amp;px=XServer-Abandonware
[7] https://arewewaylandyet.com/
</code></pre>
]]></content:encoded></item><item><title>Convert All Word Documents to .odt</title><link>https://rooiratel.red/posts/convert-all-word-docs-to-odt/</link><pubDate>Sun, 20 Sep 2020 09:38:46 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/convert-all-word-docs-to-odt/</guid><description>This post is not about a quick one-liner script that you can run to convert all Word documents on your PC to .odt files. But if that’s what you are looking for, here you go:
find ./ -type f \( -iname \*.doc -o -iname \*.docx \) -exec libreoffice --headless --convert-to odt {} \;
Just replace the ./ with the directory you want to recursively search in. Also note that this command creates a copy that is converted and does not delete the original document.</description><content:encoded><![CDATA[<p>This post is <strong>not</strong> about a quick one-liner script that you can run to convert all Word documents on your PC to .odt files. But if that&rsquo;s what you are looking for, here you go:</p>
<p><code>find ./ -type f \( -iname \*.doc -o -iname \*.docx \) -exec libreoffice --headless --convert-to odt {} \;</code></p>
<p>Just replace the ./ with the directory you want to recursively search in. Also note that this command creates a copy that is converted and does not delete the original document.</p>
<p>I have dozens of old Word documents on my computer dating back to my childhood days. I finally decided to do a bit of a cleanup and convert them all to .odt so that they are in an open file format that I can trust.</p>
<p>And instead of converting them all in one go using the script above, I decided to do them one by one, and see how well it worked, and to make sure I didn&rsquo;t lose anything.</p>
<p>I started of just seeing how many I had:</p>
<p><code>find ./ -type f \( -iname \*.doc -o -iname \*.docx \) | wc -l</code></p>
<p>Which came to 1996. damn, way more than I thought. Looking through the results (without piping it to wc) I see there are a lot of old school assignments and notes, some programming notes, a lot of music (mainly chord sheets), and finally just some miscellaneous documents.</p>
<p>Most of the documents I no longer needed (like schoolwork) but I converted a lot of them anyway just to see how well it would work. I ended up deleting most of these documents.</p>
<h3 id="what-i-learned">What I learned</h3>
<p>Practically all of the word documents I had were just simple text documents and the occasional image. I had zero problems converting these.</p>
<p>A lot of my school assignments made use of math formulas and tables, and I&rsquo;d say about 99% of them converted without any issue. Not that it mattered because I deleted all my school work afterwards.</p>
<p>What I found interesting after converting a whole bunch of files was that for small files (less than ~20KB) the .odt version was larger than the .docx version. But if the original file was any larger than that, then the file actually got smaller after converting to .odt.</p>
]]></content:encoded></item><item><title>exFAT</title><link>https://rooiratel.red/posts/exfat/</link><pubDate>Sun, 14 Jun 2020 10:59:12 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/exfat/</guid><description>Now that Linux 5.7 has been released containing the new Samsung implementation of their exFAT driver, it is time to format all my removable storage media to exFAT.[0]
Why? Previously, I would always format my external hard drives and memory sticks as NTFS even though I only use Linux. This was because the default FAT32 file system does not support files larger than 4GB (and NTFS does), and also, if I need to share files with people who use Windows or Mac, they can read the NTFS file system. Windows natively, and Linux and Mac via ntfs-3g.[1] This worked OK, but it was annoying having to use a FUSE-based solution that is quite slow.</description><content:encoded><![CDATA[<p>Now that Linux 5.7 has been released containing the new Samsung implementation of their exFAT driver, it is time to format all my removable storage media to exFAT.[0]</p>
<h1 id="why">Why?</h1>
<p>Previously, I would always format my external hard drives and memory sticks as NTFS even though I only use Linux. This was because the default FAT32 file system does not support files larger than 4GB (and NTFS does), and also, if I need to share files with people who use Windows or Mac, they can read the NTFS file system. Windows natively, and Linux and Mac via ntfs-3g.[1] This worked OK, but it was annoying having to use a FUSE-based solution that is quite slow.</p>
<h1 id="how">How?</h1>
<p>Start by installing exfatprogs so that you have what you need to format to exFAT.[2]</p>
<p>On Arch Linux, that&rsquo;s just:</p>
<p><code>sudo pacman -S exfatprogs</code></p>
<p>Next, you need to get a list of disks on your system so that you know which one to format. Personally, I like to list them all, then plug in my intended target, then list again. That way, you know for sure which disk is the removable one - even if it was otherwise obvious. I never take any risks when it comes to formatting drives with data on them.</p>
<p><code>fdisk -l</code></p>
<p>Now that you know which device to use, run the command below. Set your own label and specify the correct drive.</p>
<p><code>sudo mkfs.exfat -n LABEL /dev/sdX</code></p>
<p>Finally, run a check to make sure everything went smoothly.</p>
<p><code>sudo fsck.exfat /dev/sdXn</code></p>
<p>Now, I can use my removable storage devices on any OS and with native kernel drivers!</p>
<h1 id="references">References</h1>
<pre tabindex="0"><code>[0] https://kernelnewbies.org/Linux_5.7#New_exFAT_file_system
[1] https://www.tuxera.com/company/open-source/
[2] https://github.com/exfatprogs/exfatprogs
</code></pre>]]></content:encoded></item><item><title>Secure disk wipe</title><link>https://rooiratel.red/posts/secure-disk-wipe/</link><pubDate>Wed, 31 Oct 2018 16:22:03 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/secure-disk-wipe/</guid><description>Secure disk wipe I recently got a new work laptop. Obviously I needed to transfer all my files from the old laptop to the new one. This is a pretty painless process. Normally I just format the disk on the old laptop when I’m done with it and hand it in.
However there are a lot of confidential files and data on my work laptop, and a simple format is not enough to get rid of them. It’s quite easy to recover files from a laptop that have not been deleted securely, and I didn’t want to be held liable if someone were to get hold of the files from my old laptop. I have no guarantees of what the person I hand my laptop to might do with it. It could get stolen, they might be bribed to hand over the hard drive to criminals etc.</description><content:encoded><![CDATA[<h1 id="secure-disk-wipe">Secure disk wipe</h1>
<p>I recently got a new work laptop. Obviously I needed to transfer all my files from the old laptop to the new one. This is a pretty painless process. Normally I just format the disk on the old laptop when I&rsquo;m done with it and hand it in.</p>
<p>However there are a lot of confidential files and data on my work laptop, and a simple format is not enough to get rid of them. It&rsquo;s quite easy to recover files from a laptop that have not been deleted securely, and I didn&rsquo;t want to be held liable if someone were to get hold of the files from my old laptop. I have no guarantees of what the person I hand my laptop to might do with it. It could get stolen, they might be bribed to hand over the hard drive to criminals etc.</p>
<p>So what should I do? Luckily Linux has a useful program called <code>shred</code> which will overwrite a file with garbage multiple times before it deletes it. This is a great solution, but it&rsquo;s rather tedious to run <code>shred</code> manually on multiple files on my hardrive.</p>
<p>My final solution was to use a combination of <code>find</code> and <code>shred</code> to recursively delete all the files and directories from a given directory. In this case, my <code>/home/</code> directory.</p>
<p>Here is the command:</p>
<p><code>find /home/rooiratel/ -type f -exec shred -u -v {} \;</code></p>
<p>Where <code>/home/rooiratel/</code> is the root directory of where you want to start deleting from.</p>
<p>Another useful task this does is to rename each file to a series of 0&rsquo;s before deleting it. I still need to figure out how to do this for directories.</p>
<p>Here is a screenshot of this command in action:</p>
<p><picture>
  
  

  

  
    

    <source srcset="/images/find_shred.avif" type="image/avif" >

    
    

    

  

  <figure>
    <img
      src="/images/find_shred.png"
      alt="screenshot"
      loading="lazy"
      decoding="async"
      width="485"
      height="981"
    />
	<figcaption></figcaption>
  </figure>
</picture>
</p>
<p>You can set the number of times you want <code>shred</code> to overwrite your files with the -n flag. The default is 3, but depending on how paranoid you are or how much time you have, you can set it as high as you like.</p>
<p>Once all of this is done you can format your hard drive as usual and hand in the device. Even if it gets stolen, or handed to a compromised employee, you won&rsquo;t have to worry that you have inadvertently leaked confidential company files/data.</p>
]]></content:encoded></item></channel></rss>