Linux Filesystem colour codes

When we fire ls –all in linux cli, files may be listed in different colours  

The color code of the files is as follows:

Blue: Directory file

White: Normal file

Green: Executable file

Yellow: Device file

Magenta: Picture file

Cyan: link file

Red: Compressed file

File Symbol

-(Hyphen) = Normal file


l=link file

b=Block device file

c=character device file

Recovery of deleted files in Hadoop

There may be incidents which we accidently delete necessary files from hadoop. Sometimes the entire file system may get deleted. For doing recovery process the below steps may help you.

For doing this recovery method  trash should be enabled in hdfs. Trash can be enabled by setting the property  fs.trash.interval greater than 0. By default the value is zero.  Its value is number of minutes after which the checkpoint gets deleted. If zero, the trash feature is disabled. We have to set this property in core-site.xml.

  <description>Number of minutes after which the checkpoint
  gets deleted.
  If zero, the trash feature is disabled.

There is one more property which is having relation with the above property called fs.trash.checkpoint.interval. It is the number of minutes between trash checkpoints. This should be smaller or equal to  fs.trash.interval. Everytime the checkpointer runs, it creates a new checkpoint out of current and removes checkpoints created more than fs.trash.interval minutes ago.The default value of this property is zero.

  <description>Number of minutes between trash checkpoints.
  Should be smaller or equal to fs.trash.interval.
  Every time the checkpointer runs it creates a new checkpoint 
  out of current and removes checkpoints created more than 
  fs.trash.interval minutes ago.

If the above properties are enabled in your cluster. Then the deleted files will be present in .Trash directory of hdfs. You have time to recover the files until the next checkpoint occurs. After the new checkpoint the deleted files will not be present in the .Trash. So recover before the new checkpoint. If this property is not enabled in your cluster,  you can enable this for future recovery.. 🙂

Changing the Default GUI boot mode of Ubuntu

If you want to change the default GUI mode  boot of ubuntu machine, just do the following changes. Here actually we are not removing the GUI, just changing the default booting as text mode. By doing this you can reduce the memory consumption.

Open the terminal as root user or sudo user.

open /etc/default/grub as and add text to the

sudo nano /etc/default/grub

And in the file, change this line:


Then update your Grub

sudo update-grub

To view the changes, reboot the system. Then the system will always boot in text mode. This is applicable to Ubuntu OS only.

If you want to get the UI without changing the configuration from text mode, execute startx command in the terminal. Then the UI will be loaded.

A Simple Multithreaded Program in Java

Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

Here I am explaining a simple multi-threaded program.

The main thread writes 5000 to 1 in a file named MainThread.txt and the child thread writes 1 to 5000 in a file named childthread.txt.
Both will happen at the same time. That is it will run in parallel.

We are creating a child thread class by implementing a method Runnable.

This class will contain a method named run() where we do our functionality.

We will instantiate this thread class in the main method, so it will run along with the main thread.

The child thread class is

package com.amal.thread;

public class ThreadTest implements Runnable {
	Thread t;
		t=new Thread(this,"My Test");
		System.out.println("My test thread");

	public void run() {
		File file=new File("childthread.txt");

		try {

			FileWriter fwt = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bwt = new BufferedWriter(fwt);

			for(int i=0; i<5000; i++)
				bwt.write("thread "+i);
		} catch (IOException e) {

The main class is

package com.amal.thread;

public class MainClass {
	public static void main(String[] args) throws IOException {
		new ThreadTest();
		File file1=new File("MainThread.txt");
		FileWriter fw = new FileWriter(file1.getAbsoluteFile());
		BufferedWriter bw = new BufferedWriter(fw);

		for (int i=5000;i>1;i--)
			bw.write("main "+i);

Making Custom Auto completion mechanism for Pig

One handy feature of pig’s Grunt shell is completion mechanism, which will try to complete

Pig Latin keywords and functions when you press the Tab key. For example, consider

the following incomplete line:

grunt> a = foreach b ge

If you press the Tab key at this point, ge will expand to generate, a Pig Latin keyword:

grunt> a = foreach b generate

We can customize the completion tokens by putting our necessary tokens in a file named autocomplete and put it in the pig class path or in the directory where we are invoking the grunt shell

For example: I created a file named autocomplete which contains the tokens







Then after saving this if u press the corresponding alphabet and press tab, it will display the choices for autocompletion.

Note: The tokens that I mentioned above is not related to pig commands or funtions. It is just for an example only. Like this you can create your own custom scripts or tokens for making the scripting handy

Accessing Unix Server through Putty using Private Key

Type hostname or ipaddress


Then in the left side part of putty, click on SSH and expand.


Then you can see a section auth

Click on auth


There you will get a window with browse button.


Load your private key file (.ppk) and press open.

Then enter username and passphrase-key (if given) and login

This is the method we usually use to login to unix  cloud instances .