Following are the commands which I used to upgrade my mongodb version from 2.6.9 to latest, but its still showing me the previous version. Let me know what I am doing wrong
[Disclaimer] Before going into upgrade consider that moving from 2.6 to 3.+ requires an update on storage files. Same if you are updating from 3.2 to 3.4 or 3.4 to 3.6. Important: You can't directly upgrade from 3.2 to 3.6, for example. You must upgrade "step by step" 3.2-->3.4-->3.6. See this question/answer for details.
This is necessary if you want to recover your old DBs
As of writing 3.6 is the latest version of MongoDB. Some details here
Beware that changing between versions also regards some syntax in .conf file.
[Procedure] A more general framework for updating is to follow the typical procedure as shown here, but point to "Install a specific release of MongoDB" part of this guide as you already have MongoDB installed.
An example on Ubuntu 14.04:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org=3.2.18 mongodb-org-server=3.2.18 mongodb-org-shell=3.2.18 mongodb-org-mongos=3.2.18 mongodb-org-tools=3.2.18