Where are packages installed in Ubuntu : Debian Derivatives

Ubuntu, which is a Debian derivative, follows a very precise structure when installing packages. In other words, all software installed through the packaging tools, such as apt-get or synaptic, will put the stuff in the same locations. If you become familiar with these locations, you’ll always know where to find your stuff.

As a short cut, you can always open a tool like synaptic, find the installed package, and inspect the “properties”. Under properties, you’ll see a list of all installed files. Again, you can expect these to always follow the Debian/Ubuntu conventions; these are highly ordered Linux distributions. IN short, binaries will be in /usr/bin, or some other location on your path ( try ‘echo $PATH’ on the command line to see the possible locations ). Configuration is always in a subdirectory of /etc. And the “home” is typically in /usr/lib or /usr/share.

For instance installing maven,

sudo apt-get install maven

The Apt-get installation will install all the required files in the following folder structure

/usr/bin/mvn

/usr/share/maven2/

/etc/maven2

P.S The Maven configuration is store in /etc/maven2

Note, it’s not just apt-get that will do this, it’s any .deb package installer.

Git Rebase

The first and most important thing if you’re a committer working on a branch shared with other committers is to never use the default git pull. Use the rebase version, git pull --rebase. That takes your commits that are not on the remote version of your branch and reworks/rebases them so that they’re ahead of (on top of) the new commits you pull in with your pull.

Assuming you are on the master branch checkout at a point of time.  You have progressed making changes adding and committing them to your local store.

user@sys204:~/projects/dc-server$ git status
On branch master
Your branch and ‘origin/master’ have diverged,
and have 1 and 1 different commit each, respectively.
(use “git pull” to merge the remote branch into yours)

 

Stage your local changes: Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git checkout — <file>…” to discard changes in working directory)

modified:   app/controllers/api/ContApiController.java
modified:   app/utils/CSVUtils.java
modified:   app/utils/SelectBuilder.java
modified:   test/controllers/api/ContApiControllerTest.java

Untracked files:
(use “git add <file>…” to include in what will be committed)

app/models/api/BasePackage.java
app/models/api/CallPackage.java
app/models/api/CompContPackage.java
app/models/api/EmailPackage.java
app/models/api/MailPackage.java
app/models/api/Person.java
app/models/api/test/

no changes added to commit (use “git add” and/or “git commit -a”)
user@sys204:~/projects/datacaptive-server$ git stash save “Package Factory in Place with Abstraction and Inheritance”

Saved working directory and index state On master: Package Factory in Place with Abstraction and Inheritance
HEAD is now at d8f3827 Bad Request Tests

user@sys204:~/projects/datacaptive-server$ git stash list
stash@{0}: On master: Package Factory in Place with Abstraction and Inheritance
stash@{1}: On master: Tests included for BadRequest, Exception Handling in fetchstatesforcountries
stash@{2}: WIP on master: 8829572 API Contracts, to return JSON responses. sabhi

user@sys204:~/projects/datacaptive-server$ git rebase
First, rewinding head to replay your work on top of it…
Applying: Bad Request Tests
Using index info to reconstruct a base tree…
M    app/controllers/api/ContApiController.java
M    conf/application.conf
Falling back to patching base and 3-way merge…
Auto-merging conf/application.conf
Auto-merging app/controllers/api/ContApiController.java
user@sys204:~/projects/datacaptive-server$ git stash apply stash@{0}
Auto-merging app/controllers/api/ContApiController.java
CONFLICT (content): Merge conflict in app/controllers/api/ContApiController.java

How does Play Framework manage hot reloading?

It’s not really Play managing the hot reloading but rather the Play SBT plugin.

A Play application’s main method is in play.core.server.NettyServer. The method receives a reloader of type SBTLink and each time a request hits the server, the application delegates the task of checking if there have been any code changes to the reloader.

If there has been a code change then the existing classloader is removed and replaced with a new one which includes the updated bytecode. The application is restarted but, of course, the JVM is not.

Play is not designed to provision dynamic swapping of Jars at runtime. For this, you would need to look at things like OSGi (which I would not personally recommend after a few years of working with it).

Payment Gateway Integrations

Payment Gateway is a software that transmits TRANSACTION Information to ACQUIRING BANKS & RESPONSES from ISSUING BANKS(whether transaction is approved/declined). In a nutshell, Payment Gateway facilitate communication within Banks. A payment gateway helps in selling on-line. It allows to charge a customer’s credit/debit card with the purchase he/she makes on-line. In short, this authorizes you to take card payments directly from your website. You can call it mediator between the transactions that take place on your website and the payment processor.

Payment Processors: They provide all the payment processing services used by an on-line merchant. The payment processor connects to both the merchant account and payment gateway, quickly passing information back and forth, keeping it secure and almost instantaneous for the end user.

Merchant Accounts: Merchant accounts are the types of bank accounts that authorize merchants to accept credit or debit cards payments online. These accounts are required if you want to use a payment gateway to process transactions from your website. You can read about MIDs on paypal , which is merchant IDs!

 

Create your own payment gateway https://www.konakart.com/docs/modules.html

killbill is an opensource widely popular billing system built with Java Servelts, MySQL and Jetty as a webserver. It is built using servlets and google guice containers as an API application, ready to be consumed from a variety of applications. It support multi tenancy with MySQL datastore.

JBilling is another Java based billing system.

PayumServer is a php based opensource application supporting multiple payment gateways. Built on Symfony framework & MySQL

 

Protobuf: Migrating from proto2.6 to proto3

Uninstall protobuf-compiler
To remove just protobuf-compiler package itself from Ubuntu

sudo apt-get remove protobuf-compiler
Uninstall protobuf-compiler and it’s dependent packages
To remove the protobuf-compiler package and any other dependant package which are no longer needed from Ubuntu.

sudo apt-get remove –auto-remove protobuf-compiler
Purging protobuf-compiler
If you also want to delete configuration and/or data files of protobuf-compiler from Ubuntu

sudo apt-get purge protobuf-compiler

To delete configuration and/or data files of protobuf-compiler and it’s dependencies from Ubuntu Trusty then execute:

sudo apt-get purge –auto-remove protobuf-compiler

Once uninstalled, installation for proto3 follow the steps as described below

curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip

unzip protoc-3.2.0-linux-x86_64.zip -d protoc3 

Note: run command ‘sudo apt install unzip’ if the program ‘unzip’ is currently not installed.

sudo mv protoc3/bin/* /usr/local/bin/

sudo mv protoc3/include/* /usr/local/include/

 

To check where protbuf compiler is installed or the version of the protobuf compiler,

user@LT-201:~/Downloads$ which protoc
/usr/local/bin/protoc
user@LT-201:~/Downloads$ protoc –version
libprotoc 3.2.0

MySQL Remote access denied – Host is not allowed to connect to this MySQL server

At times when the MySQL server is residing on a different machine, and you want to access MySQL remotely you would get the error as access denied.

To resolve the issue,

First ensure that MySQL server is configured to accept remote connections from the user by verifying the My.cnf

Locate the my.cnf at

vim /etc/mysql/my.cnf, at times the configuration file could also be 
located at etc/mysql/mysql.conf.d/mysqld.cnf

comment out the lines 
#bind-address           = 127.0.0.1
#skip-networking

Restart the MySQL Server


Give permissions to the user who is trying to connect the MySQL Server
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

Verify that the privileges have been assigned
SELECT * from information_schema.user_privileges where grantee like "'USERNAME'%";

Finally flush the privileges to take effect.
FLUSH PRIVILEGES;

Just in case if mistakingly privileges have been given to revoke the privileges to the uer

mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'USERNAME'@'%';
Following will revoke all options for USERNAME from particular IP:

mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'USERNAME'@'1.2.3.4';
Its better to check information_schema.user_privileges table after running REVOKE command.
 

 


 

MySQL Configuration file in Workbench

A fresh installation of MySQL – Workbench in ubuntu at times does not reflect the mysql configuration file which is being used by the server. To set it up we first need to know the configuration files used at start up.

Following are the steps to determine which configuration file is used.

Determine mysql process from where it is initiated

user@Sys-201:/etc/mysql/conf.d$ ps aux | grep mysql
mysql    22272  0.1  1.2 1509844 198076 ?      Ssl  14:51   0:01 /usr/sbin/mysqld
user     22312  0.0  0.0  12548  3024 ?        S    14:51   0:00 /bin/bash /usr/bin/mysql-workbench
user     22315  0.0  0.0   4508   860 ?        S    14:51   0:00 /bin/sh /usr/bin/catchsegv /usr/lib/mysql-workbench/mysql-workbench-bin
user     22317  1.5  1.0 1506344 164356 ?      SLl  14:51   0:11 /usr/lib/mysql-workbench/mysql-workbench-bin
user     22514  0.0  0.0  14224   932 pts/1    S+   15:04   0:00 grep –color=auto mysql

besides the mysql row, it should indicate the configuration file which mysql is using when it starts off

If no file found, double check which instance of mysqld is running by issuing
user@Sys-201:/etc/mysql/conf.d$ which mysqld
/usr/sbin/mysqld

The one with the above matches the one listed, issue the following command to detect the order of loading the configuration files.
user@Sys-201:/etc/mysql/conf.d$ mysqld –verbose –help  | grep -A 1 “Default options”
mysqld: Can’t change dir to ‘/var/lib/mysql/’ (Errcode: 13 – Permission denied)
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

 

Once you know for certain that the configuration file used, the same can be associated with MySQL – Workbench by

Database-ManageConnections-> Select Connection in the Left hand pane-> The right hand side pane is enabled, select System Profile Tab-> Configuration File, specify the config file