Ubuntu : Zip, Unzip file using terminal.

Here is way to create zip and unzip recursively. For this, You have to install zip and unzip installation packages with following commands in terminal. Open terminal by pressing Ctrl + Alt + T.

sudo apt-get install zip  // to install zip command packages. 
sudo apt-get uninstall zip // to Unistall unzip command package.

Create a zip file :

Go To the path of that folder which you have to make zip and run following command to make a zip file.

zip -r zip-file-name.zip directory-to-compress/
  • zip :  This is the application name, which we are using to create zip file.
  • -r : For recursive
  • zip-file-name.zip : Name of result zip file name.
  • directory-to-compress/ : Name of the directory which we want to compress.

You can add more than one directory in single archives by following command :

sudo zip -r zip-file-name.zip directory-1/ directory-2/

There is no need of -r (recursive) option for single file archive.

sudo zip a2bizz.zip a2bizz.php

Unzip file

Following command will help you to unzip a file.

sudo unzip a2bizz.zip -d destination_dir/
  • sudo : super user
  • unzip : This is unzip application, which is using to extract a zip file.
  • -d : Shorts for destination
  • destination_dir/: This is the directory where you want to extract files.

You can also use unzip a2bizz.zip to extract data on same dir.

Enjoy :)


Fix “System program problem detected” error on Ubuntu

From some last previous days I notice down that there is a error popup coming while I start or restart my system, on my Ubuntu OS. The error is “System program problem detected”. Basically comes up when a certain application crashes. Ubuntu program “apport”, responsible for detecting such crashes and upon user consent, report these crashes to developers. This process intends to get the problem fixed by the developers.

However, the problem is the popup comes up each and every time when the system starts and annoyed a normal user. Really, there is no need to show popup to user when they can’t do anything or it should not come back when the report is submitted regarding the error.

So, today we are here that how to get rid of this popup –







We can remove crash reports which are resided into /var/crash directory. These crash report files cause the error message to appear every time Ubuntu boots.

$cd /var/crash
$ ls

Just Remove the crash report files .

$sudo rm -rf /var/crash/*

After removing these crash reports, the Popup will stop appearing, but it will reappear again in future when a new crash report generated and added to the directory.

So toget rid of these, we should have to turn off ‘apport’ program which is responsible for detecting crash reports and to popup error message –

$ sudo nano /etc/default/apport

nano will open the file in below manner

#set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1

Change value of enable=1 to 0 and save the file from the next boot the error message will disappear, if you don’t want to restart system then restart apport from command line –

$sudo restart apport

How much you like this post, Please make your comments, which will help me as an appreciation.

Magento2: create custom module

Today we will learn to create custom module in magento2-

For installation and initial learning please visit our previous blogs of magento2.

The overall development we are doing on Ubuntu 14.4, local environment the base directory structure of my local is –

You can download full code from GIT below given URL –


Step 1.Initialization of your custom module –

First of all we will have to initialize our custom module to the list of modules with magento configuration, for which we will have to first create a /var/www/html/magento2/app/code/A2bizz/Blog/registration.php file and write below code –




if you hit your magento2 URL i.e. http://localhost/magento2/, now you will get below issue –

Cannot read contents from file "/var/www/html/magento2/app/code/A2bizz/Blog/etc/module.xml"

Now create module.xml on file /var/www/html/magento2/app/code/A2bizz/Blog/etc/module.xml and write below code –

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="A2bizz_Blog" setup_version="2.0.0" />

Now we have initialised our custom module, To check that please check /var/www/html/magento2/app/etc/config.php where your created module will be listed down, if not then upgrade custom module.

Step 2. creating controller & routing –

Now Further create controller file /var/www/html/magento2/app/code/A2bizz/Blog/Controller/Index/Index.php


namespace A2bizz\Blog\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
	protected $resultPageFactory;

	public function __construct(
		\Magento\Framework\App\Action\Context $context,
		\Magento\Framework\View\Result\PageFactory $resultPageFactory
		$this->resultPageFactory = $resultPageFactory;
    public function execute()
        return $this->resultPageFactory->create();


and a routes.xml file on path /var/www/html/magento2/app/code/A2bizz/Blog/etc/frontend/routes.xml,which will provide the path execution to your custom module –

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="blog" frontName="blog">
            <module name="A2bizz_Blog" />

here, in this xml we initializing the calling path for our custom module. In this way we have successfully hit out the controller for our custom module. Here in our example hit –

if the hitting above URL is showing blank white page, it means controller is hitted in a proper manner and now asking for the page layout.

Step 3. designing layout (view) for our custom module –

Now Further create layout files for your custom module /var/www/html/magento2/app/code/A2bizz/Blog/view/frontend/layout/blog_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <block class="A2bizz\Blog\Block\Blog" name="blog" template="A2bizz_Blog::blog.phtml" />

and add /var/www/html/magento2/app/code/A2bizz/Blog/view/frontend/templates/blog.phtml

echo "Blog Template";

Now hit your custom module URL again, will show you below error
Object DOMDocument should be created.

it means it is unable to find corresponding Block method for its layout.

Now create your Block method, in /var/www/html/magento2/app/code/A2bizz/Blog/Block/Blog.php

namespace A2bizz\Blog\Block;

class Blog extends \Magento\Framework\View\Element\Template
	public function _prepareLayout()
	    return parent::_prepareLayout();

Now, Executing your URL http://localhost/magento2/blog, will show you complete module functionality.

Mysql : terminal basics

About MySQL

MySQL is an open source database management software that helps users store, organize, and retrieve data. It is a very powerful program with a lot of flexibility—this tutorial will provide the simplest introduction to MySQL

How to Install MySQL on Ubuntu and CentOS

If you don’t have MySQL installed on your droplet, you can quickly download it.


sudo apt-get install mysql-server


sudo yum install mysql-server
/etc/init.d/mysqld start

How to Access the MySQL shell

Once you have MySQL installed on your droplet, you can access the MySQL shell by typing the following command into terminal:

mysql -u root -p

After entering the root MySQL password into the prompt (not to be confused with the root droplet password), you will be able to start building your MySQL database.

Two points to keep in mind:

  • All MySQL commands end with a semicolon; if the phrase does not end with a semicolon, the command will not execute.
  • Also, although it is not required, MySQL commands are usually written in uppercase and databases, tables, usernames, or text are in lowercase to make them easier to distinguish. However, the MySQL command line is not case sensitive.

How to Create and Delete a MySQL Database

MySQL organizes its information into databases; each one can hold tables with specific data.

You can quickly check what databases are available by typing:


Your screen should look something like this:

| Database           |
| information_schema |
| mysql              |
| performance_schema |
| test               |
4 rows in set (0.01 sec)

Creating a database is very easy:

 CREATE DATABASE database name;

In this case, for example, we will call our database “events.”

| Database           |
| information_schema |
| events             |
| mysql              |
| performance_schema |
| test               |
5 rows in set (0.00 sec)

In MySQL, the phrase most often used to delete objects is Drop. You would delete a MySQL database with this command:

 DROP DATABASE database name;

How to Access a MySQL Database

Once we have a new database, we can begin to fill it with information.

The first step is to create a new table within the larger database.

Let’s open up the database we want to use:

 USE events;

In the same way that you could check the available databases, you can also see an overview of the tables that the database contains.

 SHOW tables;

Since this is a new database, MySQL has nothing to show, and you will get a message that says, “Empty set”

How to Create a MySQL Table

Let’s imagine that we are planning a get together of friends. We can use MySQL to track the details of the event.

Let’s create a new MySQL table:

name VARCHAR(20),
food VARCHAR(30),
confirmed CHAR(1), 
signup_date DATE);

This command accomplishes a number of things:

  1. It has created a table called potluck within the directory, events.
  2. We have set up 5 columns in the table—id, name, food, confirmed, and signup date.
  3. The “id” column has a command (INT NOT NULL PRIMARY KEY AUTO_INCREMENT) that automatically numbers each row.
  4. The “name” column has been limited by the VARCHAR command to be under 20 characters long.
  5. The “food” column designates the food each person will bring. The VARCHAR limits text to be under 30 characters.
  6. The “confirmed” column records whether the person has RSVP’d with one letter, Y or N.
  7. The “date” column will show when they signed up for the event. MySQL requires that dates be written as yyyy-mm-dd

Let’s take a look at how the table appears within the database using the “SHOW TABLES;” command:

 mysql> SHOW TABLES;
| Tables_in_events |
| potluck          |
1 row in set (0.01 sec)

We can remind ourselves about the table’s organization with this command:

 DESCRIBE potluck;

Keep in mind throughout that, although the MySQL command line does not pay attention to cases, the table and database names are case sensitive: potluck is not the same as POTLUCK or Potluck.

 mysql>DESCRIBE potluck;
| Field       | Type        | Null | Key | Default | Extra          |
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | YES  |     | NULL    |                |
| food        | varchar(30) | YES  |     | NULL    |                |
| confirmed   | char(1)     | YES  |     | NULL    |                |
| signup_date | date        | YES  |     | NULL    |                |
5 rows in set (0.01 sec)

How to Add Information to a MySQL Table

We have a working table for our party. Now it’s time to start filling in the details.

Use this format to insert information into each row:

INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "John", "Casserole","Y", '2012-04-11');
Once you input that in, you will see the words:
 Query OK, 1 row affected (0.00 sec)
Let’s add a couple more people to our group:
INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "Sandy", "Key Lime Tarts","N", '2012-04-14');
INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "Tom", "BBQ","Y", '2012-04-18');
INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "Tina", "Salad","Y", '2012-04-10');

We can take a look at our table:

mysql> SELECT * FROM potluck;
| id | name  | food           | confirmed | signup_date |
|  1 | John  | Casserole      | Y         | 2012-04-11  |
|  2 | Sandy | Key Lime Tarts | N         | 2012-04-14  |
|  3 | Tom   | BBQ            | Y         | 2012-04-18  |
|  4 | Tina  | Salad          | Y         | 2012-04-10  |
4 rows in set (0.00 sec)

How to Update Information in the Table

Now that we have started our potluck list, we can address any possible changes. For example: Sandy has confirmed that she is attending, so we are going to update that in the table.

UPDATE `potluck` 
`confirmed` = 'Y' 
WHERE `potluck`.`name` ='Sandy';

You can also use this command to add information into specific cells, even if they are empty.

How to Add and Delete a Column

We are creating a handy chart, but it is missing some important information: our attendees’ emails.

We can easily add this:

 ALTER TABLE potluck ADD email VARCHAR(40);

This command puts the new column called “email” at the end of the table by default, and the VARCHAR command limits it to 40 characters.

However, if you need to place that column in a specific spot in the table, we can add one more phrase to the command.

 ALTER TABLE potluck ADD email VARCHAR(40) AFTER name;

Now the new “email” column goes after the column “name”.

Just as you can add a column, you can delete one as well:

ALTER TABLE potluck DROP email;

I guess we will never know how to reach the picnickers.

How to Del

ete a Row

If needed, you can also delete rows from the table with the following command:

DELETE from [table name] where [column name]=[field text];

For example, if Sandy suddenly realized that she will not be able to participate in the potluck after all, we could quickly eliminate her details.

mysql> DELETE from potluck  where name='Sandy';
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM potluck;
| id | name | food      | confirmed | signup_date |
|  1 | John | Casserole | Y         | 2012-04-11  |
|  3 | Tom  | BBQ       | Y         | 2012-04-18  |
|  4 | Tina | Salad     | Y         | 2012-04-10  |
3 rows in set (0.00 sec)

Notice that the id numbers associated with each person remain the same.

Linux: Shell Scripting basics

Writing your first script and getting it to work

To successfully write a shell script, you have to do three things:

  1. Write a script
  2. Give the shell permission to execute it
  3. Put it somewhere the shell can find it

Writing a script

A shell script is a file that contains ASCII text. To create a shell script, you use a text editor. A text editor is a program, like a word processor, that reads and writes ASCII text files. There are many, many text editors available for your Linux system, both for the command line environment and the GUI environment. Here is a list of some common ones:

Name Description Interface
vi, vim The granddaddy of Unix text editors, vi, is infamous for its difficult, non-intuitive command structure. On the bright side, vi is powerful, lightweight, and fast. Learning vi is a Unix rite of passage, since it is universally available on Unix/Linux systems. On most Linux distributions, an enhanced version of the traditional vi editor called vim is used. command line
emacs The true giant in the world of text editors is emacs by Richard Stallman. emacs contains (or can be made to contain) every feature ever conceived for a text editor. It should be noted that vi and emacs fans fight bitter religious wars over which is better. command line
nano nano is a free clone of the text editor supplied with the pine email program. nano is very easy to use but is very short on features. I recommend nano for first-time users who need a command line editor. command line
gedit gedit is the editor supplied with the Gnome desktop environment. graphical
kwrite kwrite is the “advanced editor” supplied with KDE. It has syntax highlighting, a helpful feature for programmers and script writers. graphical

Now, fire up your text editor and type in your first script as follows:

# My first script

echo "Hello World!"

If you have ever opened a book on programming, you would immediately recognize this as the traditional “Hello World” program. Save your file with some descriptive name. How about my_script?

The first line of the script is important. This is a special clue given to the shell indicating what program is used to interpret the script. In this case, it is /bin/bash. Other scripting languages such as perl, awk, tcl, Tk, and python can also use this mechanism.

The second line is a comment. Everything that appears after a “#” symbol is ignored by bash. As your scripts become bigger and more complicated, comments become vital. They are used by programmers to explain what is going on so that others can figure it out. The last line is the echo command. This command simply prints what it is given on the display.

Setting permissions

The next thing we have to do is give the shell permission to execute your script. This is done with the chmod command as follows:

[ub@linux ub]$ chmod 755 my_script

The “755” will give you read, write, and execute permission. Everybody else will get only read and execute permission. If you want your script to be private (i.e., only you can read and execute), use “700” instead.

Putting it in your path

At this point, your script will run. Try this:

[ub@linux ub]$ ./my_script

You should see “Hello World!” displayed. If you do not, see what directory you really saved your script in, go there and try again.

Before we go any further, I have to stop and talk a while about paths. When you type in the name of a command, the system does not search the entire computer to find where the program is located. That would take a long time. You have noticed that you don’t usually have to specify a complete path name to the program you want to run, the shell just seems to know.

Well, you are right. The shell does know. Here’s how: the shell maintains a list of directories where executable files (programs) are kept, and just searches the directories in that list. If it does not find the program after searching each directory in the list, it will issue the famous command not found error message.

This list of directories is called your path. You can view the list of directories with the following command:

[ub@linux ub]$ echo $PATH

This will return a colon separated list of directories that will be searched if a specific path name is not given when a command is attempted. In our first attempt to execute your new script, we specified a pathname (“./”) to the file.

You can add directories to your path with the following command, where directory is the name of the directory you want to add:

[ub@linux ub]$ export PATH=$PATH:directory

A better way would be to edit your .bash_profile file to include the above command. That way, it would be done automatically every time you log in.

Most modern Linux distributions encourage a practice in which each user has a specific directory for the programs he/she personally uses. This directory is called bin and is a subdirectory of your home directory. If you do not already have one, create it with the following command:

[ub@linux ub]$ mkdir bin

Move your script into your new bin directory and you’re all set. Now you just have to type:

[ub@linux ub]$ my_script

and your script will run.

Setup Apache Virtual Hosts on UBUNTU 14.04 LTS


The Apache web server is the most popular way of serving web content on the internet. It accounts for more than half of all active websites on the internet and is very powerful and flexible. Apache breaks its functionality and components into individual units that can be customized and configured independently. The basic unit that describes an individual site or domain is called a virtual host.

These allow the admin to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS. Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites. This scheme is expandable without any software limit as long as your server can handle the load.


Before you start, you need to create non-root as explained in step 1 to 4 here.

You will need to have Apache installed server. If you have not, you need to use following command to install apache on server.

sudo apt-get update
sudo apt-get install apache2


Step 1.  — Create the Directory Structure

Document root (the top-level directory that Apache looks at to find content to serve) will be set to individual directories under the /var/www directory.

Within root directory, create public_html folder for site related files.

To create directory, user following commands

sudo mkdir -p /var/www/a2bizz.com/public_html


Step 2. — Access Permissions
sudo chown -R $USER:$USER /var/www/a2bizz.com/public_html

The $USER variable will take the value of the user you are currently logged in.

sudo chmod -R 755 /var/www


Step 3— Create IndexPage for Each Virtual Host
nano /var/www/a2bizz.com/public_html/index.html


    <title>Welcome to A2bizz.com!</title>
    <h1>Success!  The awbizz.com virtual host is working!</h1>


Step 4 — Create Virtual Host File

Apache comes with a default virtual host file called 000-default.conf that we can use as a jumping off point. We are going to copy it over to create a virtual host file for each of our domains.
Create the Virtual Host File

Copy conf file

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/a2bizz.com.conf

Edit a2bizz.com.conf file in editor

sudo nano /etc/apache2/sites-available/a2bizz.com.conf

The file look like,

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.

ServerAdmin admin@a2bizz.com

After this, we need to add two directives ( i.e. ServerNameServerAlias )

ServerName a2bizz.com
ServerAlias www.a2bizz.com

We need to change virtual host file is the location of the document root for domain.

DocumentRoot /var/www/a2bizz.com/public_html

Virtual host file should look like this:

<VirtualHost *:80>
    ServerAdmin admin@a2bizz.com
    ServerName a2bizz.com
    ServerAlias www.a2bizz.com
    DocumentRoot /var/www/a2bizz.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

save and close the file.


Step 5 — Enable the New Virtual Host Files

Use the a2ensite tool to enable the site.

sudo a2ensite a2bizz.com.conf

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

You will most likely receive a message  something like following :

* Restarting web server apache2
 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this messag

This is a harmless message that does not affect our site.

Step 6 — Set Up Local Hosts File
sudo nano /etc/hosts

Add ip as per domain name   localhost   guest-desktop a2bizz.com

This will direct any requests for a2bizz.com on our computer and send them to our server at

save and close file.

Step 7— Test virtual host

Linux: Searching and Replacing string in multiple Files in a directory/ folder

I recently stuck into a condition in which I have to replace every occurrence of a certain word / string in a number of files spanning multiple directories, and this is the easiest way I found to do it. It uses grep to search for a certain word and if it find its it runs sed to replace the strings you want. Note: This will not work on windows systems

Basic Format

grep -rl 'stringToFind' /path/to/directory/where/files/are/saved | xargs sed -i 's/stringToFind/stringToReplace/g'
Note: The forward slash '/' delimiter in the sed argument could also be a different delimiter (pipe ‘|’ character). The pipe delimiter might be useful when searching through a lot of html files if you didn’t want to escape the forward slash, for instance.


grep -rl 'room' ./ | xargs sed -i 's/room/house/g'

This will search for the string ‘room’ in all files relative to the current directory and replace ‘room’ with ‘house’ for each occurrence of the string in each file.

Magento2: Command Line or Terminal installation on Ubuntu

A long-waited Magento2 now appeared on Magento site for installation. Of course we couldn’t sit still and installed Magento2 on our server. And described the installation process for you, including the issues we dealt with and how we fixed them.

Pre Installation

The first steps lead us to the installation guide page. It is required to check whether your server suits minimal Magento 2 requirements:

Apache: 2.2 or 2.4

PHP: 5.5.x or 5.6.x

MySQL: 5.6.x


As we are using Ubuntu 14.4,  so the system suits minimal database requirements, and we already have PHP 5.5.x support. Also you’ll need Git and Composer, install it if you haven’t done it before.

Use these commands in command line or terminal for root user permissions:

apt-get update
apt-get install git wget
wget -O /usr/local/bin/composer http://getcomposer.org/composer.phar
chmod +x /usr/local/bin/composer

Magento 2 download

Now it’s time to clone Magento 2 code from GitHub repository. http://magento2/ is the URL of our website, and the document root is /var/www/magento2. Use these commands if you don’t plan to install Sample data for Magento 2:

cd /var/www 
git clone https://github.com/magento/magento2.git
cd /var/www/magento2
composer install

If you plan to install Sample data – refer to this link for details. As for now Magento 2 is still under development, the best variant is to read the latest documentation at Magento docs.

File permissions

create a root user, which is the owner of all magento files on your server, and Apache web server runs on behalf of ‘www-data’ user. Magento 2 documentation describes the access permission settings for files and directories on the principle that the web server runs on behalf of the user which is the owner of all Magento files. Our opinion is: it’s not the best decision, as it can lead to security issues (as the web server has permissions to write and run the code) as well as issues with setting access permissions for third party developers (as you’re not logging in as www-data user). We normally use the following access permissions:

chown -R :www-data /var/www/magento2
find /var/www/magento2 -type f -print0 | xargs -r0 chmod 640
find /var/www/magento2 -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/magento2/{pub,var}
chmod -R g+w /var/www/magento2/{app/etc,vendor}


now create database –

echo 'CREATE DATABASE `magento2` DEFAULT CHARSET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON `magento2`.* to `magento2`@`%` IDENTIFIED BY "magento2";' | mysql -h mysql56.local -u root -p

Magento2 installation

Now all is set start you magento installation using below command

/var/www/magento2/bin/magento setup:install --base-url=http://magento2/ --db-host=localhost --db-name=magento2 --db-user=root --db-password=root --admin-firstname=a2bizz --admin-lastname=user --admin-email=a2bizz@gmail.com --admin-user=a2bizz --admin-password=a2bizz@123 --language=en_US

Magento2: Pre Installation process

Before we go into the installation process, first we need to check the Magento basic sytem requirements –


for more information – please visit magento official documentation URL

After setting and fulfill all basic system requirements, now you download latest magento2 version, which we can download from www.magento.com/download , here you will see two types of packages, one without and another with Sample data, whatever package you want you can install, if you want to install magento2 for testing purposes, then go for magento2 package with Sample data.


Now you have completed all pre-installation process requirement, go for the next Step By Step process for magento2 Installation