How Do You Troubleshoot the Ansible Message ‘Error while linking: [Errno 2] No such file or directory … “state”: “absent”‘?

Problem scenario
You are using the file module in Ansible.  But you get the error 'Error while linking: [Errno 2] No such file or directory ... "state": "absent"'.

What should you do?

Solution
Some people get this problem with different versions of Ansible 2.x.  It is documented on this external page.

Rewrite your Ansible playbook so it uses a "shell" module and some "ln -s" command. Here is an example of the shell command:

ln -s /existing/directory/ /new/directory/via/softlink

# Where /existing/directory/ is the path of an existing directory and "/new/directory/via/softlink" is the symbolic link you 

How Do You Solve This SQL Problem When You Receive the Message “ERROR: Syntax Error at or Near”?

Problem scenario
You are trying to update a SQL table with a SQL statement (using the "UPDATE" keyword).  You keep getting "ERROR:  syntax error at or near" with a reference of the value you are trying to give to a cell in a row in a SQL table.  You verified you have no extra commas, apostrophes, or semicolons in your SQL UPDATE statement.  You verified that the columns exist in the table and are spelled correctly in your UPDATE statement. What do you do to have your UPDATE statement work?

Solution
Verify your WHERE clause is correct.  If your WHERE clause is looking for a value (e.g., where name = 'jones') in the table that matches 0 rows, then you may get this problem "ERROR:  syntax error at or near."  Once your WHERE clause matches the value of one or more rows, the UPDATE SQL statement should work.

How Do You Troubleshoot a Car Alarm Remote Control Device (aka Key Fob)?

Problem scenario
Your remote control to the car alarm (aka key fob) is not working reliably.  You need to get into your car or at least disarm the the alarm on-demand.  How do you get the keyless entry device (or the alarm remote control or key fob) to work reliably to it will deactivate or activate the alarm when you need it to happen?

Solution
Possible solution #1
Tighten the screws in the back or the side.  If the remote control (or key fob) has an intermittent problem, tighten the screws as much as possible.  Loose screws may create the symptom of an intermittent problem with the remote control of the key device.  You may want to buy a Leatherman device with tiny eye-glass Phillips screwdrivers.  Loose remote control casings can make the buttons not work every time.

Possible solution #2
Replace the battery in the remote control aka keyless entry device or key fob,

How Do You Log into a Windows Server in Google Cloud Platform?

Problem scenario
You created a Windows server in GCP.  How do you obtain credentials and connect to it?

Solution
1.  Make sure the firewalls allow for the connection.  See this posting if you need to change that.

2.  In the GCP console, go to Computer Engine -> VM Instances.  

3.  Go to the VM you want to connect to.  Under the "Connect" column find the small triangle that points downward.  Click on it and go to "Set new Windows password."

4.  Enter the username you want or use the default and click "Set."

5.  Copy it down.

6.  Open Remote Desktop.  Connect to the external IP address of the Windows VM.

How Do You View Failed User Login Attempts to a PostgreSQL Instance?

Problem scenario
You are running a LAPP application on Ubuntu Linux with PostgreSQL.  A user has complained that she cannot log into your Postgres database via a LAPP application.  You are not sure if the attempts are even registering of if the user is entering an incorrect username.  How do you look at a log to see a history of unsuccessful attempts at logging into the Postgresql database?

Solution
Examine this file: /var/log/postgresql/postgresql-x.y-main.log

(Substitute x.y with the major and minor versions of PostgreSQL you are running e.g., 9.5.)

It logs failed Postgres authentication attempts -- even if they come from a PHP web page (a web-based UI).  If a role, like an OS user but for postgres, tries to log in from a web application with the wrong password, it will be logged in to /var/log/postgresql/postgresql-9.5-main.log (if you are using PostgreSQL 9.5).  Please note that this log does not show successful database login attempts.  It is not a complete history -- it only records failed attempts.


To check operating-system-level failed logins, check these files (the top two pertain to SSH both successful and unsuccessful while btmp pertains to other failed remote login attempts):

/var/log/secure
/var/log/auth.log
/var/log/btmp

How Do You Detect the Hard Drive Letter That Your PowerShell Script (.ps1 File) Is Saved On?

Problem scenario
You have a PowerShell script that you want to be able to detect the hard drive letter it resides on.  How can PowerShell detect the hard drive letter that the .ps1 file itself is stored on?

Solution
Use this command: (get-location).drive.name

To get the drive letter to be in a variable named $dl, use this:
$dl = (get-location).drive.name

Now you can use $dl as the drive letter in the PowerShell script.   Creating composite strings such as c:\temp\various\ is easy with PowerShell.  Here is an example:

$lastsection = ':\temp\various\'
$compositeVar = $dl + $lastsection

# now compositeVar is the path x:\temp\various where x is the drive letter that the PowerShell script is ran from.

How Do You Solve the Problem “Cannot find a usable libpq.dll. Please launch heidisql64.r5168.exe from the directory where you have installed it”?

Problem scenario
In Windows 7 you start (or launch) HeidiSQL.  You try to connect to a remote server but you get the error "Cannot find a usable libpq.dll. Please launch heidisql64.r5168.exe from the directory where you have installed it."  How do you solve this problem?

Solution
Uninstall HeidiSQL and install the latest one from here.  If you download the latest build, the problem may remain.  You may need the installer.

How Do You Create an Option to Logout for a PHP Web Page to Destroy the Session?

Problem scenario
You have a LAMP (or LAPP) web page application.  The PHP code uses the session() functionality.  Once a user logs in successfully, he/she can browse to successive web pages.  You want to at least allow the user the opportunity to destroy the session (and terminate the authentication session).  How do you do this?

Solution
#1  Modify the .php file that you want to have the logout feature.  In the <html> <body> section of your .php file, add this line:

<a href="logout.php">Logout</a>

#2  Create a file named logout.php in the same directory as the .php file referred to in step #1.  Have this be the content of the logout.php file:

session_start();
session_destroy();
echo 'You have been logged out.;<a href="/path/to/login.php">Log in again.<a/>';
exit;

Note that /path/to/ is a subdirectory path of /var/www/html/ (or the default location of the web files).  login.php is the name of the .php file in /var/www/html/path/to/ that allows for logins.

How Do You Troubleshoot the Scala Error “No such file or class on class path”?

Problem scenario
You know Scala is installed because you use "man scala" and see the correct man page.  But when you try to find the version, you get an error.  Specifically you run this command:  scala version

You see this: "No such file or class on classpath: version."  How do you find out what version of Scala you have installed?

Solution
Reboot the server.

How Do You Install R on an Ubuntu Linux Instance of AWS?

Problem scenario
You are running Ubuntu Linux in AWS.  You want to install R. How do you do this?

Solution
(These directions below were adapted from this link.)

Prerequisite
Verify you have 1 GB of RAM.  Run this command:  sudo dmidecode -t 17 | grep Size

If you see 512 MB in the results of the above command, then you will not be able to get R installed.  You will need a different AWS server -- a flavor with at least 1 GB of RAM.  To upgrade the flavor to have more memory, see this posting.  To add virtual memory (aka swap space), see this posting.

Method
1.  Run these four commands:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get -y install r-base

2.  a.  Run this command to enter the R command prompt:  sudo -i R 

2. b.  Note that the ">" sign below is just a reference. Do not type the ">" or space thereafter when you type the command below.

> install.packages('txtplot')

2. c.    Enter a selection (e.g., 45 if you are in Texas).  Press enter.

2. d.  Run this command from the > prompt.

library('txtplot')

If there were no errors, then it is working.