Christopher Patricks, of no fixed abode, was under investigation after the incident on October 11 last year, just before 5pm.
Inner London Crown Court heard how the 41-year-old began to hit the victim with his bag while on the westbound Circle line train towards Paddington.
Patricks grew more aggressive towards the victim, demanding he move back and saying he wouldn’t let him off at the next stop.
As the train arrived at Victoria, both the victim and Patricks got off the train and the verbal assault continued, with Patricks racially abusing him.
He then followed the victim and shoulder-barged him from behind and then punched in the chest and face.
Patricks took his rucksack off and pulled out a knife, saying he would kill the victim.
He then thrusted the knife towards the victims chest twice, who used his arms to attempt to block the knife, with Patricks repeatedly saying that he was going to kill him.
The court heard that Patricks fled the scene, while the victim was treated at the scene by an off-duty officer before medics took him to hospital.
Police investigated Patricks’ normal route and arrested him at St James Park station on October 14.
He pleaded guilty to racially aggravated GBH and wounding with intent at an earlier hearing and was sentenced on July 23 to 51 months imprisonment.
Detective Chief Inspector Thanh Ly said: “This was an exceptionally savage and random attack which saw a man nearly lose his life, so I am so I am extremely pleased to see Patricks put behind bars for his volatile actions.
“There is absolutely no place for violent or abusive behaviour on the railway network, especially that which is motivated by hate, and we will continue to bring offenders for justice.”