How Do You Fix the Problem When You Get “docker command not found”?

Problem scenario
Docker is installed as far as you can tell on your Linux server.  You ran "sudo apt-get -y install docker" and it seemed to work.  When you run it again you see this:

"Building dependency tree
Reading state information... Done
docker is already the newest version (1.5-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
"

How do you get Docker to work when it seems installed but you get the error "docker command not found"?

Solution
If you have access to the internet, run this command:
sudo curl -sSL https://get.docker.com/ | sh

There are other ways of install Docker.  You may want to find a link below that is relevant to your situation:

How To Install Docker on an AWS Instance of RedHat Linux  (These directions use CentOS packages.)
How Do You Install Docker on an AWS Instance of RHEL?  (These directions use RHEL packages.)
How To Install Docker on an AWS Instance of SUSE Linux?
How To Install Docker on an AWS Instance of Ubuntu  (These directions do make changes to the Debian package repositories of your Linux server and use dockerproject.org and Ubuntu.com for the installation media.)
How Do You Install Docker on an AWS Instance of Ubuntu?  (These directions do not make changes to the Debian package repositories of your Linux server.)
How Do You Install Docker-Compose on a Linux Server?
How Do You Install Docker on a RHEL VM in Azure?
How Do You Install Docker on a GCP VM Running RHEL?
How Do You Install Docker on Debian 9 in GCP?

How Do You Find the Subscription ID for an Azure Account?

Problem scenario
You want to find the subscription ID for your Azure account.  What do you do?

Possible Solution #1
Log into the Azure Portal.  In the upper right click on your account and then click on "My permissions."  You should see an alphanumeric string near your subscription.

Possible Solution #2
Prerequisite

If you have Windows 7 you need to install Azure PowerShell; if you need assistance with this, see this posting.  If you have Windows 10, you need to install the modules for Azure; if you need assistance with this, see this posting.

Procedures
Run this PowerShell script:

Login-AzureRmAccount;
$subscriptions= Get-AzureRmSubscription
$totalvar = "The subscription ID is $subscriptions"
echo " "
echo $totalvar

Possible Solution #3
if you are using the Azure CLI, you can run this command to get the subscription ID:

az account show --query "{subscriptionId:id, tenantId:tenantId}"

How Do You Delete a CloudFormation Stack with the AWS CLI?

Problem scenario
You deployed servers with CloudFormation.  You know the name of the stack.  How do you delete the stack with the AWS CLI?

Solution

Prerequisite
This assumes you have installed and configured the AWS CLI.  If you need help with this, see this posting.

Procedure
Run this command (but replace "continualstack" with the name of the stack that you want to delete:
aws cloudformation delete-stack --stack-name continualstack

How Do You Copy All the Files in a Given Subdirectory and Place Them into a New .tar.gz File?

Problem scenario
You want to make copies of every file in a subdirectory and create a single .tar.gz file.  What do you do?

Possible Solution #1 (the files with the full path aka directory tree they are in)
Run this command: tar -czvf archive.tar.gz /path/to/source/files/subdirectory/

The above command will take a copy of all the files in /path/to/source/files/subdirectory/ and create a single file that is compressed with those copies.  It will copy the full path too.  That is, when you decompress the files in a given directory (e.g., tmp), it will look like this:

/tmp/path/to/source/file/subdirectory/

All the files will then be in subdirectory.

Possible Solution #2  (just the files and no directories)
If you do not want the underlying subdirectory tree, then change directories to be in the subdirectory with the files and run this command:

tar -czvf archive.tar.gz .

# The above command will create a file called archive.tar.gz with all the files in the current directory with no directory path structure.  This may be more desirable.

How Do You Write a Groovy Program to Read in User Input from the Keyboard and Print It Out?

Problem scenario
You want to test out Groovy as a scripting language.  You want a Groovy program to read in user input and print it out to the screen.  How do you do this?

Prerequisite
This assumes that you have already installed Groovy on a Linux server.  If you are running a Red Hat derivative (e.g., CentOS, RHEL, or Fedora), click on this link.  If you are running an Ubuntu or Debian distribution, click on this link for Groovy version 1 and this link for version 2.  If you are using Ubuntu Linux in AWS, click on the version 1 link (because the other directions won't work, and the version 1 link will actually install version 2).

Solution
1.  Create a file called input.groovy with the following two lines:

def input = System.console().readLine 'Please provide some input: '
println "You entered $input"

2.  Run it like this:  groovy input.groovy

How Do You Unprotect a Git Repository That Is in a GitLab Project?

Problem scenario
You have a Git repository that is protected in a GitLab project.  You want to allow developers to upload code directly to the master branch (not alternative branches).  What do you do?

Solution
It may be more advisable to work with a branch of a git repository.  This is a basic solution for testing or those instances when you want to work directly with the master branch.  

1.  Log into the web UI for GitLab.  
2.  Click on the Project that has the repository you want.
3.  On the left click on "Settings".
4.  Click on "Repository" under "Settings."  
5.  For "Protected Branches" click "Expand".
6.  Find the orange "Unprotect" button.
7.  Click "OK" to the prompt about "Branch will be writable for developers. Are you sure?"

While the above should work for GitLab on any type of server, if you need to reinstall GitLab on an Ubuntu or Debian Linux server, see this posting.

How Do You Pronounce quay.io?

Problem scenario
You are interested in the quay.io to store Docker images. You do not know how to say the term "quay" as in "quay.io." How should it be pronounced?

Answer
The word "quay" is pronounced "kway" (rhymes with stray). (The pronunciation "key" may be acceptable too.) If you want to see the source, click on this external page:
https://developers.redhat.com/blog/2019/06/26/using-quay-io-to-find-vulnerabilities-in-your-container-images/

How Do You Troubleshoot the C Compile-Time Error “gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory”

Problem scenario
You run gcc to compile a C program, but you get this error:
"gcc: error trying to exec 'cc1plus': execvp: No such file or directory"

Solution
Install a C compiler.  If you do not know how, see this posting.

How Do You Troubleshoot the Ansible Problem “ERROR! Syntax Error while loading YAML. mapping values are not allowed here”?

Problem scenario
You are trying to run an Ansible playbook with the "become: yes" stanza.  You get this error after your ansible-playbook command:

"ERROR! Syntax Error while loading YAML.
  mapping values are not allowed here

The error appears to have been in '/home/cooluser/good.yaml': line 5, column 10, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be..."

What should you do?

Possible Solution #1
Check the indentation of the playbook (i.e., the .yaml file).  Here is an example of incorrect indentation (with hosts and tasks indented too much):

- name: This is a test.
     hosts: contintserver
     tasks:
     - shell:  "free -m > /tmp/memory.txt"

Here is how it should look (without the extra indentation beneath the "- name:" stanza):

- name: This is a test.
  hosts: contintserver
  tasks:
    - shell:  "free -m > /tmp/memory.txt"

Possible Solution #2
Sometimes you cannot have the "become: yes" stanza immediately after the module.

Here is an example of an incorrect order:

- hosts: all
  tasks:
  - copy:
    become: yes
      src: /home/cooluser/swapspace.sh
      dest: /home/cooluser/swapspace.sh
      owner: cooluser
      group: wheel
      mode: 0644

Here is an example of a correct order:

- hosts: all
  tasks:
  - copy:
      src: /home/cooluser/swapspace.sh
      dest: /home/cooluser/swapspace.sh
      owner: cooluser
      group: wheel
      mode: 0644
    become: yes

Possible solution #3

Instead of:

tasks:
- name: foobar3
shell: "free -m > /tmp/memory.txt"

use this:

tasks:
- shell: "free -m > /tmp/memory.txt"

How Do You Run a Java Program That Has Compiled Successfully?

Problem scenario
You have compiled the source code of a Java program into bytecode (with a .class extension). You try to run it (execute the bytecode) with a javac command (javac HelloWorld), but you get "error: Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested
1 error "

What should you do?

Solution
Run it with the java command like this (with no ".class" extension): java HelloWorld