Abarim Publications' online Biblical Hebrew Dictionary
There are two Hebrew words of the form שם (shm), and they have nothing to do with each other:
The noun שם (shem) means name. It's not certain where this noun comes from. In other words, we don't precisely know what exactly a name meant to the Hebrews, or what it means in the Bible.
It's been proposed that our noun has something to do with an Arabic verb meaning to mark or brand; a name would be one's 'verbal' mark. Perhaps this is true but it's not very satisfying; names in the Bible are far more than abstract marks.
Another possibility is a relationship with the root שמה (shmh), from whence comes the word שמים (shamayim), the Bible's common word for (the) heaven(s); which is either the natural sky, or the mental sphere and also the abode of God. Etymologically, the relation between שמה (shmh) and שם (shem) may be hard to establish, but poetically spoken, the relationship is clear and well defendable.
In the Bible, names are applied to rivers (Genesis 2:11), animals (Genesis 2:19, although no animal exists in the Bible with a personal name), cities (Genesis 4:17), humans, and God.
A name may be passed on to mark ownership or another strong relation (2 Samuel 12:28). It may change to signify an intense experience or mission (Genesis 17:5, 32:28). It may be carried to somewhere as an emissary of the owner of the name (1 Samuel 25:5).
One may become noted by making a name for oneself (Genesis 11:4), and God promises a name to the outcast (Zephaniah 3:19). One may be defamed and thus become a proverbial name (Ezekiel 23:10). And one's legal children may preserve or form one's name (Deuteronomy 25:6).
As is specifically demonstrated by the Name of God: a name to the Hebrews reflected character, personage and perhaps even certain events and deeds (Exodus 3:15, Isaiah 52:6, Jeremiah 33:2, Amos 5:8).
The adverb שם (sham) means here. Preceded by the relative particle אשר (asher) it forms the meaning of where. After verbs of motion it means thither. It occurs preceded by the definite article ה (he) in the meaning of there. In conjunction with the preposition מן (min) it forms משם (meshem), which means from there.
These expressions of locality may also be applied to temporal contexts: then, when, etcetera.