Technology Support Articles


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.

How to Password Protect 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.

Installing FileZilla Without Getting Potentially Unwanted Programs

The default installer for FileZilla, a popular program for FTP, SFTP, and other protocols, may leave your PC with potentially unwanted and potentially malicious software.

Fortunately, it is possible to download and install FileZilla without the bundled software, by adding ?show_all=1 to the end of the URL -- so the URL would look like this:

http://filezilla-project.org/download.php?show_all=1
From there, at least as of writing this post, you will now be able to safely download FileZilla for all supported operating systems.

Installing Google Chrome on Debian GNU/Linux

Google Chrome is undoubtedly the most popular web browser in the world, and has several forks from being based on a free software program. With Google Chrome's continued success, it makes sense for a web developer to have it for testing when perse want to make sure that per project works for Chrome users. While Windows and macOS users basically have 1 important step, those not familiar with Debian may find themselves unsure how to install the browser since it's not in the default apt repositories. Chromium is, but there are some features Chrome users are familiar with that aren't in the Chromium version.

Installation is quite simple. In order to install, you'll need access to either sudo, or more preferably, the normal root user.

  1. Download the .deb file for Google Chrome.
  2. Install Google Chrome with apt install ./google-chrome-stable_current_amd64.deb.
  3. Enjoy Google Chrome!

Please note that Google Chrome will now automatically update from Google's APT repository when updates become available. Make sure that the file "/etc/apt/sources.list.d/google-chrome.list" exists and contains deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main. Updates to Chrome may automatically update or modify the file, and manual changes may get removed.


Performing a Full Shutdown on Windows 10 and Windows 11

Windows 10 and Windows 11 by default use a hybrid shutdown for their fast startup feature, which works similarly to hibernate. While it may have some benefits, there are going to be times when you want to perform just a normal shutdown. I was able to find 2 ways to do so. Some sites showed a command-line method as well, but it may confuse less tech savvy users to have to paste things into a Command Prompt window.

Recommended Options Changes for Using the Built-In Console on Windows 10 and 11

Disclosure: This article was first written to address an issue one user on a shared shell server was having while trying to copy+paste text due to her computer's default terminal config. I would like it if Mirosoft would be able to make these the default settings, so that this article is no longer necessary.

Microsoft made a great decision by adding native SSH support to their operating system (after around 4 decades or so), but there are still some problems users can face with how much different Windows can work compared to other operating systems. For example, the Windows Console by default will use CTRL+C or "Copy", while on GNU/Linux or UNIX (excluding macOS, which is a bit problematic in programs that use the control key for things such as emacs), it is used for SIGINT (signal interrupt), which will quit/kill most foreground processes.

Here are some things I recommended changing in Command Prompt or PowerShell for the best possible user experience.

Opening settings

Right click the icon in the top left corner of the window, and select "Properties".

Change the following:

Why we may want to change these options

Notes

If you are promoted on whether the settings should apply to every window or just that one when clicking OK, select every window. This way you will not need to keep re-setting these every time.

I had erroneously, without any sort of testing, suggested disabling "insert mode". Disabling it actually had the opposite effect from what I was expecting.


Resetting Windows 10

Note 1: If your device is encrypted, you will need your BitLocker key when resetting your PC. If you don't know your BitLocker key, please see Find my BitLocker recovery key.

Note 2: I recommend *not having this guide opened on the device you want to reset, especially if you reset it from WinRE (Method 2). If you have another device, such as a phone, tablet, or another PC, it is recommended that you open the guide on there if you will want to keep following it after you restart your PC.*

When resetting Windows 10, you are given the following options:

Option What the option does
Keep my files > Change Settings > Preinstalled apps On Reinstalls Windows 10 while keeping your personal files, removes any apps and drivers you installed, and restores default settings and preinstalled apps.
Keep my files > Change settings > Preinstalled apps Off Reinstalls Windows 10 while keeping your personal files, removes any apps and drivers you installed along with preinstalled apps, and restores default settings.
Remove everything
(clean install)
Reinstalls Windows 10 while removing personal files, all apps, drivers, and settings changes. Preinstalled apps will be reinstalled.Data erasure On removes all files and cleans the drive. If you plan on donating, recycling, selling, or disposing your PC, this option is highly recommended. It takes longer but makes it harder for other people to access removed files.Data erasure Off simply removes files, and is less secure.

Method 1: Resetting From Settings

  1. Press Start
  2. Select Settings > Update & Security > Recovery
  3. Under the Reset this PC section title, select the Get started button, and choose your setting from the above table

Method 2: Resetting From Sign-In Screen

  1. Press the Windows logo key+L to get to the sign-in screen
  2. Select the Power icon in the lower-right corner and then select Restart while holding the Shift key
  3. Once your PC restarts to the Windows Recovery Environment (WinRE), select Troubleshoot > Reset this PC, and choose an option from the above table

Still Having Issues?

If your device is still having issues, you may want to consider contacting Microsoft support.

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 UNIX and GNU/Linux 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]"
BASH
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 Apps From Automatically Loading Themselves on Microsoft Windows

Auto-starting apps get annoying. Here's how to stop them from automatically opening themselves.

Discord

  1. Click "User Settings"
  2. Scroll down in the side menu and click "Windows Settings"
  3. Click the slider for "Open Discord" to the off position.
  4. Optionally, click the slider for "Minimize to Tray", so that closing the app would (hopefully) actually close the app.

Microsoft Teams

  1. Click the three horizontal dots next to your user's profile image in the top bar
  2. Click "Settings"
  3. Uncheck "Auto-start application"

Spotify

  1. Click the menu labeled by your account's display name
  2. Click "Settings"
  3. Scroll down to "Startup and window behavior"
  4. Change the option for "Open Spotify automatically after you log into the computer" to no.
Even better yet than these "fixes" would be to use 100% free software as opposed to these proprietary applications and disservices.

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 modified: Wed Nov 15 13:34:45 EST 2023
Disclaimer