Technology Support Articles

(A number of articles have been removed due to those articles being about nonfree software.)

Connecting to WiFi on a Systemd-based GNU/Linux distro using only the command line and standard utilities

You first want to scan for WiFi networks. My laptop's WiFi adapter interface is wlp2s0. Replace this if yours is different.

Hint: If you need to check what your adapter's interface is, you may use IWCONFIG(8) for that.

# iwconfig Assuming you know your WiFi network's name already, you can skip this step You can list available networks using IWLIST(8) with the following command:
# iwlist wlp2s0 scan
To connect to your network, you can use WPA_SUPPLICANT(8). Using WPA_PASSPHRASE(8), you can generate a WPA PSK from the ASCII passphrase. You can use the following command which generates output and saves it in the /etc/ directory:
# wpa_passphrase <SSID> <pass> > /etc/wpa_supplicant.conf Note: if either your SSID or passphrase has spaces, make sure to put it in quotes. For example, if your SSID and passphrase have spaces, write it as wpa_passphrase "Secure WiFi" "p4ss w0rd". You can use quotes without spaces too, but it's not necessary to do so. Using quotes will make it read the entire phrase as a single argument, rather than multiple arguments separated by a space.
You'll now want to connect to the network. You can use WPA_SUPPLICANT(8) to do this. The below command worked for me:
# wpa_supplicant -c /etc/wpa_supplicant.conf -i wlp2s0
If your network uses DHCP, you will want to use DHCLIENT(8). This command is fairly simple, and works as shown below:
# dhclient wlp2s0
And that should be it! Your system, if it worked, should now have a WiFi connection. One drawback I've found is that WPA_SUPPLICANT needs to constantly run, but it is possible to use SYSTEMD(1) to run it automatically on boot. You can do that by downloading and saving wifi.service and dhcpclient.service to /etc/systemd/system/, and running the following command:

# systemctl enable --now wifi.service dhcpclient.service

Your WiFi should now be configured.

Converting a Mailbox Into a Maildir

When using Dovecot, I would suggest switching from the mailbox format to maildir, due to issues that will happen with locking conflicts. To switch from mailbox to maildir, you can use the following command: mb2md -s [source] -d [destination].

For example, with the testing user:

mb2md -s /var/spool/mail/chelsea -d /usr/home/chelsea/Maildir

Converting a Maildir Into a Mailbox

If you are using a standard GNU/Linux distro or a free software BSD system, there may be instances where a mailbox format for e-mails would work better. If you use POP3 or a single local e-mail client, the locking issues may really just be a nonissue. To switch from maildir to mailbox, you can use the md2mb.py script following command: mb2md -s [destination] [source].

For example, with the testing user:

md2mb /usr/home/chelsea/Maildir /var/spool/mail/chelsea

Strangely, during the test, the user's e-mails were out of order in the resulting mailbox. Thankfully, I was not the first to have this problem, and someone provided an answer that worked for fixing message sorting.

#!/usr/bin/python2.5 from email.utils import parsedate import mailbox def extract_date(email): date = email.get('Date') return parsedate(date) the_mailbox = mailbox.mbox('/var/spool/mail/chelsea') sorted_mails = sorted(the_mailbox, key=extract_date) the_mailbox.update(enumerate(sorted_mails)) the_mailbox.flush() (Source post licensed under CC BY-SA 2.5)

Afterwards, the user's e-mails were in a more normal-looking order.


Fixing 'pkg: Shared object "libssl.so.111" not found, required by "pkg"' After Upgrading FreeBSD

After upgrading FreeBSD from version 13.2 to 14.0, the pkg command started ti show the following output: pkg: Shared object "libssl.so.111" not found, required by "pkg" After some reading, I found that this was caused by the change to OpenSSL in this version of FreeBSD. Attempt to update the static package with: pkg-static install -f pkg If you are still having issues, consult the FreeBSD Handbook.

Password Protecting Files/Directories on Apache2 with .htpasswd and .htaccess

Note: You must have sudo/root access for some commands.

Step 1: Create the .htpasswd file

The htpasswd file is where you set the specific username and password. To generate this file run the following command: htpasswd -c /path/to/directory/.htpasswd <username> (Replace /path/to/directory/ and username with your web site's path and desired username.)

It will then ask for your desired password. The resulting file will be encrypted. If you want to add additional users, run the command again without the -c flag as shown below:

htpasswd -c /path/to/directory/.htpasswd <username>

Step 2: Create the .htaccess file

You will want to make sure to place the .htaccess file in the directory you want password protected.

Copy and paste the following code into the .htaccess file:

For directory:

AuthName "Dialog prompt" AuthType Basic AuthUserFile /path/to/directory/.htpasswd Require valid-user

For file

<Files file.ext> AuthName "Dialog prompt" AuthType Basic AuthUserFile /path/to/directory/.htpasswd Require valid-user </Files>
This is not intended to provide a perfect or fool-proof secure way to protect a directory. Any attackers who can get the password will be able to access the directory's contents as well, especially since this method is only single-factor. Do NOT use this to hide your critical information on a publicly available web server. I hereby disclaim all liability from using this as a security measure.

Setting a Custom DirectoryIndex Page on Apache2

Typically, when you access a web site, there are pages that I'm going to refer to as "index pages" -- these are typically going to be index.html on the web server. While most webmasters keep this as the default, when handling .html pages like on this web site, others may need to change this setting.

For example, if you use WordPress, you will want to set the web server to use index.php instead.

Making this change is fairly simple:

  1. Open either your .htaccess or domain.conf file
  2. If you are not using an .htaccess file, you will need to write lines reading <Directory [dir]> and </Directory>. HTACCESS users can skip this step.
  3. Inside either the <Directory /> lines or .htaccess file, write "DirectoryIndex file.ext". So, for WordPress, you would do "DirectoryIndex index.php".
And it should be set up. This would mean that your web site's visitors would not get an unexpected "Index of [path]" or 403 Forbidden error.

Setting and Using Variables on GNU/Linux and *NIX Shells

The specific process used to set variables will depend on the shell that you are using. For example, GNU/Linux distros such as Debian and its forks (ex: Ubuntu, Mint, Trisquel, etc.) default to the BASH(1), or, the GNU Bourne-Again SHell. This article currently only gives examples for both the CSH(1) and BASH(1) shells. CSH was tested on FreeBSD and BASH was tested on Debian GNU/Linux. The concepts described should be able to, with some modifications, work with other system setups.

Examples were produced on chell.aperture.presumed.net and coco.presumed.net.

Creating a Variable

To create a variable to last during the current shell session only, you may use "export" to do so from the command line. CSH: set [VAR_NAME] = "[STRING_OR_COMMAND]" SH: export [VAR_NAME] "[STRING_OR_COMMAND]" For the variable to stay saved for use with multiple instances, or to persist between logins, you may add it to either your local .profile file, or to the /etc/profile file.

Removing a Variable

To remove a variable, run the unset command from the command line. CSH & BASH: unset [VAR_NAME] If added to .profile or /etc/profile, you will also want to delete or comment out the line for that variable. Commenting out is preferred if you intend to use it again in the future, or if you want to use it as a reference.

Using Variables with Spaces

At this time, I am not aware of ways to set variables with spaces in them. The easier short-term option out of the two I can think of is to put the variable in quotes. For example: CSH: chelsea@lodge:~/variables % cd "$TEST_VAR" BASH: chelsea@callisto:~/variables$ cd "$TEST_VAR" The easier long-term option would be to simply remove the space from the file path, but you will need to ensure that you do not have any scripts or programs that have the path hardcoded in them, or else bad things will happen.

Setting up DNSSEC on Bind9

There may be a "better" way to do DNSSEC on Bind 9 (NAMED(8)), but this is what eventually worked for me. This page will exist as a guide for if I need to re-install Bind 9 at any point in the future.

Creating keys

dnssec-keygen -a ECDSAP256SHA256 -n ZONE example.com dnssec-keygen -a ECDSAP256SHA256 -fKSK -n ZONE example.com

Signing zone

dnssec-signzone -A -3 $(head -c 4096 /dev/urandom | \ shasum -a 256 | \ cut -b 1-16) -N INCREMENT -o example.com \ -t /etc/namedb/example.com.zone

Next steps


Starting Programs on Boot/Reboot with CRON(8) and TMUX(1)

When rebooting your PC or server, there may be interactive programs or small scripts that you would want to have automatically load on boot, such as chat clients or shell scripts. Even though you can manually start them when you log in, it's more convenient to have these scripts run automatically. Fortunately CRON(8) jobs make it possible to automate processes in this sense, and tools like screen or tmux can make it so you don't need to keep a terminal window and SSH connection open 24/7.

TMUX(1)

To start a program, you can easily launch a program in tmux with: tmux new-session -d -s <program> '<program>'

CRON(8)

To launch the above script and/or example with a cron job (via crontab) type crontab -e and add the following line: @reboot tmux new-session -d -s <program> '<program>'

Stopping Detached Mosh Sessions

Mosh (the mobile shell is a remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes. It works as a replacement for Interactive SSH terminals, and can go between Wi-Fi, Cell, and long-distance links.

If your mosh connections gets closed improperly, you may see the following message the next time you log in:

Mosh: You have a detached Mosh session on this server (mosh [Mosh-PID]).

For security reasons, Mosh connections can only be reconnected to the corresponding client. If that client is dead or closed improperly (such as the client closing while the user is disconnected from the Internet or network), the only option is to kill the listening server with kill [Mosh-PID].


Using a Save Hook for an Automatically Updating "Last Modified" Timestamp

There are multiple ways that save hooks on GNU Emacs can be used for automatically updating timestamps. By default, Emacs will update timestamps in the first eight lines of a file. The lines would look like either: Time-stamp: <> Or: Time-stamp: "" In order for the timestamp to automatically change when you save a document, you need to add the save hook to your ~/.emacs file: (add-hook 'before-save-hook 'time-stamp) This is not the only way your timestamp can work, especially since it may be a bit awkward to look at an HTML document. Another way you can display timestamps would be how I do with my own web pages. To do this, you'll need to add the below code block to your .emacs file. (add-hook 'html-mode-hook (lambda () (set (make-local-variable 'time-stamp-pattern) "-8/<!--LASTMOD-->+%3a %d %3b %:y %02H:%02M:%02S %p %Z<!--END-->"))) The above code will look in the last 8 lines of the document, and will add the time stamp in between the below comments: <!--LASTMOD--> <!--END-->

Notes:


Watching YouTube Videos Without Nonfree Software, Advertisements, or Tracking

Since around 2022, I've been encouraging people to use
Invidious, a free software front-end for YouTube, over the standard YouTube web site, since it lets people watch the same videos free of advertising, tracking, and nonfree software. It fortunately does not use the YouTube API, decreasing the amount of data that needs to get handed over to Google to get sold around down by a ton. It also, by design, gets rid of the forced advertisements for nonpremium users entirely.

To use Invidious, simply replace "www.youtube.com" in the URL bar with "invidio.us", and select any instance from the list.

Optionally, for people with JavaScript enabled, you can add this link to your bookmarks bar to easily switch from YouTube to Invidious:


Anton McClure / anton@presumed.net
Last updated: Thu Feb 22 23:54:14 EST 2024
Disclaimer