The passwords are not stored anywhere on the system at all. What is stored in
/etc/shadow are so called hashes of the passwords.
A hash of some text is created by performing a so called one way function on the text (password), thus creating a string to check against. By design it is "impossible" (computationally infeasible) to reverse that process.
What can be done is to try a "brute force" attack - by hashing a lot of possible passwords until the outcome equals the found hash. There is no other way, you cannot compute a text (=password) that matches the hash you have.
There are several algorithms to create hashes, they differ in complexity, length of the hash, probability/possibility of so called collisions (two different texts have the same hash, which eventually must happen if the hash is shorter than the original text).
Typical current algorithms are
- SHA-1 (also called SHA)
both should not be used for cryptographic/security purposes any more!!
- SHA-3 (KECCAK was announced the winner in the competition for a new federal approved hash algorithm in October 2012) - not used in Ubuntu yet.