Hint $\rm\ mod\ 7\!:\ 5 \equiv -2\ \Rightarrow\ \dfrac{1}{5}\,\equiv\, -\dfrac{1}2\,\equiv\, 3,\ $ since $\rm\:mod\ 2n\!+\!1\!:\,\ 2n\,\equiv\, -1\ \Rightarrow\ n\,\equiv\, -\dfrac{1}2$
Remark $\ $ Generally one can employ the Extended Euclidean Algorithm to efficiently compute modular inverses. The above computation is an optimization for the frequent special case where the modulus is $\equiv \pm1\:$ modulo the number being inverted ($= 2$ above), hence the algorithm terminates in a single step. Euler's phi theorem is not a computationally efficient method to compute inverses for large moduli (but it is useful for theoretical purposes, such as deducing the existence of inverses for elements coprime to the modulus, as well as for other purposes).
As for uniqueness: if $\rm\ a\,x' \equiv b \equiv a\, x\:$ then multiplying both sides by $\rm\:a^{-1}\:$ yields $\rm\: x'\equiv x.$
Beware $\ $ The above use of fractions in modular arithmetic is valid only when the denominator is a unit (invertible); else it is a zero-divisor so the quotient need not be unique, e.g. mod $\rm\:10,\:$ $\rm\:4\,x\equiv 2\:$ has solutions $\rm\:x\equiv 3,8,\:$ so the "fraction" $\rm\:x \equiv 2/4\pmod{10}$ cannot designate a unique solution. Indeed, the solution $\rm\:x\equiv 1/2\equiv 3\pmod 5\:$ requires cancelling $\,2\,$ from the modulus too, since $\rm\:10\:|\:4x-2\iff5\:|\:2x-1.\:$
Generally the grade-school rules of fraction arithmetic apply universally (i.e. in all rings) where the denominators are units (invertibles). This fundamental property will be clarified conceptually when one learns about the universal properties of fractions rings and localizations.
$\varphi(n)$ is even for every $n \ge 3$, so you would need $n$ to be even as well. However, if you write $n = 2^k m$, $m$ odd, then $$ n - 2 = \varphi(n) = \varphi(2^k) \varphi(m) = 2^{k-1} \varphi(m) \le 2^{k-1} m = \frac{n}{2}$$ which severely limits the possibilities for $n$.
Best Answer
This is too long to be comment and hence the post.
$\phi(n) = 8$. Note that $\sqrt{n} \leq \phi(n) \leq n-1$.
This implies $n$ is at most $64$. So you could write a brute force computer and compute $\phi(n)$ when $n \in [9,64]$.
A better way would be as follows.
Let $n=\displaystyle \prod_{i=1}^k p_i^{\alpha_i} \Rightarrow \phi(n) = \displaystyle \prod_{i=1}^k p_i^{\alpha_i-1} (p_i-1)$.
First note that $n$ can be of the form $\displaystyle 2^\alpha \left( \prod_{i=1}^k p_i \right)$ i.e. the exponent of the odd primes in the prime factorization of $n$ is $1$. This is so, because if not these primes will then divide $\phi(n) = 8$ which is not possible.
If $k=0$, then we have $n=2^{\alpha}$, $\displaystyle 2^{\alpha-1} = \phi(n) = 2^3 \Rightarrow \alpha=4$. Hence, $k=1 \Rightarrow n=16$.
Let $k=1$. Then we have $n=2^{\alpha} p_1$.
If $\alpha = 0,1$, then $\displaystyle (p_1-1) = \phi(n) = 2^3 \Rightarrow p_1 = 9 \Rightarrow \text{ Not possible}$.
If $\alpha = 2$, then $\displaystyle 2 (p_1 - 1) = \phi(n) = 2^3 \Rightarrow p_1=5$. Hence, $n=20$.
If $\alpha = 3$, then $\displaystyle 2^2 (p_1 - 1) = \phi(n) = 2^3 \Rightarrow p_1=3$. Hence, $n=24$.
Now let $k=2$. Then we have $n=2^{\alpha} p_1 p_2$.
If $\alpha = 0,1$, then $\displaystyle (p_1-1)(p_2-1) = \phi(n) = 2^3 \Rightarrow p_1 = 3, p_2 = 5$. Hence, $n=15$ when $\alpha = 0$ and $n=30$ when $\alpha = 1$
If $\alpha = 2$, then $\displaystyle 2(p_1-1)(p_2-1) = \phi(n) = 2^3 \Rightarrow (p_1-1)(p_2-1) = 4 \Rightarrow \text{ Not Possible}$.
$k=3$ is not possible since $(3-1) \times (5-1) \times (7-1) > 8$.
Hence, the only solutions (hope I have not missed any case) are:
$$n=15,16,20,24,30$$
Similar idea extends to other problems where we want to find the inverse of the totient function.