A tenancy agreement is contract between the tenant/ lodger and landlord, either written or oral. The agreement gives you and your landlord certain rights and will differ whether your landlord lives in the property or out.
Assured Shorthold Tenancies (ASTs) are the most common form of rental in the UK when the landlord doesn't live in the property - it's the default agreement if you don't specify another type when letting your property. An AST allows the landlord or tenant to end the tenancy after an initial six month period, by giving notice to quit. It's a legal requirement for all deposits taken by landlords using ASTs be protected by a tenancy deposit scheme.
You'll probably have one of two types of AST if you're sharing:
If youre renting a room in a property where your landlord lives, youre a lodger. Lodging is a form of license rather than a tenancy - this is basically to protect the landlord as it's their home you're living in. Most live in landlords will still expect you to sign an agreement of some sort - this is standard procedure and protects you as well as them.
The main thing to be aware of if you're renting as a lodger is that there's no requirement for your landlord to protect your deposit in a tenancy deposit scheme (although they can, and probably will, still expect a deposit from you).
These are less formal than tenancy agreements but can still be a useful piece of paperwork if you're sharing with a group. Essentially, they are an agreed upon set of terms between the people living in a property. They can cover basics (such as who's paying what share of the rent) or include more detail (like whose responsibility it is to find a new flatmate if someone wants to move out). Not everyone has, or needs, an inter-sharer agreement but they can be useful if there are a few things you've agreed on and you want a copy in writing.
Some contracts include what's known as 'joint and several' liability. This means that, if one of your flatmates stops paying the rent or leaves before the end of the contract, the rest of you will be liable for their share of the rent. Not all contracts include this but it's worth checking the paperwork before you sign anything so you know what you're getting into.