Thursday, February 28, 2019

Sick of Keying in Username and Password During Pull and Push in GIT... Here is the solution

Hi everyone, let me take this opportunity to give you some details on two of the commands from GIT

1. git config credential.helper store
2. git push <clone URL of the repository>

Normally these two git utilities can be used for configuring your username and password once and the push and pull operation to and from GIT repository can be done multiple times without keying them.

Here is how we configure

Before we configure, please have the clone URL of the repository handy...

Move to the local repository, which means to the folder where your .git folder resides using a terminal and paste the command below
> git config credential.helper store


The above command would do nothing from the user perspective, now copy paste second command at the prompt as mentioned below... use your repository clone URL, in my case the URL is..

https://github.com/ravaneswaran/git-tutorial.git
> git push https://github.com/ravaneswaran/git-tutorial.git
The above command would prompt you to provide the username and password, provide your credentials to have them saved locally.


Try modifying some files and push those to the remote repo... you do not have to key in your credentials again

Well this concludes this post, hope this helped...

Tuesday, February 12, 2019

How to Restore MySQL Database Dump in MySQL Server in Linux Box

In this article I would like to discuss how to Restore database dump into MySQL Server...

For our discussion, let me have the database dump of database "mysql" from MySQL Server, which I have already taken in a file named "serverdump-of-database-mysql.sql"

To know how to dump a database from MySQL server, you can checkout my article given below...
How to take MySQL dump using the command utility "mysqldump"
This article assumes you have the Username and Password handy to connect to database server.

I am going to use the root user's credentials to access the server instance and to have the database dump.

To try out I am going to assume the following properties
DATABASE : mysql_dump
USERNAME : root
PASSWORD : admin

Open up a terminal and connect to MySQL Sever as dictated below.
> mysql --user=root --password
The above command would prompt to provide the password, please provide the one you used to connect to server, I am going to use the password "admin" as mentioned above.

Soon after you provide the password, you would have mysql prompt as given in the image below...


Now create a database as given below...
mysql> create database mysql_dump;
The above statement creates a database named "mysql_dump", to check that use the statement below...
mysql> show databases;
The above statement would list down the databases like the one given below along with the one just created...

As you can see we have the database "mysql_dump" created with no tables in it... this can be justified by firing the following statement at the prompt
mysql> use mysql_dump;
mysql> show tables;

the above command results something like the image given below...


Now exit from MySQL Server by typing "exit" at the prompt.
mysql> exit
So far we had been working on the set up, now is the time to restore the database we had backed up.

To achieve that... type the following command at the prompt
> mysql --user=root --password mysql_dump < <location-of-the-dump-file>
eg
> mysql --user=root --password mysql_dump < /home/ravaneswaran/serverdump-of-database-mysql.sql
provide the password to restore the database.

To check the restoration process successful... connect to database server and check the database "mysql_dump", which can be done as follows...
> mysql --user=root  mysql_dump --password
provide the password...
mysql> show tables;

The response of the above statement would be as follows...




Well this concludes the restoration of backed up database in MySQL Server.

Hope you enjoyed reading.

Monday, February 11, 2019

MySQL Server Installation in Ubuntu 18.10

Hi, this post discuss the installation of MySQL Server in Ubuntu-18.10.

You can install the same in many different ways you like, but this post talks about installing MySQL Server using "Advanced Package Tool" simply apt

This Advanced Package Tool comes default with Debian, Ubuntu and related Linux Distributions.

This procedure is not just for this particular distribution of Ubuntu but for other distributions too....

To install MySQL Server, you need to have Administrator Rights... so make sure you logged into the system with an account(Linux Login Account) with administrator rights

Open a terminal and issue the following command at the prompt..
 > which mysql
The above command gives the location of mysql executable.

/usr/bin/mysql

If nothing appears conveys us it is yet to be installed.

to install MySQL Server issue the following command at the prompt
 > sudo apt-get install mysql-server
the above command would prompt you to provide the password, provide the one associated with the account

Now the package manager i.e Advanced Package Tool would install MySQL Server

Be patience till the process is completed.

After the installation is completed, at the terminal issue the same command which we had used to check mysql service is installed. i.e "which mysql"

The response would give a valid location of mysql which is nothing but the client to connect to the database server.

The acutal server executable is mysqld whose location can be located the using the following
 > which mysqld
The above command would print out the location of the mysqld executable, usually you will be locating mysqld in the following folder

/usr/sbin/mysqld

With this we can confirm that MySQL Server is installed successfully but still we have not checked it is up and running or not

To have that check issue the following command at the prompt...
 > sudo service mysql status
If the server is not up and running

you can start the server as follows..
 > sudo service mysql start 
Now you should have mysql server instance for service.

to verify, execute the command "sudo service mysql status", which would result in response something like the one shown in the image below...


With this we have concluded the installtion of MySQL Server in Ubuntu-18.10

Thanks...


Sunday, February 10, 2019

Installing Liferay IDE and Code Upgrade/Migration tool in Eclipse Photon

Hi, in this post we are going to discuss the installation of Liferay-IDE in Eclipse - Photon

To have this done we need to have the softwares required... the following table provides the tools/softwares, use the link(s) to download them..

SoftwareDownload Link
Java - 1.8Java Software Development Kit - 8 Download  
Eclipse Photon(4.8)eclipse-jee-photon-R-linux-gtk-x86_64.tar.gz

To Install Java, there are plenty of resource available online find one for installing, Please make sure you set the environment variables appropriately, what I meant was setting JAVA_HOME and PATH

Use the following command to check Java-1.8 is available
> which java
the above command would give the path of the java executable.

To check the version of the same, use the following command
> java -version
Proceed with installing eclipse-photon

Just extract the .tar.gz file into your preferred location

If you like to change the default workspace location and config location of your
eclipse refer the post below...

Now start eclipse....

The objective of this post starts form here...

After you start eclipse, go to "Help" menu and click on "Install New Software", you would see a dialog appearing... Click on Add to add the repository for Liferay IDE installation as follows...

the URL for downloading the software component can be taken from the following location

https://community.liferay.com/project/-/asset_publisher/TyF2HQPLV1b5/content/ide-installation-instructions

you would find two URLs under the section "Using an Update Site", the first location gives you the stable version of the component and the second is the milestone

I am going to use the URL which stands against "Stable",you can use the
second one too but I prefer the stable one.

Copy the url and add the repository as given in the Image below and click on add to add the repository.


Soon after you add repository, eclipse would try to download the component and the dialog appears like the one below...


Try expanding the component Liferay IDE.. if you would, you could find five sub-components namely...

1. Buildship: Eclipse Plug-ins for Gradle
2. Liferay IDE
3. Liferay IDE AlloyUI
4. Liferay IDE Enterprise
5. Liferay IDE Maven Support

you can install all the components by selecting the parent component or selected one depending on your need. I want all to be installed hence selecting all and click next


now eclipse tries to download and install all the components. If everything goes fine at your end at the first go then it's fine else eclipse would display an error message something like this


Do not be panic, the main purpose of writing this post is to tackle this error... simply cancel the operation and proceed as follows...
Now you see the main window of eclipse... select "Help" menu and click "check for updates", now you would have something like shown in the image below...


select the component by clicking on "Select All" and proceed forward clicking Next



Click Next


Accept the license agreement and click "Finish" after installing the component eclipse would prompt you to restart it, restart by clicking the "Restart Now" Button.


Out of the components listed we have installed just one, we are going to install the rest now...you might have eclipse window on screen now if not start it.

Now we have to repeat the steps from step one i.e Select "Help" menu and click on "Install New Software"

from the Work with drop down, select the liferay-ide-repository, now what appears on the dialogs almost the same as image-2 of this post


try expanding the component Liferay IDE, doing so you would have something like shown in the image below...


As you can see we have only four components now to be installed excluding the first we installed separately, now try to installing one by one... you can also go with selecting all but I have not tried it, if anything goes wrong in the bulk install try installing one after the other..

I am sure you will have all the components installed and your eclipse would be packed with Liferay IDE. This update also comes with Liferay code migration tool.

To confirm, we can select the liferay prespective from the Window menu as below

Window > Perspective > Open Perspective > Other

Select the Liferay Workspace from Open Perspective dialog

Clicking the Open button would make eclipse to appear as Liferay IDE.

The image below would explain how to have the code migration tool along with Liferay IDE, from the window menu navigate as mentioned below to have the liferay code upgrade/migration tool

Window > Show View > Other

Clicking on Open, results the window to appear like the one as below...Well this concludes the installation of Liferay IDE in Eclipse-Photon.



Hope you liked it, Thanks.

Friday, February 8, 2019

How to create Custom Launch Icon for a program/executable in Ubuntu-16.04

This intention of this post is to create Custom Launch Icon for any program or executable that you have in Ubuntu.

For this experiment I have used Ubuntu-16.04 but you can have any distribution of Ubuntu of your choice.

To start with let me have the following

1. A tiny c program
2. An Icon to click

The C Program
#include <stdio.h>
int main(void){
        printf("Hello World... Welcome to Ravaneswaran Chinnasamy's Blog.\n");
        printf("Checkout :  https://ravaneswaran-chinnasamy.blogspot.com\n");
        printf("\n");
        printf("Press any key to exit the program...\n");
        getchar();
        return 0;
}

I have copy pasted the above program statements in a file named "helloworld.c" and executed the following command to make an executable out of it...
> gcc -o helloworld helloworld.c
now you find the executable version of helloworld.c in the folder where you executed the above command, move the executable to a preferred location, in my case /opt/bin (this location does not exist by default, you have to create one if you want one)

Similarly I have downloaded a .ico file from Internet and moved to a comfortable location(/opt/icons) to access.

Now we have to create a .desktop file and should fill it with the following properties, let the file name be hello-world.desktop 
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Name=Hello World
Icon=/opt/icons/hello-world.ico
Path=/opt/bin
Exec=/opt/bin/helloworld
StartupNotify=false
StartupWMClass=HelloWorld
OnlyShowIn=Unity;
X-UnityGenerated=true
the details about each of the key is given below...

Courtesy : standards.freedesktop.org

Key Description Type Mandatory
Type This specification defines 3 types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3). To allow the addition of new types in the future, implementations should ignore desktop entries with an unknown type. string YES
Version Version of the Desktop Entry Specification that the desktop entry conforms with. Entries that confirm with this version of the specification should use 1.1. Note that the version field is not required to be present. string NO
Name Specific name of the application, for example "Mozilla". localestring YES
GenericName Generic name of the application, for example "Web Browser". localestring NO
NoDisplay NoDisplay means "this application exists, but don't display it in the menus". This can be useful to e.g. associate this application with MIME types, so that it gets launched from a file manager (or other apps), without having a menu entry for it (there are tons of good reasons for this, including e.g. the netscape -remote, or kfmclient openURL kind of stuff). boolean NO
Comment Tooltip for the entry, for example "View sites on the Internet". The value should not be redundant with the values of Name and GenericName. localestring NO
Icon Icon to display in file manager, menus, etc. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon. localestring NO
Hidden Hidden should have been called Deleted. It means the user deleted (at his level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the .desktop file not existing at all, as far as that user is concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming) - by letting make install install a file with Hidden=true in it. boolean NO
OnlyShowIn, NotShowIn A list of strings identifying the desktop environments that should display/not display a given desktop entry.
By default, a desktop file should be shown, unless an OnlyShowIn key is present, in which case, the default is for the file not to be shown.
If $XDG_CURRENT_DESKTOP is set then it contains a colon-separated list of strings. In order, each string is considered. If a matching entry is found in OnlyShowIn then the desktop file is shown. If an entry is found in NotShowIn then the desktop file is not shown. If none of the strings match then the default action is taken (as above).
$XDG_CURRENT_DESKTOP should have been set by the login manager, according to the value of the DesktopNames found in the session file. The entry in the session file has multiple values separated in the usual way: with a semicolon.
The same desktop name may not appear in both OnlyShowIn and NotShowIn of a group.
string(s) NO
DBusActivatable A boolean value specifying if D-Bus activation is supported for this application. If this key is missing, the default value is false. If the value is true then implementations should ignore the Exec key and send a D-Bus message to launch the application. See D-Bus Activation for more information on how this works. Applications should still include Exec= lines in their desktop files for compatibility with implementations that do not understand the DBusActivatable key. boolean NO
TryExec Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example). string NO
Exec Program to execute, possibly with arguments. See the Exec key for details on how this key works. The Exec key is required if DBusActivatable is not set to true. Even if DBusActivatable is true, Exec should be specified for compatibility with implementations that do not understand DBusActivatable. string NO
Path If entry is of type Application, the working directory to run the program in. string NO
Terminal Whether the program runs in a terminal window. boolean NO
Actions Identifiers for application actions. This can be used to tell the application to make a specific action, different from the default behavior. The Application actions section describes how actions work. string(s) NO
MimeType The MIME type(s) supported by this application. string(s) NO
Categories Categories in which the entry should be shown in a menu (for possible values see the Desktop Menu Specification). string(s) NO
Implements A list of interfaces that this application implements. By default, a desktop file implements no interfaces. See Interfaces for more information on how this works. string(s) NO
Keywords A list of strings which may be used in addition to other metadata to describe this entry. This can be useful e.g. to facilitate searching through entries. The values are not meant for display, and should not be redundant with the values of Name or GenericName. localestring(s) NO
StartupNotify If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all (does not shown any window, breaks even when using StartupWMClass, etc.). If absent, a reasonable handling is up to implementations (assuming false, using StartupWMClass, etc.). (See the Startup Notification Protocol Specification for more details). boolean NO
StartupWMClass If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details). string NO
URL If entry is Link type, the URL to access. string YES

With that I have given the details of every property we have, now we have to make a important move to make our program appear when we search "Hello World" from "Search your computer" Icon on the Launch bar, to achieve that we have to copy the hello-world.desktop file to two locations...

 /usr/share/applications
~/.local/share/applications

To do that use the following command...
> sudo cp <path-to-the-hello-world-script/hello-world> /usr/share/applications
The above command may prompt you for password, provide the password to move the file successfully...
This move is for the entire system level.

The second move is achieved as given below...
> cp <path-to-the-hello-world-script/hello-world> ~/.local/share/applications
This move is for the User level.

Now if you try to search the application by clicking on the "Search your computer" Icon on the launch bar, our program would appear and click the icon to run it.
.
.
.
Thanks

Thursday, February 7, 2019

Changing the password of a user in database of LIFERAY PORTAL

This post discusses how to change the password of a liferay user at the database level to have him/her access to the portal instance

The targeted audience of this post is developers who develop the requirements on liferay portal

In order to do that you should have your database username and password handy

for our discussion, let me use TERMINAL BASH to connect to database, you can use any database client of your choice..

Connect to MySQL Service instance as follows...

Open a terminal and connect to MySQL as follows...

assuming USERNAME=root, PASSWORD=admin and DATABASE=lportal
> mysql --user=root --database=lportal --password
Press enter
this will ask you to provide password..

mysql> prompt would appear as a result of successful connetion to the database.

Before we change the password, I would like to give some hints on three important fields in the table User_, which are

password_ , passwordEncrypted , passwordReset

The password_ field : It's a varchar field, holds the user password in default encrypted format, i.e the encryption algorithm defined by liferay

The passwordEncrypted field : It's a tinyint field, tells liferay whether the password should take the encrypted or the plain text form

passwordEncrypted = 0; the password_ field will hold the password as plain text.
passwordEncrypted = 1; the password_ field will hold the password as encrypted text.

The passwordReset field : It's a tinyint field, tells liferay to make the user to reset the password as soon as they login

Let us pick a user whose password is to be changed...

Let us assume that we know the emailAddress of the user and let the emailAddress be "admin@liferay.com" having the emailAddress in hand we can query the database something like below

mysql> SELECT userId, emailAddress, password_, passwordEncrypted, passwordReset FROM User_ WHERE emailAddress='admin@liferay.com';

you will have the result as shown in the image below...



Now as you can see the password_ appears in encrypted form, passwordEncrypted holds '1' and passwordReset is '0'

This is how liferay stores user's password and this is the default behaviour of liferay..

In order to change the password of this user, we are going to update the above mentioned fields with the query as follows...
mysql> UPDATE User_ set password_='test', passwordEncrypted=0, passwordReset=1 WHERE emailAddress = 'admin@liferay.com';

Now if you use the SELECT query we used just before the UPDATE query... you will have the result as follows...



As you can see the password_ field holds the password in plain text format, which is not the intention but this would be changed by the user when he/she logs into the portal using the password "test".

Well we have reached the end of our discussion, hope you find this post useful.

Please post your comments...


Changing the default ".eclipse" and "p2" folder location in Eclipse IDE

Many of us have been using Eclipse IDE since we started developing programs in variety of languages but as a developer we never bothered the internals of it

Well there is so much into it, If we start talking the internals of eclipse IDE, it takes almost our lifetime to know it all.

What we discuss here is a tiny piece of information from the universe of eclipse, but worth knowing it

This post will give you some hints on changing the ".eclipse" folder and "p2" folders which you normally find at the user home directory

for discussion, let me take ECLIPSE-PHOTON as lab rat, you can have any major distribution of eclipse and try it. If you ask me I would suggest two major distributions back since photon would be appropriate and all other distributions there after since photon

The reason which made me write this post was, I was pulled to a situation during development where I should maintain different locations for such folders, as I was searching web, I encountered there were lot of people having the same problem or the requirement as I did.

Ok lets jump into the pool...

You can download Eclipse - Photon form the link below to try it or the Eclipse of your choice

Direct Link : Eclipse Photon Download

Eclipse Photon requires java-1.8 or higher to operate, so make sure you have java installed and appropriate environment variables are set accordingly....

i.e JAVA_HOME and PATH

Extract the eclipse-jee-photon-R-linux-gtk-x86_64.tar.gz file to your preferred location.

Now open a terminal and navigate to the CONFIGURATION folder as given below...
> cd <eclipse-photon-home-directory>/configuration
In the above mentioned folder you will have a file named "config.ini"

Open config.ini file in your favourite text editor(I prefer VI-Improved, simply vim) and include a configuration property at the bottom of the file
osgi.configuration.area=<preffered-location-of-your-choice>/.eclipse

Well that's it... Now you can start eclipse and check the folder you mentioned in the config property "osgi.configuration.area", I bet you would find two folders as said in the title....
.
.
.
Hey forgot to tell you about another parameter which can be used to change the default WorkSpace location when the eclipse starts

this parameter can be found in the file "eclipse.ini" at location <eclipse-photon-home-directory>/

The parameter which decides the default workspace location is "osgi.instance.area.default" 

You can change the value of this parameter to any of your preferred location as your workspace

Tuesday, February 5, 2019

How to take MySQL dump using the command utility "mysqldump"

This post discusses about taking backup of your database using the utility "mysqldump"

This post assumes you have MySQL Server installed, up and running

Alright, lets talk the business..

There are two ways you can have the MySQL Dump one is with data and another is without it

this post provides options for both, depending on you requirement you can pick the appropriate

Taking MySQL Server Database Dump with data

This form takes the format as mentioned below
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=<SERVERHOST> --port=<PORT> --user=<USERNAME> --verbose <DATABASENAME> --password > <FILENAME>.<EXTENSION>

let us assume certain parameters to this utility as follows
--host=localhost
--port=3306
--user=root
<DATABASENAME>=mysql
<FILENAME>=serverdump-of-database-mysql
<EXTENSION>=sql
for the above mentioned parameters, the command appears to be as follows...

mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose mysql --password > serverdump-of-database-mysql.sql

Now open a termial window and fire the command at the prompt as follows
> mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose mysql --password > serverdump-of-database-mysql.sql
at the end of the process you should be having the file "serverdump-of-database-mysql.sql" at the present-working-directory.

that is it, you have backed up your required database successfully...

Taking MySQL Server Database Dump without data

This form takes the format as the one we discussed above but with a little difference...
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=<SERVERHOST> --port=<PORT> --user=<USERNAME> --verbose <DATABASENAME> --no-data --password > <FILENAME>.<EXTENSION>

having the same parameters as discussed above the command appears to be...
mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose --no-data mysql --password > serverdump-of-database-mysql.sql

now fire the command at the prompt as given below
> mysqldump --routines --add-drop-table --disable-keys --extended-insert --host=localhost --port=3306 --user=root --verbose --no-data mysql --password > serverdump-of-database-mysql.sql

well that is it you have taken the structure or template of the requierd database.

Monday, February 4, 2019

How to remove MySQL completely in Ubuntu-16.04 ?

In this post we will discuss how to delete mysql server.

If you want to backup the database before removing MySQL service, you can refer the post

How to take MySQL dump using the command utility "mysqldump"

This post assumes you have running instance of mysql server which you want to remove or the corrupted one which you want to get rid of...

In the former case let us confirm first that the server is not running...

use the following command to check the server is running or not
> service mysql status or systemctl status mysql
the response would let you know whether the server is running or not

if the server is running then shut it down first as follows...
> sudo service mysql stop
use "service mysql status" to check the server has come to a stop.

Now we are going to perform the action intented... which is removing the mysql service

execute the following commands in order as they are mentioned at the terminal
> sudo apt-get remove --purge mysql*
> sudo apt-get purge mysql*
> sudo apt-get autoremove
> sudo apt-get autoclean
> sudo apt-get remove dbconfig-mysql

Deleteing the mysql directory in /etc and /var/lib
> sudo rm -rf /etc/mysql
> sudo rm -rf /var/lib/mysql

If you want to install MySQL Server again, you can check my post

MySQL Server Installation in Ubuntu - 18.10

Well that is it, please post your comments if you encounter any issue while removing the instance thanks.

Saturday, February 2, 2019

Moving the launch/task bar at the bottom of the screen in Ubuntu - 16.04

In this post we will see how to make the launch bar that appears on the left hand side usually, to appear at the bottom  of the screen

Before you proceed, please check gsettings utility is installed in your system...

open a terminal and type the following command at the prompt...

> which gsettings

the above command should give the path of the gsettings executable

if not, install the utility as said below...

> sudo apt-get update
> sudo apt-get install gsettings-desktop-schemas

The following are the command(s) would help you to have the launch bar at the bottom of the screen...

> gsettings set com.canonical.Unity.Launcher launcher-position Bottom

Open a terminal and Copy Paste the above command(with in quotes) at the prompt and execute it(I mean press Enter), as a result you will see the launch bar appearing at the bottom of the screen.

How to bring it back to the original position i.e at the left hand side?

It is as simple as you made the launch bar to appear at the bottom...

Copy Paste the below command at the command prompt and execute it

> gsettings set com.canonical.Unity.Launcher launcher-position Left

Well that is all about changing the position of the launch bar in Ubuntu 16.04

.
.
.
.
.

Hope this post helped you.. thank you


How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...