Friday, 17 June 2016

ARM LPC2129 Mini Development Board – Overview

ARM LPC2129 Mini Development Board from RhydoLabz can be used to evaluate and demonstrate the capabilities of LPC2129(ARM7TDMI-S) microcontrollers. The board is designed for general  purpose applications and includes a variety of hardwares to exercise microcontroller peripherals.Ideally suitable for training and development purposes.
Key Features :
  • Compact and ready to use design
  • On Board 10 MHz Crystal Oscillator
  • Integrated ARM LPC2129 Microcontroller
  • Professional EMI/RFI Complaint PCB Layout Design for Noise Reduction 
  • High Quality Two layer PTH PCB 
  • Multiple programming options – USB/RS-232 with jumper selection at UART0
  • No separate programmer required (Built in Boot loader)
  • Power indication LED (Red)
  • Multiple Power source (USB, RMC Connector, DC barrel jack) with jumper selection
  • Power Supply with Reverse Polarity Protection
  • Controller Area Network (CAN) transceiver
  • CAN Controller (MCP 2551) interface
  • CAN connection taken from RMC connecter (+5V, CANH, CANL, GND)
  • Jumper selection at CAN RX & CAN TX 
  • Buzzer interface
  • Pot interface to ADC 
  • Temperature Sensor (MCP 9700) interface
  • For Buzzer,Temperature Sensor and Potentiometer jumper selection available, if necessary interface independently
  • Servo motor(SIG,+5V,GND), LCD & ZigBee can be easily interfaced through on-board connectors
  • Potentiometer for contrast control
  • ZigBee can be interfaced from either side of the board at UART0
  • 4 on-board switches including a RESET switch
  • 3 on-board SMD LED s connected to port pins
  • SMD LEDs and Switches , if necessary interface independently
  • Breadboard can be attached to the board
  • 5V and 3.3V regulators available
  • 3.3V/5V output available in berg strips
  • External power supply and adapter having range of 7 – 9V DC
  • In UART0 communication, position of programmer switch should be in manual mode
  • UART0 available at RMC connecter with jumper selection option for power i.e;  3.3V/5V 
  • UART1 available on berg strip (GND,TXD1,RXD1)
  • Two on board programming modes
    • Automatic  -  no reset, no ISP jumper
    • Manual      -  insert ISP jumper & press reset switch
  • ISP jumper should be removed for code execution
  • On Board JTAG Connector for Debugging/Programming
  • All port pins available at Berg Strip
LPC2129 Chip Specification :
  • 16/32-bit ARM7TDMI-S microcontroller in a 64 or 144 pin package
  • 16 kB on-chip Static RAM 
  • 128/256 kB on-chip Flash Program Memory 
  • 128-bit wide  interface/accelerator enables high speed 60 MHz operation
  • External 8, 16 or 32-bit bus (144 pin package only) 
  • In-System Programming (ISP) and In-Application Programming (IAP) via on-chip boot-loader software
  • Flash programming takes 1ms per 512 byte line.Single sector or full chip erase takes 400ms
  • EmbeddedICE-RT interface enables breakpoints and watch points
  • Interrupt service routines can continue to execute whilst the foreground task is debugged with the on-chip Real Monitor  software
  • Embedded Trace Macrocell enables non-intrusive high speed real-time tracing of instruction execution
  • 2/4 interconnected CAN interfaces with advanced acceptance filters
  • 4/8 channel 10-bit A/D converter with conversion time as low as 2.44 ms
  • Two 32-bit timers (with 4 capture and 4 compare channels)
  • PWM unit (6 outputs), Real Time Clock and Watchdog
  • Multiple serial interfaces including two UARTs (16C550), Fast I2C (400 kbits/s) and two SPIs™
  • 60 MHz maximum CPU clock available from programmable on-chip PLL
  • Vectored Interrupt Controller with configurable priorities and vector addresses
  • Up to forty-six (64 pin) and hundred-twelve (144 pin package) 5V tolerant general purpose I/O pins
  • Up to 12 independent external interrupt pins available (EIN and CAP functions)
  • On-chip crystal oscillator with an operating range of 1 MHz to 30 MHz
  • Two low power modes
    • Idle
    • Power-down
  • Processor wake-up from Power-down mode via external interrupt
  • Individual enable/disable of peripheral functions for power optimization
  • Dual power supply
    • CPU operating voltage range of 1.65V to 1.95V (1.8V +/- 8.3%)
    • I/O power supply range of 3.0V to 3.6V (3.3V +/- 10%)
The following figures illustrate the peripheral features of the board:
  • J7,J9 - To select programming source as serial port/USB port
  • SW5(Programmer switch) – To select auto/manual mode of programming
  • J15(ISP jumper) - To be shorted in manual mode of programming & should be removed for code execution
  • Power LED - Glows when the board is powered
  • K2(Power jumper) - To select power source as USB/DC source
  • J8(JTAG jumper) - Toenable 20 pin JTAG connector for debugging
  • LED - 3 x On-board SMD LED s
  • SWITCH - 3 x On-board switches
  • SW (RESET) - Reset switch
  • J1,J2,J3 – Jumpers connects LEDs to port pins P0.17, P0.18 & P0.19
  • J4,J5,J6 – Jumpers connects Switches to port pins P0.14, P0.15 & P0.16
  • J10 – Jumper connect Buzzer to P0.21
  • J11 – Connects Temperature Sensor to P0.28(AD0.1)
  • J12 – Connects Potentiometer to P0.29(AD0.2)
  • J13,J14 – Connects CAN TX , CAN RX to CAN Controller (MCP 2551)
  • J16 – Jumper for selecting 3.3/5 V level when using UART0 through K14
  • K12 – Connector for accessing UART1
  • K13 – Connector for interfacing Servo Motor at P1.24
  • K14 – Connector for accessing UART0
  • K15 – Connector for accessing CAN
  • LCD – 16 pin Berg strip connector for LCD
Layout
Powering     The board could be powered using 3 different ways
  • USB connector
  • DC Barrel Jack Connector
  • RMC Connector
The supply source can be selected as DC/USB using the jumper(K2). If DC source is selected, then either DC Barrel Jack or RMC connector can be used and the supply voltage should be in the range of 7-12 V.Once the board is powered, the power LED(red LED on the board) glows.
How to test ?Mini USB and Serial Cable can be used for programming ARM LPC2129 Mini Development Board. When USB cable is connected to the ARM LPC2129  board, Power LED(Red) on the top of mini development board glows, which shows the power indication.
Coding is done in Keil uVision4 IDE(Download). Basic steps after installation are mentioned below.
  • Step 1: Launch Keil uvision4
  • Step 2: The Keil uvision window opens as shown below
  • Step 3: To create a new project, select Project > New uVision Project from menu bar
  • Step 4: Save the project in a suitable location with appropriate name
  • Step 5: The following window opens. Select LPC 2129 (listed under NXP) from the drop-down list
  • Step 6: Click ‘Yes’ for the following question to copy and add the Startup code to Project
  • Step 7: This creates a target to the project
  • Step 8: Create a new file either by clicking the New File icon, or by selecting  File > New or using keyboard shortcutCTRL + N
  • Step 9: Save the file in any name, but with .c extension in the project folder
  • Step 10: Double click on “Startup.s” to open the configuration window and configure as below
  • Step 11: Set the options as shown below and save
    The PLL setup is done for 10MHz crystal. The divider and multiplier must be selected such that the PLL output is 30MHz((10/2)*6). If crystal frequency is changed, then these values must be changed accordingly
  • Step 12: Right click on Target1 to set target file options. You can also do this by using the icon on ‘Build toolbar’ or Project > Options for Target ‘Target 1′
  • Step 13: Configure TargetOutput and Linker options as shown below
    TargetOutputLinker
  • Step 14: Right click Source Group 1 to add C file to source
  • Step 15: Select the C file created and cilck Add
  • Step 16: Now the c file gets added to the Source
  • Step 17: Type the code
  • Step 18: Click the build icon (encircled in figure) to build the project. Errors (if any) get listed in the Build output window. Correct them and build again. On successful building, the hex file will be generated in the project folder
  • Step 19: Now the code can be flashed to the controller in the board,Note the following jumper connections
  1. Select the power source as USB cable or DC source
  2. Select USB or serial port using jumpers J7 & J9 for flashing the code
    Both jumpers on bottom side means USB programming
    Both jumpers on top side means RS232 serial programming
  3. Select mode using programmer switch
    In manual mode, insert ISP jumper and press reset button before programming
    In auto mode, leave it open and proceed to programming
Now power up the board. The power LED(red LED on the board) glows. Open Flash Utility. Select the correct COM port recognized by PC and if its more than COM5 change it to any any lower COM port in Device Manager and select any suitable baud rate. Also select XTAL Frequency as 10000kHz
  • Step 20: Open the desired hex file to be programmed
  • Step 21: Read device ID
    If auto mode is selected, simply clicking the ‘Read device ID’ button  will read the ID. But in manual mode, press reset switch and click
  • Step 22: Click ‘Upload to Flash’
After successfully flashing the code into the controller, remove ISP jumper if programmed using manual mode and reset the board. Also ensure that all the necessary jumpers to get the desired output are shorted.

Thursday, 16 June 2016

How to build a REST Web API on a Raspberry PI in JavaScript

One of the most useful reasons for providing your Raspberry Pi with a REST API is to expose its inputs and outputs to a web client (on any iPhone, laptop or desktop PC anywhere in the world) for remote monitoring and/or control. This is part 1 of a 2 part blog showing how to implement a REST API in JavaScript.

What’s REST ?

In recent years, the Web has turned from a network of webservers serving mainly static pages to web browsers…

Web 1.0 – How the Internet was
…into a full client-server architecture, where single-page client web apps use AJAX principles to communicate with server-side applications, increasingly via simple but powerful RESTful APIs.

The Web as a client-server application framework

REST, AJAX and JAVASCRIPT

With REST, the idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between clients and servers, simple HTTP queries are used. RESTful applications use HTTP requests to POST data (create and/or update data), GET data (make queries), and delete data on the server. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.
AJAX is a popular web development technique that makes web pages interactive using JavaScript. In AJAX, requests are sent to the server using XMLHttpRequest objects. The response is used by the JavaScript code to dynamically change the current page. Each XMLHttpRequest can be viewed as a REST service request, sent using GET. And the response is often in JSON format.
For example, if our client application wants to get the ISBN for a book the user knows the title of, we might send our API server an HTTP GET with the URL :
http://www.myapiserver.com/books/ISBN/Catch-22
Using jQuery we can implement this AJAX request in our client application simply like this:
$.getJSON("http://www.myapiserver.com/books/ISBN/Catch-22", function(data) {
  console.log("The ISBN for this book is "+data );
 });
The HTTP reply our server sends back to the client is the raw result data — not embedded inside an HTML page, not XML-encoded, just the data you need in a way you can immediately use – a String or a JSON object you can use directly.
With REST, a simple network connection is all you need. You can even test the API directly, by typing the API URL into your browser. For instance, try out the twitter API by enteringhttps://api.twitter.com/1/statuses/home_timeline.json?include_entities=true in your browser. Because you haven’t included a key in your request, you will see an authentication error response in the browser window, encoded as a JSON object, which looks something like this:
{"errors":[{"message":"Bad Authentication data","code":215}]}
As you may have noticed in these examples, REST can easily handle more complex requests, including multiple parameters. In most cases, you’ll just use HTTP GET parameters in the URL.
For example, if we can only uniquely specify a book by both title and author, our API might accept a request like this: “http://myapiserver/books/ISBN?title=Catch-22&author=Heller”
As a convention, HTTP GET requests should be for read-only queries; they should not change the state of the server and its data. For creation, updating, and deleting data, use POST requests.

REST on the Raspberry Pi

Nodejs_logo_lightI’ve been using Node.JS as the backend (server-side) framework for building single-page or client-server web apps and more recently as a Javascript platform on my Raspberry Pi. On top of providing the advantage of an asynchronous, event-based programming model, it means I can code in he same language – Javascript – on  the frontend and the backend and on the Pi.
The Raspberry Pi as a Web Application server
To install Node.JS on your Raspberry Pi, see my earlier Blog post HOW TO INSTALL NODE.JS ON A RASPBERRY PI 
On the Raspberry Pi, we need to use the Node Package Manager npm to download and install the other modules we will need to build our web application. We will be using the express web application framework module initially, and also the connect module it depends on.
On your RPi, create a new directory for your project, and download the node modules you’ll need as follows :
$ mkdir myapp
$ cd myapp
$ npm init
$ npm install express --save
$ npm install connect --save
Or use the -g flag if you prefer the package to be installed globally, i.e. in /usr/local where node is installed, rather than in./node_modules. To install global packages, you need to use sudo to execute with superuser priviledges.
The node package manager will download and install the express framework.

Coding a RESTful API example on the Raspberry Pi

We’re now going to build an example client-server application using our Raspberry Pi as the server.
To build this full REST example, we need to create three source files on our Raspberry Pi: The server-side Javascript code, a simple HTML page, and some client-side Javascript.
myapi.js – our server-side Javascript code uses the Node and the Express framework to provide simplistic Web server functionality and to expose a RESTful API.
index.html – the HTML page which the browser loads from the Raspberry Pi and uses to render the presentation layer for our application.
myclient.js – Javascript code executed in the browser when our HTML page loads. This code implements the AJAX client functionality to call our API and render the results directly in the HTML page.
The application architecture looks like this:
Our Example – using Raspberry Pi as an App Server

MYAPI.JS: The Server(RPi)-side code

Now create a file called myapi.js on your Pi and copy the code below to build a simple  server in Javascript, which processes API requests on port 3000 with a JSON object. (Port 3000 is the standard port most commonly used for an express server).
First we need to let Node know we will be using the http and expresspackages,  call express to create our application server as an object, and assign it to a variable.
var http = require('http');
var express = require('express');

var app = express();
Next we will define an array of objects the client will be able to query….
var inputs = [{ pin: '11', gpio: '17', value: 1 },
              { pin: '12', gpio: '18', value: 0 }];
Then configure Express to serve index.html and any other static pages stored in the home directory, such as your myclient.js JavaScript source file
  app.use(express['static'](__dirname ));
Next we need to define the API middleware for our server-side application. We use express’s get function to define routes for the API calls and/or page requests to our server.
// Express route for incoming requests for a customer name
app.get('/inputs/:id', function(req, res) {
  res.status(200).send(inputs[req.params.id]);
}); 

// Express route for any other unrecognised incoming requests
app.get('*', function(req, res) {
  res.status(404).send('Unrecognised API call');
});

// Express route to handle errors
app.use(function(err, req, res, next) {
  if (req.xhr) {
    res.status(500).send('Oops, Something went wrong!');
  } else {
    next(err);
  }
});
Finally, start the server application, listening on port 3000:
app.listen(3000);
console.log('App Server running at port 3000');

INDEX.HTML: the homepage

Our web page simply displays a title, and sets up an input div as a placeholder that will be used by our  client-side JavaScript code in myclient.js to display the I/O values retrieved from our RPi.
<!DOCTYPE html>
<html lang="en">
 <head>
   <meta charset="utf-8" />
   <title>My Express API server example</title>
   <script src="http://code.jquery.com/jquery-latest.js"></script> 
   <script src="myclient.js"></script>
 </head>
 <body>
   <H1>My Express API server example</H1>
   <div id="input"></div>
 </body>
</html>

MYCLIENT.JS: the client-side code

this JavaScript code will be loaded and executed on the client machine when the browser loads our HTML page. It makes 2 calls to our API server running on the Raspberry Pi to retrieve and display the state of two inputs.
window.onload = function () {
  var url, 
      i,
      jqxhr;

  for (i = 0; i < 2; i++) {
    url = document.URL + 'inputs/' + i;
    jqxhr = $.getJSON(url, function(data) {
      console.log('API response received');
      $('#input').append('<p>input gpio port ' + data['gpio'] + ' on pin ' +
        data['pin'] + ' has current value ' + data['value'] + '</p>');
    });
  }
};

Download the Source Code

You can also download the full source code (client, server and html) for this example from github herehttps://github.com/fatkahawai/rpi-webapp-express
Create or download the three source files into a new folder on your RPi.

Running your Raspberry Pi Web App Server

To start up your web server on your RPi , invoke your application with node, from the folder you have saved the source files in.
$ node myapi.js
App Server running at port 3000
$
(Making sure that you have first installed the express module using npm, as already described above.)
Your web server is now running continuously in the background, waiting for API calls.
Finally, using another machine on the same local network, open a web browser and navigate to your App Server hosted on the RPi.
If your RPi has the local IP address 192.168.0.22, you would enter this in your browser:
http://192.168.0.22:3000
This will cause the browser to load your index.html file from your RPi, which then loads your javascript client code in myclient.js.
If you’re in luck, this should appear in your browser window:

What’s Next ?

One of the most useful reasons for providing your Raspberry Pi with a RESTful API is to expose its input and output ports to web clients for remote monitoring and control.
So in our next exercise, we will do just this, exposing the real GPIO I/O ports through a RESTful API, which will allow you to control your Pi’s inputs and outputs from any smartphone or PC wherever you are in the world.
I hope this exercise has been useful. If you have any feedback or spot any errors or omissions, feel free to leave a note in the comments section below.

Thursday, 9 June 2016

Enable SSH root login on Debian Linux Server

After fresh system installation the root login on the Debian Linux is disabled by default. When you attempt to login as root user to your Debian Jessie Linux server the access will be denied eg.:
$ ssh root@10.1.1.12
root@10.1.1.12's password: 
Permission denied, please try again.
root@10.1.1.12's password: 
Permission denied, please try again.
root@10.1.1.12's password: 
Permission denied (publickey,password).
To enable SSH login for a root user on Debian Linux system you need to first configure SSH server. Open /etc/ssh/sshd_config and change the following line:
FROM:
PermitRootLogin without-password
TO:
PermitRootLogin yes
Once you made the above change restart your SSH server:
# /etc/init.d/ssh restart
[ ok ] Restarting ssh (via systemctl): ssh.service.
From now on you will be able to ssh login as a root:
$ ssh root@10.1.1.12
root@10.1.1.12's password: 

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
The following guide will provide you with the information on how to enable SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server/Desktop.

The following config will guide you through the process of enabling SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server or Desktop. This guide assumes that you are in possession of root password and are able to login directly on your system as root user. Use the following guide, if you do not have a root's user password.

By default the root's ssh remote shell access is denied by default. Any attempt to remote login as root will result in Permission deniedmessage:
$ ssh root@10.0.0.55
root@10.0.0.55's password: 
Permission denied, please try again.
root@10.0.0.55's password:
In order to enable root ssh login on Ubuntu 16.04 Xenial Xerus Linux run the following command:
$ sudo sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config
or manually open sshd configuration file /etc/ssh/sshd_config and change line:
FROM:
PermitRootLogin prohibit-password
TO:
PermitRootLogin yes
Once you have made the above configuration change restart ssh daemon:
$ sudo systemctl restart sshd
After you restart sshd daemon you will be able to remotely login as a root user:
$ ssh root@10.0.0.55
root@10.0.0.55's password: 
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

22 packages can be updated.
20 updates are security updates.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Howto mount USB drive in Linux

1. Example

2. Detecting USB hard drive

After you plug in your USB device to your USB port, linux will add new block device into /dev/ directory. At this stage you are not able to use this device as the USB filesystem needs to be mouted before you are able to retrieve any data. To find out what name your block device file have you can run fdisk command:
# fdisk -l 
You will get output similar to this:
Disk /dev/sdb: 60.0 GB, 60060155904 bytes
255 heads, 63 sectors/track, 7301 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000b2b03

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        7301    58645251    b  W95 FAT32

3. Creating mount point

Create directory where you want to mount your device:
mkdir /mnt/sdb1 

4. Edit /etc/fstab

To automate this process you can edit /etc/fstab file and add line similar to this:
/dev/sdb1       /mnt/sdb1           vfat    defaults        0       0 
Run mount command to mount all not yet mounted devices. Keep in mind that if you have more different USB devices in you system, device name can vary!!!
# mount -a 

Monday, 6 June 2016

Top 15 Linux virtualization interview questions and answers

Linux virtualization is the process of running one or more virtual machines on a physical computer, that is operated by the open source Linux operating system. Linux virtualization is used for creating virtual resources such as Operating system, server, network and storage device. It can be used for programming code, isolating specific apps, performance testing and security purposes.
The powerful hardware and computers made virtualization more practical for both server and desktop environments, helping to save power by combining several workspaces on one system and extending the workload that the computer can handle. The popular Linux virtualization solutions include QEMU, VMware, KVM, Xen and Virtual Box.
linux 15 image

1.What are the different types of Virtualization?
The Virtualization can be used in different ways and various forms of virtualization are shown below:
  • Hardware virtualization
  • Server virtualization
  • Application virtualization
  • User virtualization
  • Network virtualization
  • Desktop virtualization
2.What are the types of Hardware virtualization?
The Hardware virtualization is categorized into two categories:
Full virtualization:
In order to run unmodified Partial virtualization, almost a complete simulation of the actual hardware is done to allow the software, which consists of a guest operating system.The Only few target environment is simulated. Thus,modification is needed for some programs to run in this virtual environment.
Para virtualization:
Here the hardware environment is not simulated, the guest programs are executed in their own isolated domains, like if they are running on a separate system. To run in this environment, the guest programs are required to be modified specifically.
3.What are the benefits of virtualization?
Virtualization is used for the creation of virtual machines and to manage them. It allows to share the resources with large amount  of network resources. It contains lots of benefits and they are as follows:
  • It does not depend on heavy hardware to run the application.
  • It reduces the amount of space taken by both company data and data centers.
  • It saves the amount of cost and helps to maintain easily.
  • It combines the servers that are used for crashing.
  • It offers multiple operating system run on one virtualization platform.
4.What is QEMU?
The QEMU is an open source and generic machine Virtualizer and emulator. It can achieve very  good performance by using dynamic translation. The QEMU has the ability to run programs and OS that is made for one machine on a different machine, when used as a machine emulator.
5.What is KVM?
The KVM stands for Kernel Virtual Machine is a Linux Kernel module that provides a user space program to use the features of hardware virtualization of different processors.
6.What is virtual Machine Cloning?
The Virtual Machine Cloning is a process of creating a copy of an existing virtual machine with the same installed software and configuration as the original. The current virtual machine is known as the parent of the clone. After the completion of cloning operation, the clone becomes a separate virtual machine.
7.What are the types of cloning in virtualization?
A linked clone is a copy of a virtual machine, which shares the virtual disk with the parent virtual machine in a constant manner. This will occupy the space of the disk and provides multiple virtual machines to use the same installation of software.
A full clone does not depend on the copy of a virtual machine and after the cloning operation, shares nothing with the parent virtual machine. The operation of the full clone is entirely different from the parent virtual machine.
8.What is memory virtualization?
The memory virtualization aggregates the resources of the RAM from the networked systems into a single memory pool.
9.What is Storage virtualization?
The Storage virtualization is the method of extracting a logical storage from physical storage. A computer program,Virtual disk drive follows an optical disk drive or a hard disk drive in virtualized setup.
10.Define snapshot of a virtual machine?
The snapshot is the state of a virtual machine. Snapshots are taken just by giving order to be performed at a given time and can be returned on demand. With the conclusion that the VM appears exactly same, when the snapshot  was taken. It is used as a rapid backup method.
11.What is the purpose of a Hypervisor?
The program that manages the virtual machine is known as Hypervisor. It provides multiple operating system to share a single hardware host. It also acts as a virtual machine manager, which manages many virtual machines. In this, each operating system has its own defined place, that consist of memory, processor and space. It helps to separate the layers between many operating systems, so that no one can get clash with one another. It is used as a controller program to control resources and host processors.
12.What are the different hypervisors available in Linux?
KVM and Xen are the two different hypervisors available in Linux.
13.What is the difference between KVM and Xen?
The KVM is the kernel based virtualization, so extra kernel is not required for this. It is a module In kernel and supports full virtualization. Whereas, for Xen hypervisor, first the Xen kernel has to be installed and have to enhance the machine with Xen kernel, it does not support full virtualization by default.
14.What is the use of virsh command?
The virsh command is used for managing the virtual machines depending upon Xen and KVM hypervisor. The virtual machines are identified by their domain names, on virsh interface. Hence Virsh is used to pause, create, list and shut down current domains
15.How to identify the KVM version?
The ‘virsh version’ command is used to find the KVM version.

Saturday, 4 June 2016

Potential Security Threats To Your Computer Systems


A computer system threat is anything that leads to loss or corruption of data or physical damage to the hardware and/or infrastructure. Knowing how to identify security threats is the first step in protecting computer systems. The threats could be intentional, accidental or caused by natural disasters.
In this article, we will introduce you to the common computer system threats and how you can protect systems against them.

Topics covered in this tutorial

  • What is a threat?
  • What are Physical Threats?
  • What are Non-physical Threats?

What is threat ?

The ISO 27005 defines a threat asa potential cause of an incident that may result in harm of systems and organization. The cause could be physical such as someone stealing a computer that contains vital data. The cause could also be non-physical such as a virus attack. In these tutorial series, we will define a threat as a potential attack from a hacker that can allow them to gain unauthorized access to a computer system.

What are Physical Threats?

A physical threat is a potential cause of an incident that may result in loss or physical damage of the computer systems.
The following list classifies the physical threats into three (3) main categories;
  • Internal: The threats include fire, unstable power supply, humidity in the rooms housing the hardware etc.
  • External: These threats include lightening, floods, earthquakes etc.
  • Human: These threats include theft, vandalism of the infrastructure and/or hardware, disruption, accidental or intentional errors.
To protect computer systems from the above mentioned physical threats, an organization must have physical security control measures.
The following list shows some of the possible measures that can be taken:
  • Internal: Fire threats could be prevented by the use of automatic fire detectors and extinguishers that do not use water to put out fire. Unstable power supply can be prevented by the use of voltage controllers. An air conditioner can be used to control the humidity in the computer room.
  • External: Lightening protection systems can be used to protect computer systems against such attacks. Lightening protection systems are not 100% perfect, but to a certain extent, they reduce the chances of lightening causing damage. Housing computer systems in high lands is one of the possible ways of protecting systems against floods.
  • Humans: Threats such as theft can be prevented by use of locked doors and restricted access to computer rooms.

What are Non-physical threats?

A non-physical threat is a potential cause of an incident that may result in;
  • Loss or corruption of system data
  • Disrupt business operations that rely on computer systems
  • Loss of sensitive information
  • Illegal monitoring of activities on computer systems
  • Others
The non-physical threats are also known as logical threats. The following list is the common types of non-physical threats;
  • Virus
  • Trojans
  • Worms
  • Spyware
  • Key loggers
  • Adware
  • Denial of Service Attacks
  • Distributed Denial of Service Attacks
  • Un-authorized access to computer systems resources such as data
  • Phishing
To protect computer systems from the above mentioned threats, an organization must have logical security measures in place. The following list shows some of the possible measures that can be taken
To protect against viruses, Trojans, worms etc, an organization can use anti-virus software. In additional to the anti-virus software, an organization can also have control measures on the usage of external storage devices and visiting website that are most likely to download unauthorized programs onto the user’s computer.
Unauthorized access to computer system resources can be prevented by the use of authentication methods. The authentication methods can be, in form of user ids and strong passwords, smart cards or biometric etc.
Intrusion-detection/prevention systems can be used to protect against denial of service attacks.There are other measures too that can be put in place to avoid denial of service attacks.

Summary

  • A threat is any activity that can lead to data loss/corruption through to disruption of normal business operations.
  • There are physical and non-physical threats
  • Physical threats cause damage to computer systems hardware and infrastructure. Examples include theft, vandalism through to natural disasters.
  • Non-physical threats target the software and data on the computer systems.

Friday, 3 June 2016

How to set up Cron Job on Amazon EC2 Cloud Servers


How to set up Cron Job on Amazon EC2 Cloud Servers

I am writing this blog because I faced issue for adding cron jobs in Amazon Ec2 cloud server. I was using Linux 64bit .
To add cron jobs open command prompt (via putty if windows) and login via ssh, when you are login then type:
  1. which php
this will return: /usr/bin/php
keeping response in mind from above, now type:
  1. #!/usr/bin/php -q
-q parameter is passed so that whenever cron job runs, you will not get email.
now type command:
  1. crontab -e
then use vim editor to add the following lines to crontab to run your php script every minute:
  1. * * * * * /usr/bin/php /home/ec2-user/cron.php
Start a php file named cron.php and enter the following contents:
  1. ----------------------code----------------------------
  2. #!/usr/bin/php -q
  3. <?php
  4. //script to test cron on adam's cloud server:
  5. $message = "If ur reading this then the cron job worked!!!!nn";
  6. $myFile = "testFile.txt";
  7. $fh = fopen($myFile, 'w') or die("can't open file");
  8. fwrite($fh, $message);
  9. $stringData = "Yay for cloud cron! script was home/ec2-user/cron.php";
  10. fwrite($fh, $stringData);
  11. fclose($fh);
  12. ?>
  13. --------------------------------------------------------
Now also create file testFile.txt and leave it blank. Also give this file valid permissions to write. When the cron will run, it will going to write the file.
All done!
Thanks for reading the blog.
- See more at: http://findnerd.com/list/view/How-to-set-up-Cron-Job-on-Amazon-EC2-Cloud-Servers/17285/#sthash.aVYOFIzR.dpuf