In order to un-install ROS completely from system the following command can be used
sudo apt-get remove ros-*or if you need to remove specific version then Like for electricsudo apt-get remove ros-electric-*
You have to edit .bashrc to remove all the calls or variables set in there for ROS, Remove any setup scripts also delete the workspaces created when working with ROS.
If there is some unused dependecies left then the following can be used
sudo apt-get autoremove