Difference between virtual, resident and shared memory?

Virtual Memory (VIRT) is the full size of all memory the process is using, whether in RAM or on disk (shared objects, mmaped files, swap area) so VIRT is always larger or equal to RES. A process is always dealing with (i.e. allocating / accessing / freeing) virtual memory. It is up to the operating system to map some or all of these pages to RAM.

Resident Memory (RES) is the amount of RAM currently used by the process. This value can vary because memory pages might be swapped in or out. It might even be 0 for a process that has been sleeping for a long time. Example: an unsolicited daemon.

Shared Memory (SHR) is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between programs.

top or htop command can be used to monitor these memory

htop is an interactive and real time process monitoring application for Linux which will show you your usage per cpu/core as well as a meaningful text graph of your memory and swap usage. Once installed (with sudo apt-get install htop), just type htop at a terminal to launch it.