How Do You Find the Amount of RAM Your Linux Server Has in GB?

Problem scenario
You want to find the total RAM a Linux server has.  You do not want the number to be in kilobytes.  You want human-readable output.  What do you do?

Solution
Run this command:

free -g | grep Mem | awk ‘{print $2 ” gigabytes of RAM total (sum of in use and available combined)”}’

If the amount of GB is less than 0.5,

How Do You Install PostgreSQL on an EC2 SUSE (AWS Instance of Linux SUSE)?

Problem scenario
You want to install Postgres on Linux SUSE.   This AWS server is in a security group with the ability to get to the Internet.  How do you install PostgreSQL on it?

Solution
1.  Log into the SUSE server with the default ec2-user.  The default user for AWS SUSE instances used to be root.  But now it is ec2-user.

2.  Run these five commands (taken from 

How Do You Write a Backend PHP Script to Query Postgres and Create a Database Name “foobar”?

Problem scenario
You are running Ubuntu Linux, and you want to create a .php script to be ran at the command prompt like this:

php good.php

You want this to open a PosgreSQL connection and issue a DDL command to create a database.  This is not a PHP web page.

Solution
This solution is only slightly more complicated than using PHP to run a basic SQL query in a Postgres database.

​How Can PHP Accept Data from a Form and Assign It to Variables for Future Retrieval?

Problem scenario
You want a web page to request user input.  After the user clicks “Submit” you want the values to be assigned to variables for future usage (e.g., an algorithm could retrieve the values to manipulate them).  How do you use PHP to assign input from a web page to be variables on the back end?

Solution
You need two files.  

How Do You Troubleshoot the PHP Error “role is not permitted to log in” So Your Script Can Log into a Postgres Database?

Problem scenario
You are trying to use a .php script on the back end to connect to your PostgreSQL database.  However, you get an error like this when you try to run it:

‘PHP Warning:  pg_connect(): Unable to connect to PostgreSQL server: FATAL:  role  “funuser” is not permitted to log in in /tmp/d.php on line 7’

How can your .php script log into the Postgres database?

How Do You Troubleshoot a PHP Error “call to undefined function pg_connect()” So Your Script Can Log into a Postgres Database?

Problem scenario
You are trying to use a .php script on the back end to connect to your PostgreSQL database.  However, you get an error like this when you try to run it:  ‘PHP Fatal error:  Call to undefined function pg_connect() in ‘

Solution
Install php5-pgsql.  For Ubuntu you would run a command like this:  sudo apt-get install php5-pgsql

How Do You Fix “Scanning Plug and Play compliant hardware” Message That Does Not Go Away?

Problem scenario
Flash drives and USB ports are not working properly in Windows.  You are not able to use a variety of working USB sticks.  These flash drives have files that you need.  When you go to Device Manager and right click “Universal Serial Bus controllers” or other sub-devices, you see this error “Scanning Plug and Play compliant hardware.”  It never goes away.  The Device Manager window becomes stuck.

How Do You Find the PID when You only Know It by the Task Name in the Task Manager?

Problem scenario
You have an application (in Windows) running, and you want to terminate it with PowerShell.  You want to find running program’s PID.  But you only know its name in Task Manager.  

How do you obtain the Process ID (identification number) of a program (or application) in Windows when you only know the Task Manager name of the program (or application)?

Solution
1.

How Do You Start the Postgres Service on an Ubuntu Linux Server?

Problem scenario
You have Postgres installed on an Ubuntu Linux server.  You want to start the Postgres service. How do you do this?

Solution
Run this command:  service postgresql start

If you want to list the databases on the server, run these three commands:

sudo -i -u postgres
psql
\l

# To exit the psql command prompt,

How Do You Use C++ to Retrieve Data from a PostgreSQL Database on Ubuntu Linux?

Problem scenario:  You have C++ and Postgres installed on an Ubuntu Linux server.  How do you write C++ programs to retrieve data from Posgres databases?

Solution
Install the official C++ API for Postgresql.  These directions should work on any Debian distribution of Linux.

As root, do the following from the Linux command prompt:

apt-get -y install libpq-dev g++
cd /usr/bin/
curl http://pqxx.org/download/software/libpqxx/libpqxx-4.0.tar.gz >