What is X window system in linux ? How it is relatable to GNOME and KDE GUI enviornment ? I mean what is the relation between them ? Is X window system and GNOME are same or what ?
The XWindows system is the base graphic support in Unix systems. It draws things on the screen, and forwards keyboard and mouse actions to applications. It works as a client/server, where the application on the system is the client, and the thing that displays it is the server (a long time ago, people shared Unix systems and the servers were dedicated terminal on users desks known as X-terminals). Of course on a Linux desktop the client and the server are on the same machine.
In practice X is rarely used bare, it is mostly used through libraries, the two most used being GTK and Qt. GTK and Qt apps can coexist.
Gnome and KDE are Desktop managers, they start applications, maintain a status bar, etc... Gnome is GTK-based, KDE is Qt-based.