How to overcome death is explained in the Mahabharata by Sanatkumara to Dhritarashtra and is famous as Sanatsujatiya.
Seers say that ignorance or delusion and death have existed from the very beginning. I tell you forgetfulness of our true nature is death and constant mindfulness, immortality.
It is on account of their forgetfulness of true nature that the asuras were defeated. The Devas became Brahman by being mindful of their true nature.
Death comes out of the egos of men in the form of anger, ignorance and delusion.
Following evil ways, as human beings generally do, under the impulse of the ego, hardly anyone attains union with the Self.
Being deluded and under the sway of ego human beings repeatedly die and take birth.
Actions produces attachment to the fruits of action. And those who are enamored of the results of action on earth never transcend death. Not knowing how to attain liberation or union with Reality, these souls work purely for the sake of sense enjoyments.
This working for sense enjoyments is the delusion of the sense organs which makes one perpetually attached to unreal objects. And one who is unable to overcome attachment to unreal objects always thinks of them and is devoted to them.
A man is first overpowered by hankering after sense enjoyments. Desire and anger possess him next. These lead foolish men to death. But men of discrimination transcend death.
He who discriminates deeply and rejects these transitory pleasures, treating them with contempt and never giving a thought to them, becomes as it were, a slayer of death. A wise man overcomes his desires in this manner.
He who submits to his desires perishes along with them. But he who turns his back on them expiates his sins, if any.
This inert body is a hell for all beings. Those who are enamored of it and pamper it are like the blind who walk into places full of pits, thorns, etc.
Human beings do not attain real knowledge as result they have become worthless like a tiger made of straw. Deluded and terrified by anger and green one experiences death in one’s own body many times.
One who knows thus the origin of death and is established in wisdom does not fear death. He annihilates death even as death annihilates one who is in its grip.