When Does the DNS Server Override the /etc/hosts File for FQDN or Domain Name Resolution?

Problem scenario
You notice that on some Linux servers the /etc/hosts file controls the resolution of hostnames and on other servers the DNS server overrides the /etc/hosts file. Which has precedence in DNS resolution, /etc/hosts or the DNS server on the network?

Answer
It depends. The /etc/nsswitch.conf file will decide. There is a “hosts” stanza. This setting will have the DNS server override the /etc/hosts file:

hosts:dns files

This setting will have the /etc/hosts file take precedence for name resolution:

hosts:files dns

To get the hostname,

How Do You Fix a Mouse That Scrolls in a Different Direction Than It Is Supposed To?

Problem scenario
Your mouse scrolls up when you use the scroll wheel to scroll down. What should you do?

Solution
Is the problem reproducible on two different computers? If the problem stays with the mouse you may need to dis-assemble it and clean it. You may need a can of air and a small screwdriver. If you see no screws on the bottom of the mouse,

How Do You Get a PHP Program to Invoke a Python Program via Browsing a Website?

Problem scenario
You want Debian/Ubuntu Linux to support a website. You want a Python program to run every time a web page is downloaded. How do you get a PHP program to invoke a Python program on Debian/Ubuntu Linux?

Solution

Prerequisites
i. This assumes you have Apache2 and PHP installed. If you need assistance run this: sudo apt -y install apache2 php
ii.

Why Cannot You List Every Repository in Your GitHub Organization’s Account?

Problem scenario
You are trying to list the repositories in your GitHub organization with the REST API. You run something like this:

curl -u $username:$password https://api.github.com/orgs/$ORGNAME/repos

But as you add repositories, all are not showing. What is wrong?

Possible solution
Do you have more than 30 repositories? The output of the curl (GET REST) invocation can be the same as you add repositories if you exceed 30.

How Do You Remove the ECDSA Fingerprints of Old Servers That You Will Not Connect to Again?

Problem scenario
You have a server that has run SSH to connect to other servers. You want to remove the fingerprints so the ECDSA key fingerprint will challenge a user to continue connecting. What do you do?

Solution
Run this command where x.x.x.x is the IP address or hostname of the server whose finger print should be removed: ssh-keygen -R x.x.x.x

If you used a hostname with the SSH comands,

How Do You Create an Issue for a Repository in a GitHub Organization the API?

Problem scenario
You are running this command:

curl -u jdoe:$password -X PUT -d ‘{“title”: “Look at this bug”, “body”: “This is a serious problem here.”, “assignees”: [ “jdoe” ], “milestone”: 1, “labels”: [ “bug” ]}’ https://api.github.com/repos/$orgname/$reponame/issues

The message in the response you receive is “Not Found”. You found documentation that refers to an “owner” being in the URL. You see “POST /repos/:owner/:repo/issues” (with no reference to the organization).

How Do You Read in User Input with Golang?

Problem scenario
You want to read in user input with Golang. What should you do?

Solution
This program will illustrate how you accept user input with a Golang program:

package main

import (
“bufio”
“fmt”
“os”
)

func main() {
fmt.Println(“Please enter some text:”)
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString(‘\n’)
fmt.Println(“The text you entered was this: “, text)
} …

How Do You Create a GCP VM to Be a Web Server?

Problem scenario
You have a GCP server. You can run curl commands to its URL via localhost. But with a URL constructed with the server’s external IP address the curl command times out. You cannot reach the URL from your workstation. How do you get the GCP server to present the web service to other machines?

Solution
Modify the firewall rule by following these steps below.

How Do You Install Firefox on a Windows Server with PowerShell?

Problem scenario
You want to install Firefox on a Windows server without using the traditional GUI method. What should you do?

Solution
Updated on 5/16/21
1. Open PowerShell ISE as Administrator (right click it, go to More -Run as Administrator).
2. Run this script (e.g., firefox.ps1):

# This script was mostly taken from https://forum.pulseway.com/topic/1940-install-firefox-with-powershell/

# www.continualintegration.com changed the version number of Firefox and added some comments
# Silent Install Firefox

# Download URL: https://www.mozilla.org/en-US/firefox/all/

# Path for the workdir
$workdir = “c:\installer\”

# Check if work directory exists if not create it

If (Test-Path -Path $workdir -PathType Container)
{ Write-Host “$workdir already exists” -ForegroundColor Red}
ELSE
{ New-Item -Path $workdir -ItemType directory }

# Download the installer

$source = “https://download.mozilla.org/?product=firefox-88.0.1-SSL&os=win64&lang=en-US”
$destination = “$workdir\firefox.exe”

# Check if Invoke-Webrequest exists otherwise execute WebClient

if (Get-Command ‘Invoke-Webrequest’)
{
Invoke-WebRequest $source -OutFile $destination
}
else
{
$WebClient = New-Object System.Net.WebClient
$webclient.DownloadFile($source, …