Adventures in Linux – Newline in file names

I just learned something about Linux that everyone should know to watch out for.

Image
Newlines in file name

In case you do not know what you are looking at, the image is demonstrating Linux’s support for wired file names.

How to Install and Setup Matterbridge

For those of you who do not know, Matterbridge (https://github.com/42wim/matterbridge/) is an application that bridges two or more channels/rooms from 1 or more chat platforms to each other so that users in each can talk to each other.

Being a statically linked, single binary, installation is fairly easy. Configuration is also fairly simple. However some people know more then others. This guide will is intended to help anyone host their own bridge.


Table of contents

Install on Windows

Go to https://github.com/42wim/matterbridge/releases/ and Download the binary for your system. This is most likely going to be windows-64bit.exe. Put it into the folder of your choice. I would recommend making an empty folder, but it is not required that you do so. Open a command Windows by clicking an empty part of the windows to make sure nothing is selected. Them press shift+right-click and select either “Open in Windows Terminal”, or “Open Powershell Window Here”.

Image

This should open a command window that you can run the app in. Run .\matterbridge-1.22.2-windows-64bit.exe in the command window. If all is well, you should see an error like the one below saying that it cannot load the config file. This is normal as we have not created it yet. Proceed to the Configuring section to build the config file.

Image

Installing under Linux

In your favorite browser, https://github.com/42wim/matterbridge/releases and download the binary for your platform. In my case, it is matterbridge-1.22.2-linux-armv6. Put it in the folder of your choice. I prefer to put it in a dedicated directory, but that is up to you.

From a command shell, make it executable by running chmod +x matterbridge-1.22.2-linux-armv6, replacing matterbridge-1.22.2-linux-armv6 with the file you downloaded. Run it with ./matterbridge-1.22.2-linux-armv6, substituting as necessary. If all is well, you should get an error saying that it cannot read the config file. We will build it next.

Image

Other platforms

I do not have other systems to test it on. However, the commands are likely to be similar to the ones for Linux. I also expect that you know more about your system that I do, and that you know how to download a file and run and application on it.

Building your config.

Steps for all possible platforms are available at https://github.com/42wim/matterbridge/wiki/How-to-create-your-config.

Matterbridge uses gateways to bridge different protocols together. Gateways are like a hub where messages are sent to, then copied by each protocol driver. Multiple gateways can be configured, and one instance can have multiple gateways running. A protocol can be setup multiple times. Each configuration on a protocol is called an instance throughout this guide.

Discord

Based off of https://github.com/42wim/matterbridge/wiki/Section-Discord-%28basic%29

Discord messages are relayed using bots. You can create a discord bot by going to https://discord.com/developers/applications and clicking new application. Name the app when prompted.

Image

One the app is created, you will be taken to the general information page. Here you can Rename your app or give the app an optional Description and image. You can change the information here at any time. Once you are ready, click the Bot link on the left side to open the Bot page.

Image

On the Bot page, click Add Bot, then Yes, do it!. This will create a new bot. You can also create a new bot on an existing app as well.

Image

We are now ready to create the configure Matterbridge to use the bot. Create a config file if you haven’t already. Paste the following code snippet near the top of the file.

[discord.mydiscord]
# You can get your token by following the instructions on
# https://github.com/42wim/matterbridge/wiki/Discord-bot-setup
# in particular that the "Members Intent" checkbox is important.
# If you want roles/groups mentions to be shown with names instead of ID, 
# you'll need to give your bot the "Manage Roles" permission.
Token="YOUR_TOKEN_HERE"
Server="name or uid of guild" # picked from guilds the bot is connected to
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

Replace YOUR_TOKEN_HERE with the bot token. You can get it by clicking Copy button which will copy the token to your clipboard. Paste it into the config file. We will get the server id next.

Image

In order for the bot to work, you need to enable Server Members Intent. Scroll down to Privileged Gateway Intents and enable the Server Members Intent switch.

Image

Now you will need to add the bot to the server you want to bridge. Click the OAuth2 button and select bot under scopes, then click the Copy button. This will give you the URL to add the bot to the server with. Paste it in a browser tab and press enter to go to the page.

Image

Select the server that you want to add the bot to from the dropdown and click Authorize. Note: You will need to have Manage Server permission on the server to add the bot to it.

Image

Once the bot is added, you will need to get the server ID. To do so, go to your user setting > Advanced and enable Developer Mode.

Image

Close the Settings page and open the server you added the bot to. Right+Click on the server name and click Copy ID. Just clicking on the Server name will not work. Go back to the config file and set the Server field to the ID you just copied. You are now ready to add the instance to a Gateway. Set the Channel in the gateway to the Channel name in the server.

Image

TODO: Write out a detailed tutorial for Telegram.

Telegram

Based off of https://github.com/42wim/matterbridge/wiki/Section-Telegram-%28basic%29

Telegram messages are relayed using bots. Full instructions to create a bot are at https://core.telegram.org/bots#6-botfather.

To create a bot, start a chat with @botfather in Telegram. Click start to begin a conversation. Send /newbot. Give it a name and a username. Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot’s username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.

Image
Creating a bot with BotFather. Using Unigram, an unofficial Telegram client.

Next, you need to set the Privacy mode of the bot to disabled for Mattermost to work properly with the bot. Otherwise it will only relay mentions. Do so by sending /setprivacy. Select Disable when prompted.

Image
Setting the bots privacy mode with BotFather. Using Unigram, an unofficial Telegram client.

Add the following template to your config. Replace Yourtokenhere with the token you got from BotFather.

[telegram.mytelegram]
#See https://core.telegram.org/bots#6-botfather 
#and https://www.linkedin.com/pulse/telegram-bots-beginners-marco-frau
Token="Yourtokenhere"
RemoteNickFormat="({PROTOCOL}) {NICK} "
MessageFormat="HTMLNick"

Matrix

Creating a Matrix bridge could not be more simple. First, create a dedicated user for your bot. This is not required, but Matterbirdge will not relay messages from the account it is logged in as.

Second, paste the following code block into your config, filling in the appropriate fields

[matrix.mymatrix]
#Server is your homeserver (eg https://matrix.org)
Server="https://matrix.org"
#login/pass of your bot.
#Use a dedicated user for this and not your own!
#Messages sent from this user will not be relayed to avoid loops.
Login="yourlogin"
Password="yourpass"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#Whether to send the homeserver suffix. eg ":matrix.org" in @username:matrix.org
#to other bridges, or only send "username".(true only sends username)
#OPTIONAL (default false)
NoHomeServerSuffix=false

Last, you will need to get the room ID. While the room name sometimes works, I have not had much success with it. To find it in Click on the room name > Advanced, and save the Internal room ID field. This is what you will use for the channel later.

Image

Configuring your gateway(s)

One of the nice things about Matterbridge is that is supports having multiple gateways, and multiple bridges in each gateway.

To create a gateway, go to the bottom of the config and create a gateway, using the following as a sample. Replace protocol with the protocol name, and myprotocol with the bridge name. Repeat with as many gateways as you want. Just make sure to give each gateway a uniqure name.

[[gateway]]
name="gateway1"
enable=true
[[gateway.inout]]
account="protocol.myprotocol"
channel="prtocolchannel"
[[gateway.inout]]
account="protocol2.myprotocol2"
channel="protocol2channel"

TODO: Write out a detailed tutorial for Mattermost.

TODO: Write out a detailed tutorial for IRC.

Additional help?

We have discussions at the Github repro. https://github.com/42wim/matterbridge/discussions. You can also read and open bugs on the issue tracker at https://github.com/42wim/matterbridge/issues. You can also chat with community members on any of several chat apps. https://github.com/42wim/matterbridge/#chat-with-us. Each room is bridged to each other using Matterbridge.

dd Mayhem Part 2 – Recovering my Hard Drives Content

This is a continuation of my previous post dd-mayhem – How I Overwrote my Linux Install. This is the post where I attempt to recover my hard drive data. I am writing this post as I go throughout this process with the help of @hbelusca and @oldman on the ReactOS chat.

This is a continuation of my previous post dd-mayhem – How I Overwrote my Linux Install. This is the post where I attempt to recover my hard drive data. I am writing this post as I go throughout this process with the help of @hbelusca and @oldman on the ReactOS chat.

My tools of choice

I am going into this recovery using the following tools:

  • Archlinux Live cd to run my tools from
  • dd to backup my disk beforehand.
  • TestDisk as my recovery tool of choice (suggested my @oldman)

Getting started

!Warning! The dd command is uses here. Please double check the command before using. !Warning!

Before I go playing around with testdisk, I decided to make a backup of my disk by running dd if=/dev/sda of=/mnt/hd.img where /dev/sda is my internal hard drive, verifiable with fdisk -l and /mnt is the mount point of a external USB drive that I freshly formatted beforehand. I also instaled testdisk with pacman -Sy testdisk

Doing the recovery

After doing the backup it is now time to start TestDisk. I started TestDisk by running testdisk, selected my drive, select Intel on the next screen (I am using MBR partitioning and that is what the docs said to use), started a quick scan, then selected the option to do a deep scan. Doing a deep scan found at least 20 possible partitions. It said it couldn’t recover most of the partitions (which were probally overwritten and too old to matter anyways. I selected ok, and got a list of partitions. Pressing p for each partition gives me a list of files that I can browse through. Press q to go back to the partition list (it sometimes took me back the the main menu). I am now ready to decide what partitions need to be restored.

After reviewing the files in the partitions, I am now able to make a decision on what partition to restore.

Time to get more help

After getting annoyed with pressing the wrong keys to many times and having to restart umpteen times, I am ready to ask someone else to help me.

If you have any thoughts, or any suggestions, please reply in the comments below.

Linux tips and advice

Whether you are a Linux newbie, or a long time user, there are probably times you want to learn some tips, or discover some advice on how to do something. This post is here to help you and others find tips and advice.

Whether you are a Linux newbie, or a long time user, there are probably times you want to learn some tips, or discover some advice on how to do something. This post is here to help you and others find tips and advice. Feel free to comment below to share some knowledge that is not listed here already.

To help organize, I have divided the rest of this post into sections to make it easier to find what you are looking for.

System Utilities

Disk Imaging

dd

  • Check because you run. dd didn’t get it’s nickname disk destroyer for no reason. Verify the command is built correctly before hitting enter. Be expessially careful when running it as root or with sudo. Here is an example of a dd command gon wrong.

Ping

  • Used to check connectivity.
  • Can be used to check on both ipv4 and ipv6.
  • Uses ICMP echo packets which can be blocked by firewalls.

dd Mayhem – How I Overwrote my Linux Install

If you have used the linux command line, you may have used dd to write disk images to disk. And if you have used dd, you may have heard the joke that dd means disk destroyer. You may find the joke funny, at least until you have set of to the wrong block device. Here is the story of how I learned what dd can do.

If you have used the linux command line, you may have used dd to write disk images to disk. And if you have used dd, you may have heard the joke that dd means disk destroyer. You may find the joke funny, at least until you have set of to the wrong block device. Here is the story of how I learned what dd can do.

The day was December 23, 2020. Just two days before Christmas. I had previously compiled a PR for ReactOS to test it, copied it to my Raspberry Pi 4b, and configured it to share the .iso file as a mass storage device over the USB port. After rebooting and choosing USB as my boot device, it loaded the drivers and went to a black screen which didn’t supprise me.

Booting ReactOS from my Raspberry Pi 4 in mass storage mode.

After trying a few times, I decided to try a more common method, use a physical USB drive. That is where my mistake came in. I verified that /dev/sdb was my USB drive with fdisk -l, formatting it with parted, I was ready to write my .iso file to my drive with dd. I ran the command sudo dd if=bootcd.iso of=/dev/sda. And there goes the first couple megabytes of data on my hard drive. That’s right, I overwrote the boot sector, boot partition, and who knows what else on my hard drive. Woopse. Look for part 2 where I will attempt to recover the data on my drive.

Comparison of Desktop and Mobile Operating Systems

I have grown up in a all windows environment, until about a year or 2 ago when I got a Linux laptop from my grandpa. The mobile operating systems in my house today are all Android, unless you count the school iPads (which I strongly dislike). I have also used Macbooks (which are almost an entirely different beast from iPads) last year, also for school. That puts me in a good position to compare and contrast these operating systems.

Notice! This is still a draft.

I have used many operating systems. Let me elaborate.

I have grown up in a all windows environment, until about a year or 2 ago when I got a Linux laptop from my grandpa. The mobile operating systems in my house today are all Android, unless you count the school iPads (which I strongly dislike). I have also used Macbooks (which are almost an entirely different beast from iPads) last year, also for school. That puts me in a good position to compare and contrast these operating systems.

A list of operating systems I have used

  • Windows xp (not compared here)
  • Windows vista (not compared here, but is simular to windows 7)
  • Windows 7 (my most favorite Windows version)
  • Windows 8 (my least favorite version)
  • Windows 10
  • Ubuntu Mate Linux (Ubuntu 19.04 (I believe) with a different desktop environment)
  • Linux’s Mint (also based on Ubuntu with the cinnamon desktop environment, has a few more default apps)
  • Archlinux (bare bones do it yourself distro
  • MacOS (previously known as OSX)
  • iOS (best knows as the OS that runs on iPads and iPhones)
  • Raspberry Pi OS (used to be called raspberrian)
  • Android
  • ReactOS (not compared here)

Features of each

Windows 7

  • Runs all apps from Vista to seven, runs many Windows 10 apps
  • Gadgets

Windows 8

  • Designed to run on tablets
  • Runs the same apps as Windows 7

Windows 10

  • Designed for both desktops and tablets
  • Runs same apps as Windows 7
  • Supporters UWP apps (technically, Windows 8 does, but most UWP apps don’t support it)
  • User friendly settings app
  • Native support for drawing tablets

Ubuntu Mate

  • Familiar to windows users
  • Fairly complete with many apps preinstalled
  • Built-in firewall (not enabled by default)
  • Supports most hardware

Linux Mint

  • Based off of Ubuntu

Archlinux

  • Small lightweight os
  • Command line only by default
  • Very few packages pre-installed
  • Hands-on, do it yourself install

MacOS

  • Seamless integration with Apple devices

iOS

  • Seamless integration with Apple devices
  • Very secure (possibly too secure)

Comparison

Windows VS. Linux

Comparing Windows to Linux is like comparing Houses to Skyscrapers. They both run apps and have a kernel (that not so little binary that makes all the magic happen). There is not to much to compare. But here is an attempt.

User interface

Windows is a GUI based OS. While some stuff can be done from cmd.exe, or more recently, powershell, unless you are using windows server core and Microsoft products, you are going to be forced to use a GUI. Linux, on the other hand, is driven from the command line with graphical interfaces built on top of linux commands.

Usability

Windows is fairly easy to use. Linux is harder to judge, depending on what tools you have. If you install a desktop environment such as Gnome, KDE, or Xfce, you get many GUI based tools. If you are a hardcore command line user, there are also many console driven applications available as well. You can also go modifying configuration files directly as many are plain text files.

Customizability

Being closed source, to customize Windows, you are limited to either to using what Microsoft has allowed, or reverse engineering. Linux, on the other hand, has infinite flexibility. Do what you want with it. If you wan’t, you could even make it run on your washing machine or microwave. Someone has even ported it to play station.

Newbe friendliness

Windows is fairly friendly to new users. Linux depends on what environment you have set up. When running a fairly complete desktop environment such as Gnome, KDE, or a fork of one of these, there are generally several tools that are included that can help all users. Plus, it is very easy to create configuration tools for linux because of it’s design. While windows does provide some GUI tools, they may not be as friendly as Linux tools, and there are not many alternatives

App compatibility

Windows is the most popular OS therefore many apps (and drivers) are written for windows first (oftentimes only for Windows). However, many apps are written for Linux (many of these apps are written for Linux first, then ported to Windows (or sometimes just work on Windows without much tinkering) by the community. Therefore, you should make sure that the apps you want work on your chosen OS. However, utilities such as cwygen (Linux on Windows) and Winehq (Windows on Linux) help with compatibility. However, you still need to ensure they work.

My opinion

I personally love Linux. However I like Windows as well. I will not say one is better then another without knowing the intended use case (at which point I would say better for…). I feel that each OS has their own strengths and weaknesses. Personally, unless somthing works better on Windows, I would stick with Linux, but everyone is different.

Windows VS. MacOS

Comparing Windows to MacOS is similar to comparing Windows to Linux, however, MacOS is easier to compare with as there is no Varity.

User interface

Both Windows and MacOS are designed to be driven with a GUI. Both have command line tools available. However these tools may not be as complete as the GUI counterparts.

Usability

Both Windows and MacOS are fairly user friendly. However, users coming to MacOS are likely to be confused for a bit due to the big differences in user interfaces.

Linux VS. MacOS

Conclusion

Using mutt mail client

I have recently discovered mutt (and neomutt which has a few patches that haven’t made it into mutt) in my search for a command line mail client. While it is a simple mail client that works nicely when a Display server is not available, or you choose to go command line only, there are a few things to be aware of when using it for the first time. I have set this program up fairly recently, and here is my experience.

I have recently discovered mutt (and neomutt which has a few patches that haven’t made it into mutt) in my search for a command line mail client. While it is a simple mail client that works nicely when a Display server is not available, or you choose to go command line only, there are a few things to be aware of when using it for the first time. I have set this program up fairly recently, and here is my experience.

Installing

I have installed neomutt on my Archlinux laptop. Unlike some packages I have installed on Arch, both mutt and neomutt were available in the arch repros to be installed with sudo pacman -S mutt or sudo pacman -S neomutt.

Configuring

The config file for mutt and neomutt go in a file in ~/.muttrc unless another is specified on the command line. Below is a sample config file that I use.

set editor=/opt/bin/nano
#-----------#
# Passwords #
#-----------#
#gpg --textmode -d ~/outlook.password.asc
#---------------#
# Account Hooks #
#---------------#
account-hook . "unset imap_user; unset imap_pass; unset tunnel" # unset first!
account-hook        "imaps://wyattcjackson2006@outlook.com@smtp.office365.com" "\
    set imap_user   = wyattcjackson2006@outlook.com\
        imap_pass   = ywqowraeupaewbcf"
# -------------------------- #
# Ignore unnecessary header  #
# -------------------------- #
ignore *                                                                        
unignore From: To: Cc: Date: Subject:   
#-------------------------------------#
# Folders, mailboxes and folder hooks #
#------------------------------------#
# Setup for wyattcjackson2006
  set folder          = imaps://wyattcjackson2006@outlook.com@smtp.office365.com/
  mailboxes           = +INBOX
  set spoolfile       = +INBOX
  folder-hook         imaps://wyattcjackson2006@outlook.com@smtp.office365.com"\
      set folder      = imaps://wyattcjackson2006@outlook.com@smtp.office365.com\
          spoolfile   = +INBOX \
          postponed   = +Drafts \
          record      = +'Sent Mail' \
          from        = 'Wyatt Jackson <wyattcjackson2006@outlook.com>' \
          realname    = 'Wyatt Jackson' \
          smtp_url    = smtp://wyattcjackson2006@outlook.com@smtp.office365.com:587\
          ssl_starttls = yes \
          smtp_pass   = ywqowraeupaewbcf"

Using mutt

Using mutt is fairly simple. Use the arrow keys to move up and down the listings (page up/down to move 1 screenful), [enter] to select mail, [q] to quit mutt, and [i] to leave the mail reader. [m] to compose new message and view drafts. More keybindings are listed at the top of the screen, and more can be configured.

More information

Design a site like this with WordPress.com
Get started