Finding all homomorphisms between two groups - couple of questions

Consider $\mathbb{Z}_{15}$, and $\mathbb{Z}_{18}$.
Let's say I want to find all homomorphisms $f:\mathbb{Z}_{15}\rightarrow \mathbb{Z}_{18}$.

I'm not interested in the answer in particular, mostly I'm concerned about understanding the properties of homomorphism, so I can answer these kind of questions myself.

So, first of all, I know that homomorphism of cyclic group is completely determined by it's generator.
But, will any mapping do?

For example, the easiest one to find is $f(1)=0$, where $Imf=\left\{0\right\}$, and $Ker=G$ (correct me if I'm wrong, this kind of $f$ can be defined between any two groups).
Now, what things do I need to consider, when trying to find another one (if it exist)?
Can I decide that $f(1)=1$? (It is not onto, but that shouldn't bother me)
And what about $f(1)=2$? and so on...

My second question is: what about non-cyclic groups?
Consider $D_{10}$ and $\mathbb{Z}_{18}$, for example.
Do I need to go and define $f$ for each and every $g\in D_{10}$? (it doesn't have a generator)

A link to a useful (and simple) summary regarding homomorphisms properties will also be great.
Thank you in advance.


For these groups it's best to think of then in terms of generators and relations. The group $\mathbb Z_n$ has generator $1$ and is subject to one relation: $n\cdot 1 = 0$.

To map out of a group which is presented as generators and relations you need only choose images for the generators which satisfy the same relations. Thus every homomorphism $\mathbb Z_{15} \to \mathbb Z_{18}$ is defined by sending $1 \in \mathbb Z_{15}$ to an $m \in \mathbb Z_{18}$ which satisfies $15\cdot m = 0$ in $\mathbb Z_{18}$.

If $15m = 0$ modulo $18$ then $3m = 0$ modulo $18$ so $m = 0$ modulo $6$. Hence you can send $1$ to either $0$, $6$, or $12$. This means there are exactly three homomorphisms $\mathbb Z_{15} \to \mathbb Z_{18}$.

For non-cyclic finite groups the generators and relations approach still works. For example $D_n$ has two generators, $\rho$ and $\tau$, and three relations: $$\rho^n = 1 \qquad \tau^2 = 1 \qquad \rho\tau = \tau\rho^{-1}$$ So homomorphisms out of $D_n$ are specified by choosing two elements (the images of $\rho$ and $\tau$) which satisfy these relations.

Obviously as the groups get bigger figuring out how they are presented as generators and relations gets much harder as does figuring out which sets of elements in the target group satisfy those relations. But still I think it's the best "general" approach.