Monday, March 19, 2018

Scheduling Ubuntu program with gnome-schedule

In Ubuntu you can schedule any task to run automatic or on a specific time.
For this either you can use gnome-schedule GUI or using crontab command.

Using gnome-schedule

=========================
1.   First make sure your program is running properly.
2.   Open the terminal (using Ctrl+Atl+t shortcut key).
3.   Enter the following command to install gnome-schedule
sudo apt-get install gnome-schedule
4.   Enter gnome-schedule command in the terminal window to open the desired GUI, as given below.

5.   Now click on "New" button.
6.   Select "A task that launches recurrently" option to execute the programm repeatedly in a specific time inerval.


7. Enter the Description and Command in corresponding fields.
8. Click Advanced radio button to explicitly mention the execution time. Now click on "Add" button.
    Examples:
                    Minute: 5, Hour: 15,  Day: *, Month: *, Weekday: *
                          This will execute the program Everyday, every month, at time 15:05 (3:05 PM)

    Click here to see some examples.  


Using crontab command

==========================
1.   Open terminal (using Ctrl+Atl+t shortcut key).
2.   Enter crontab -e
3.   Add one line in following format at the end of the file.
          <minute> <hours> <day> <month> <weekday> <Command to execute>
4.   Now save the file.

That's all.




Friday, March 16, 2018

Different ways to open a notification/dialoge box in Ubuntu

Different ways to display a dialog box or a status message in Ubuntu.

1.   notify-send -i /home/user/Desktop/notifications.ico "MsgSummary"  "This is message body !!!"

2.
     gxmessage "This is message body"
     gxmessage -file message.txt
     gxmessage -center -timeout 3 -fg RED -file message.sh

3.
     whiptail --msgbox "This is the message" 10 50
     whiptail --yesno "Press wither yes or no" 10 50

4.
     dialog --msgbox "This is the message" 10 50

5.
     zenity --info --text="Here is the message body"
     zenity --calendar
     zenity --color-selection
     zenity --password

Please see user manual of each command for more detailed information.
You can find more ways. Please comment if more options are there to display a message.


-Thanks

Thursday, March 15, 2018

Making the backup process simple and automatic

Let's we have two Ubuntu servers:

Server-1: IP: 1.2.3.10 (source server )
                 user account name: user1
                 user account password: user1
                
Server-2: IP: 1.2.3.11 (Destination server)

--------------------------------------------------

On Server-1
1. Install openssh-server. You may install through terminal.
2. configure openssh-server if needed, else leave it to the default configuration.

On Server-2
1.  Install openssh-server and sshpass through the terminal.
2.  Change the current directory to $USER/Desktop/backup
3.  Create the directory "data"
3.  Create a password file "pw.txt" with following content.
"pw.txt" content
user1
 4.  Create a shell script file with the name "backup.sh" with following content.
backup.sh content
sshpass -f pw.txt scp -r user1@1.2.3.10:data/*  /home/server2/backup/data/

5.  Make sure pw.txt and backup.sh files are in the same directory.
6.  Execute following command in the terminal
    bash backup.sh
   This  will copy all the content from user1@1.2.3.10:data/ path on Server-1 to /home/server2/backup/data/ directory on Server-2.

--------------------------------------------------

Now its time to schedule the bash backup.sh command to execute in a specific time interval

Make sure you have gone thorugh crontab manual page or gnome-schedule GUI. You may also go through this page to know more details on crontab and gnome-schedule.

1.  Open terminal
2.  Enter following command
crontab -e
3. If you are executing this command for the first time, it will ask for the choice to open an editor.
4. In the editor add following line at the end of the file.
0,12 * * * * bash /home/server2/backup/backup.sh
5. Save and exit the editor.

You can also use gnome-schedule command to schedule the "backup.sh"


-Thats all



Sunday, March 11, 2018

Installing Docker on Ubuntu 14.04 OS [Update]

Steps:

  s1:    sudo apt-get update
  s2:    sudo apt-get install \
                  apt-transport-https \
                  ca-certificates \
                  curl \
                  software-properties-common
  s3:    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  s4:    sudo add-apt-repository \
                  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
                  $(lsb_release -cs) \
                  stable edge"
  s5:    sudo apt-get update
  s6:    sudo apt-get install docker-ce
  s7:  For testing the docker
           sudo docker run hello-world

 Create the "docker" group
   sudo groupadd docker
Add the current user to the "docker" group
   sudo usermod -aG docker $USER

Now logout and then login again from the currnet session.

You can download and run the following shell script file.
InstallDocker.sh

Wednesday, August 23, 2017

Virtualization: The technology behind cloud

Virtualization is the dominant technology used to set up cloud environment. In traditional approach, without using virtualization technology, only one OS can be installed onto one physical machine. However, using virtualization technology, multiple machines can be created, called Virtual machines (VMs) or virtual server. In research articles, PMs are also referred to physical servers. Similarly, the physical resources are also refers to substrate resource. Now, lets understand the figure given below.




Fig: Type-1 and Type-2 hypervisor
[src]: https://commons.wikimedia.org/wiki/File:Hyperviseur.png#/media/File:Hyperviseur.png



The virtual machines can be created only with the help of a small piece of software call virtual machine monitor (VMM) or virtual manager that implements the virtualization technology. The VMM can be installed directly on the hardware (Type 1 in the above figure) or can be installed atop an OS (Type 2 in the above figure). When the VMM is installed atop an OS, that OS is called hosted OS and the OS that is installed in each virtual machine is called guest OS. This virtualization layer provides and environment for the VMs to interact with the hardware. Another major responsibility of virtualization layer is to maintain the isolation among the VMs or guest OSs.

Here question arises, how this technology helps us to setup a cloud environment. When the cloud user ask for a computer with the configuration 2GB memory, 2 processing units, 50GB storage, and 2mbps network connection, cloud service provider creates a VM with the configuration provided by the cloud user. The cloud user is than given a URL in order to establish a connection to the created VM. Cloud user has no information regarding the underlined PM upon which the VM is created. In general CSPs adopt the TYPE 1 (in the above figure) approach to create the VMs. multiple VMs are created upon single PM. Another major advantage of this virtualization technology is that, it is very easy to migrate a VM fromone PM to another. Users are also NOT given any facility to interact with the physical machine which make the PMs more secure from the outside attacker.

Here is the link to calculate the number of VMs per PM or Host. In today's date an average of 40-60 VMs are created on each PM.

Based on the where the VMM is installed and purpose of the installation, virtualization is of four types[1].
    1. Hardware Virtualization : If the VMM is install atop the hardware, e,i, Type 1 in the above figure
    2. OS Virtualization : If the VMM is install atop an Operating System, e.i. Type 2 in the above Figure
    3. Storage Virtualization : Here the VMM is installed on multiple storage servers, which forms a single storage system for the user.
    4. Server Virtualization: When the VMM installed to divide the single physical server system into multiple virtual servers.

Besides aforemention four types, virtualization can also be divided into data virtualization, memory virtualization, network virtualization etc categories[2].




Thats all about the basics of Virtualization. Please comment if you need more further detail information.

Thank you

Tuesday, June 27, 2017

Cloud computing for layman



Before digging to the concept of cloud computing, Let's see how we consume electricity. Basically in every region some companies/organisations are providing electricity to every house. Electricity provider uses Copper or Aluminium wire to provide eletricity to our houses. In addition to that, external electric meter is attached in every house to monitor the amount of electric power we are consuming.

Now imagine computer instead of electricity. Some organization may offer you computers instead of electricity. Computers will be rented to you over high speed internet by some organization. The computers are not provided physically by shifting the machines to your location, rather, the organizations/providers allow you to connect to that computer over high speed internet. A large number of computers are used by the provider. Those large number of computers, also known as servers, are kept in secure place called Data Center. Henceforth, we will use the term server instead of computer. The organization is called cloud service provider (CSP) and the users are called cloud user. So here we have two entities: cloud consumer/user, and the CSP.

The CSP also provide the software on a rented instead of the server. Let’s say, I want to use MS office. In that case I’ll have two options: either buy the software or rent from the CSP. In later option, you will be allowed to access the software through a webpage or some explicitly designed different interface. Such interface will provide you all the required functionalities and you need to pay based on different costing model. This kind of service offered by the CSP is called Software as a Service (SaaS). For example, Google Apps, Salesforce etc

User may also request the CSP multiple number of servers with certain configuration. For example, One may ask the CSP to provide two servers with 4GB memory, 50GB storage, 4 processing units. Offering such service to the cloud users is called Infrastructure as a Service (IaaS). For example Amazon AWS, Windows Azure, Google Compute Engine, IBM SmartCloud Enterprise, Rackspace Open Cloud etc.

Coming to another type of service, CSP also customize the service based on the users requirement such as providing the platform. Here user refers to the software developer. CSP provides all the required software components, such as database servers, programming environment etc, in order to develop a software tool. Such kind of service is called Platform as a Service, in short PaaS. For example, Google App Engine provides the environment to develop web applications using Java, Python, PHP and Go.

Fig. 1 : Snap of data center’s inside view [src]

Thats all about the basics of Cloud Computing. Next, we will see the underlined technology behind the cloud computing.

-Thank you


Monday, June 19, 2017

Shell Script: Pausing the execution with sleep command

To pause the execution of shell script use sleep command.

Examples:

sleep 1   # Pause for 1 sec
sleep 1s  # Pause for 1 sec
sleep 1m  # Pause for 1 min
sleep 1h  # Pause for 1 hour
sleep 1d  # Pause for 1 day
sleep .1  # Pause for 100 mili-sec i.e. 0.1sec



Thank you

Saturday, June 10, 2017

X11 forwarding using Xming X server for Windows

Problem statement:

Let's say, We have 2 two computers: One with Ubuntu OS and other with Windows OS
Through SSH connection, "How can we access the any application's interface (GUI) installed on Ubuntu computer from Windows computer ?". For example, we want to access the GUI of calculator application that is installed on Ubuntu from Windows computer.

Environment:

First computer:
                       OS- Ubuntu 14.04 64-bit
                       Openssh-server package
Second computer:
                       OS- Windows 8 64bit
                        Xming software tool

Here, for demonstration, we will open GUI of calculator application
The command to open the calculator in Ubuntu is gnome-calculator                      

Step-1:
On Ubuntu Computer, install openssh-server package.

Perform Step-2 to 5 on Windows computer.
Step-2:
On Windows computer: 
Download Xming for Windows 8 64bit.
Install Xming executable file. You don't have to do any changes. Leave everything to the default selection.

Step-3: 
Now open command prompt on Windows computer
Change the directory to the location where Xming is installed. In my case it is "C:\Program Files (x86)\Xming"


cd "c:\Program Files (x86)\Xming"

Step-4:
Now enter the following command to start Xming on Windows


Xming.exe -multiwindow -clipboard


Step-5:
Now its the time to connect to the Ubuntu computer through inbuilt putty. In this step, you need to provide the login information, and the command to open required application.

The command can be

plink -ssh -2 -X user1@<IP of ubuntu computer> -P <port number of SSH server> <command to open the required application>



e.g.

plink -ssh -2 -X chinmaya@120.162.56.85  -P 23 gnome-calculator


Here, I am connecting to the Ubuntu computer through ssh protocol 2.
The IP address and SSH port number of Ubuntu computer is 120.162.56.85 and 23, respectively.
gnome-calculator is the command to open the GUI of calculator application.

After entering the above command, you need to give the corresponding password. If all goes well, the required GUI will appear on Wondows computer.

Please comment if you need more information or if you have any suggestion.

-Thank you



Friday, June 9, 2017

GitLab: For private Git repository

I assume here that the reader has basic knowledge about GitHub, BitBucket or SourceForge or some other alternatives to GitHub. Now, as a member of small research team, my responsibility is to setup something like GitHub in our own private server. The objective is to store and access individual's source code used for varification and evaluation of own research projects in a secure place. It's quite similar to GitHub.

For this requirement,I found GitLab as one of the best solutions. Installation of such software tool is a straight-forward procedure.

Installation Procedures:


Environment

In our physical server, NO other webserver is installed.
OS: Ubuntu 14.04, 64-bit Desktop version

Step-1:
Open the terminal by pressing Alt + Ctrl + T.

Step-2:
Enter the following command
sudo apt-get install curl openssh-server ca-certificates postfix
 
 This will install curl to get download the required packages, openssh-server for secure connection, postfix to setup mailing server and other essential packages.

Step-3: 
Now run the following commands donwload and install community edition of GitLab
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce

Pre-Final Step:
Reconfigure the gitlab-ce and start the GitLab server by running following command
sudo gitlab-ctl reconfigure

Final Step:
Once the server is ready, please open any web browser. Visit http://127.0.0.1 or http://localhost or http://<The IP of own server>
At first, enter the new password for the administrator. Once the password for the administrator is setup, other usernow can signup their account and enjoy own git repository.

For more information please visit GitLab official homepage.


-Thank you