Where Did The Term “Daemon” Come From?

Question
You have heard of the term daemon when it refers to a process, service or listener of an OS. Where did this term come from?

Solution
According to page 440 of A Practical Guide to Fedora and RedHat Enterprise Linux by Sobell, the terms daemon, service and server are all interchangeable. Demons are invisible presences like spirits. The term "daemon" is Latin and is pronounced exactly the same as "demon" according to Dictionary.com.

To read more elaborate definitions of the word, see this Webopedia posting or this Whatis.com definition.

There are discrepant etymologies for the word. This term was chosen in the early stages of computing. The term may be a backronym/portmanteau for "Disk And Execution MONitor" (according to page 1245 of A Practical Guide to Fedora and RedHat Enterprise Linux by Sobell). Linfo.org says that the term "daemon" denotes something that is not necessarily evil which is contradistincted from the term "demon."

A different published book has a different explanation of the word's origin.

The term daemon was first coined by MIT hackers in the 1960s. It refers to a molecule-sorting demon from an 1867 thought experiment, Maxwell's demon is a being with the supernatural ability to effortlessly perform difficult tasks, apparently violating the second law of thermodynamics. Similarly, in Linux, system daemons tirelessly perform tasks such as providing SSH service and keeping system logs.

Page 321 of Hacking the Art of Exploitation, 2nd Edition.

Happy National Freedom Day!

The Union victory of the Civil War forced the southern states back into the Union under its jurisdiction.  On February 1, 1865 President Lincoln signed a resolution permanently outlawing slavery in the U.S. (www.timeanddate.com).  

This resolution became the 13th amendment which was ratified later that year after Lincoln's death (www.timeanddate.com).  

A former slave named Richard Wright became a successful businessman in Philadelphia in the 1900s (http://www.americaslibrary.gov/es/pa/es_pa_free_1.html).  He advocated a day to celebrate freedom (http://www.americaslibrary.gov/es/pa/es_pa_free_1.html).  He is considered to have founded the day (Library of Congress Website).  In 1948 President Truman proclaimed Feburary 1 to be National Freedom Day (www.timeanddate.com).

You may want to read these books about freedom and slavery in the U.S.:

How Do You Enter a Docker Container That is Currently Running?

Problem scenario
You want to get inside a Docker container that is running.  You are on the Docker host.  What should you do?

Solution
1.  Run this command:  docker ps -a   # Find the container ID in the output
2.  Run this command but substitute abcd1234 with the container ID found above:
docker exec -it abcd1234 bash

How Do You Fix the Problem of Being Prompted for the Root Password When You Want to sudo as a Given User?

Problem scenario
You try to run a command with sudo and you are prompted for the root user password (not the password for the username who issued the sudo command). You want to be prompted for the user (e.g., jdoe) not root.  What should you do?

Solution
Root cause
sudo is not configured properly.

Procedures
1.  Use the visudo command (with no arguments): visudo

2.  Comment the stanzas (place leading "#" symbols) in front of these stanzas:

Defaults targetpw
ALL    ALL=(ALL) ALL

They will look like this:

#Defaults targetpw
#ALL    ALL=(ALL) ALL

3.  Add the user to the "User privilege specification":

jdoe ALL=(ALL) ALL

4.  Save (e.g., press ZZ).

5.  You are done.  If you want to change the interval of how frequently you are prompted to enter a password (the time duration before being challenged again) when you use the sudo command, see this posting.

How Do You Write a Hello World Program in Node.js?

Problem scenario
You want to write a "Hello World" program using Node.js.  What do you do?

Solution
Prerequisite
Identify the external IP address of the server (e.g., run "curl icanhazip.com" if you have access to the internet).

Procedures
1.  Install node and npm on a Linux server.  If you need assistance with this, see this posting.
2.  Run these two commands:
mkdir contint
cd contint

3.  Run this command:

npm init  # respond to the interactive prompts.  You probably will want to accept the defaults, but for the "Entry point" one with the suggestion of "index.js" change it to "contint.js"

For "Is it ok?" type "yes" (with no quotes) and press "Enter".

4.  Create a file called contint.js and have the following as content:

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World');
});

app.listen(2987, function () {
  console.log('Example webpage application listening on port 2987!');
});

5.  Run these two commands:

npm install express --save
node contint.js

6.  Open a web browser on your workstation.  Go to x.x.x.x:2987 where x.x.x.x is the external IP address of the Linux server.

How Do You Create a Node.js Application to Be Presentable and Usable via a Docker Container?

Problem scenario
You want to create a basic "Hello World" web page with Node.js running in a Docker container.  How do you do this?

Solution
Prerequisite

Install Docker.  If you need assistance, see this posting.

Procedures
1.  Create three files in the same directory on a Linux server.  A possible location would be the home directory of the user that will run the "docker" commands.

1.a.  Dockerfile should have this as its content (which was modeled on what was here):

FROM node:argon

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 8080
CMD [ "npm", "start" ]

1.b.  package.json should have this as its content (which was taken from https://nodejs.org/en/docs/guides/nodejs-docker-webapp/):

{
  "name": "docker_web_app",
  "version": "1.0.0",
  "description": "Node.js on Docker",
  "author": "First Last <first.last@example.com>",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.16.1"
  }
}

1.c.  server.js should have this as its content (which was mostly taken from https://nodejs.org/en/docs/guides/nodejs-docker-webapp/):

'use strict';

const express = require('express');

// Constants
const PORT = 8080;
const HOST = '0.0.0.0';

// App
const app = express();
app.get('/', (req, res) => {
  res.send('Hello world. This is from Continual integration\n');
});

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

2.  Run these two commands:

docker build .
docker images
    # Mentally identify in the output your new image.

3.  Run this command but substitute 44444 with the port you want to access the Node.js web page on and replace abcd1234 with the image ID found above:

docker run -p 44444:8080 -d abcd1234 # where abcd1234 is an Image ID

4.  Go to web browser.  Go to x.x.x.x:49160 where x.x.x.x is the external IP address of the Docker host; to find this IP address you can go to the Docker host and run "icanhazip.com" if you have internet access on the host.

How Do You, in Python, Make a Tuple from a List?

Problem scenario
You are writing code in Python.  You have a list that you want to have a copy of in the form of a tuple.  What do you do to convert the content to a different data type?

Solution
Assuming you have a list called "contintlist", this line would create a tuple with the content of "contintlist":

cooltuple = tuple(contintlist)

Here is a Python program that generates a list, then creates a tuple with the same content:

import random
pretuplelist = []
for i in range(1000):
   pretuplelist.append(random.randint(1,100))
cool_tuple = tuple(pretuplelist)
print(cool_tuple)

How Do You Generate 10,000 Random Numbers in a List in Python?

Problem scenario
You want to generate 10,000 random numbers in a tuple.  That is, you want a tuple with 10,000 numbers.  The numbers can be chosen at random.  How do you do this?

Solution
Run this program:
import random
coollist = []
for i in range(1000000):
   coollist.append(random.randint(1,100000))

How Do You Install kubeadm on Any Type of Linux?

Problem scenario
You want a quick, generic way to install kubeadm on any type of Linux.  What should you do?

Solution
Run these commands:

cd /tmp

curl -Lo kubeadm https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubeadm && chmod +x kubeadm

sudo mv kubeadm /usr/bin/

Test it by running this command: kubeadm version

(If you would prefer to use apt commands, because you are using a Debian/Ubuntu distribution of Linux, to install kubeadm, see this posting.)