How Do You Run a Groovy Program on a Debian or Ubuntu Server?

Problem scenario
You want to use a Java Virtual Machine language on an Ubuntu Linux server.  You want to test out the language too.  What should you do?

Prerequisites
Install Groovy version 1; this command should work:  sudo apt-get -y update; sudo apt-get -y install groovy

Procedures
1.  Create a file called hello.groovy with the following five lines:

class Example {
   static void main(String[] args) {
      println('Hello World');
   }
}

2.  Run it like this:  groovy hello.groovy

How Do You Troubleshoot the Message “/usr/bin/mongodb/bin/mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory”?

Problem scenario
You are using a Red Hat derivative of Linux (e.g., CentOS/RHEL/Fedora).  When trying to run a mongod command you receive this message: "/usr/bin/mongodb/bin/mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory".

What should you do?

Solution
Get different installation media.  If you try to install a .tgz file for Ubuntu on CentOS/RHEL/Fedora, you will get this message.  The solution is to get new installation media.

How Do You Troubleshoot a C Program Displaying the Error “Segmentation fault” at Run Time?

Problem scenario
Your C program compiles.  But you get the error "Segmentation fault."  You expect the value of a variable to be printed.  How do you get the value to be printed without this error?

Solution
Does every print function print?  If one print function seems to be displaying the "Segmentation fault" error, look closely at the syntax thereof.  Here is a line that will produce this error:

   printf ("y is a %s\n", y);

Here is a similar but corrected line that will be error free:

  printf ("y is a %d\n",y);

The "%s" is appropriate for printing string variables.  For integer variables, use "%d" syntax.

How Do You Fix a Non-Terminating (Hanging) Command Such as “git push origin master” ?

Problem scenario
The command "git push origin master" hangs. What should you do?

Solution
Cancel the job with ctrl-c.  (Hold the "Control" key and tap the "C" key.)

For the target .git repository, does the file have the owner and group associated with the "git" user?

If you used the git user in the "git clone" command (as in "git clone @...") but then changed the owner and group of the .git repository to something else, you may see an indefinite hang after the "git push origin master" command.

Can the Kernel Access Hardware Directly?

Question
Can the kernel, or code running in it, access hardware directly?

Answer
Yes. 

kernelspace lives in RAM (or memory) (1).  Code that is processing in kernelspace can fully access other processes in memory or fully access hardware directly (1).

The kernel governs hardware utilization via drivers, memory, disk space, memory and CPU (1).

In RedHat distributions of Linux (including CentOS and Fedora) userspace exists in RAM (or memory) (2).  Running applications live in userspace (2).  "Code running in userspace cannot access hardware directly and cannot access memory allocated to other applications." (2)

Here is the guide:
(1) Page 1257 of 7th Edition of A Practical Guide to Fedora and RedHat Enterprise Linux by Mark G. Sobell
(2) Page 1279 of 7th Edition of A Practical Guide to Fedora and RedHat Enterprise Linux by Mark G. Sobell

How Do You Deal with the Python Error “IndexError: pop index out of range”?

Problem scenario
You have a Python list with n items.  You are getting a "IndexError: pop index out of range" error.  The order that these lists are being printed (used or displayed) is not what you expect.  Your program prints the entire list initially, so you know what to expect.  This IndexError and the order of the items being displayed is not what you expect.  Here is an example:

>>> print(fun_list)
['item1', 'item2', 'item3', 'item4']

>>> print(fun_list.pop(0))
item1
>>> print(fun_list.pop(1))
item3

>>> print(fun_list.pop(2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: pop index out of range

What is wrong?

Root cause
The .pop operation removes the item from the list each time the .pop operation is used.  So the index becomes different because the list itself is different.  Pop is destructive.  The list is mutable.

Solution
Do not use pop.  Print the items via the bracket syntax [] and the 0-based indexing.

Here is an example:

>>> fun_list = ['item1', 'item2', 'item3', 'item4']
>>> print fun_list[0]
item1
>>> print fun_list[1]
item2
>>> print fun_list[2]
item3
>>> print fun_list[3]
item4


Caveat: there are times when the pop operation is useful. If you are getting this error and do not know why, we would recommend avoiding pop.

If you want to learn more about Python, you may want to purchase a book on the subject.

How Do You Get hdfs or Yarn to Start the Jps Process You Expect to Start?

Problem scenario
You use start-dfs.sh and start-yarn.sh and there are no errors.  They seem to work, but when you use the jps command, you do not see the service you expect.  Why isn't a jps process starting when you run one of these scripts?

Solution
The root cause could be a variety of root causes.  Here are some potential solutions.

1.  In these files, is there an all uppercase stanza like one or both of the following?

HADOOP_SECURE_DN_USER=yarn

HDFS_NAMENODE_USER=root

If it has never worked, you may want to comment out such stanzas.

2.  Are you using sudo to start these start-dfs.sh and start-yarn.sh scripts?  Try not using sudo before you run the scripts.

3.  You want want to set up Hadoop again.  This link can help you with deploying open source Hadoop.

How Do You Use Amazon Route 53 with a Domain Name?

Problem scenario
You have a web server with an external IP address (e.g., a VPS, an EC-2 instance, a DigitalOcean droplet, a VM in Azure or GCP).  You have a domain name, e.g., funexample.com, that you have registered.  You want to go to craft a URL foobar.funexample.com to resolve to this web server with an external IP address.  Right now when you open a web browser and go to foobar.funexample.com, nothing downloads.  You get a message about "Server not found" or "Page cannot be displayed."  In a web browser when you enter the external IP address of the web server, it resolves.  How do you up DNS to resolve your URL to your IP address with Amazon Route 53?

Solution
Prerequisites

1.  You have registered a domain name with AWS or transferred a domain name to Amazon (e.g., funexample.com).  (This costs money.)
2.  You have the external IP address of a web server (e.g., x.x.x.x) that you want to assign a domain name to (e.g., you want a URL with funexample.com to resolve to x.x.x.x).

Procedures
1.  Log into the AWS Console.
2.  Go here: https://console.aws.amazon.com/route53/home#hosted-zones:
3.  Check the option near the domain you want to configure (as there should be a circular button on the left)
4.  On the right there should be a button that says "Configure Query Logging"
5.  For the "New log group name" choose something like this (but replace "contint" with a phrase that will be meaningful to you): /aws/route53/contint
6.  Click "Create Log Group"
7.  For the option "CloudWatch Logs resource policy" choose the "Create a new resource policy in..."
8.  For the field "Resource policy name", enter one that will be meaningful to use (e.g., "route-53-query-logging").
9.  For the "Log groups that the resource policy applies to" enter something like this: /aws/route53/*
10.  Click "Create policy and test permissions" button
11.  Click the button in the lower righthand corner that says "Create query logging config"
12.  Click "Go to Record Sets" button
13.  Click "Create Record Set"
14.  Enter a value for Name.  The result will be something worth noting.  For example, if you enter "foobar" your website address will be foobar.funexample.com (assuming your domainname was funexample.com).
15.  Enter the IP address of your web server in the "Value" field.  (We recommend a private or "internal" IP address.)
16.  Click the "Create" button.
17.  You are now done.  AWS servers will be able to resolve the foobar.funexample.com URL almost immediately.  From an AWS Linux server, you can run a command like this: curl foobar.funexample.com > /tmp/good.html
Then examine /tmp/good.html to verify it is the page you want.

Web browsers on a Windows workstation will need time (e.g., 30 minutes or more) for your new URL, e.g., "foobar.funexample.com", to resolve.

What Does the “git rebase” Command Do?

Problem scenario
You are familiar with codebases in the context of configuration management or version control.   How can you invoke "git rebase" to learn more about git?

Solution
If you use the man page for "git rebase" you see this phrase to define "git rebase":  "Forward-port local commits to the updated upstream head"

What does "Forward-port local commits to the updated upstream head" mean?

According to Steve Bennett, it means "Sequentially regenerate a series of commits so they can be applied directly to the head node." 

The phrase "forward-port" means applying a change from one code base to another. (Do not confuse forward-port with TCP/IP ports.  The term port here is not a reference to TCP/IP.  In our experience however, this git usage of "forward-port" is very rare.)

The term "head" "is a reference to the last commit in the currently checked-out branch" according to this StackOverflow posting.  The "git rebase" command reapplies commits to another base of code according to this external website which has more detailed information about "git rebase".

How Do You Troubleshoot the Error “We are experiencing problems connecting to the Graylog server running on http://127.0.0.1:9000/api”?

Updated on 1/22/19

Problem scenario

You installed Graylog in a Docker container.  You open the URL for the server in a web browser.  You see this message:

" Server currently unavailable

We are experiencing problems connecting to the Graylog server running on http://127.0.0.1:9000/api. Please verify that the server is healthy and working correctly.

You will be automatically redirected to the previous page once we can connect to the server.

Do you need a hand? We can help you."

What should you do?

Solution
1.  Stop the Docker container with Graylog. 
2.  Remove this container. 
3.  Create a new Docker container but replace the 127.0.0.1 with the external IP address of the Linux Docker server (the Docker host).  The command should look like this (but replace x.x.x.x with the IP address of the Linux server):

docker run --link contint-mongo:mongo --link contint-elasticsearch:elasticsearch -p 9000:9000 -e GRAYLOG_WEB_ENDPOINT_URI="http://x.x.x.x:9000/api" -d graylog2/server

4.  If the command you drafted fails, you may need to run it with "sudo " at the beginning.  If you normally need to use sudo before Docker commands, you may want to try to configure your Docker host to not need that; if you need assistance with this, see this posting.