By
Tells you who did something.
Use:


The Mona Lisa was painted by Leonardo da Vinci.
The account was opened by Mr. Stephen Francis.
This bread was baked by my sister.
Hamlet was written by Shakespeare.
'By' is used to say who did an action, often in the passive voice or a piece of art (painting or writing).
Telling someone the way to do something
Use:


You can cut onions properly by using a sharp knife.
Call me by my first name.
The best way to practice English is by speaking.
I fall asleep by listening to soft music.
The result of the action (cut onions properly, practice English) is achieves 'by' doing something (using a sharp knife, speaking).
Result of action + by + what you do to achieve it
Saying the margin or size of something
Use:
He missed the goal by inches.
The putt was off by a few centimetres.
I was late for work by minutes.
I charge by the hour.
We use 'by' to indicate the size of margin (by inches) or the frequency of time (by the hour).
Use:
Use: