Sometimes I want a second address on a network card for a quick test, such as reaching a device that sits in another subnet. There is no need to edit a config file for that.
sudo ip addr add 192.0.2.10/24 dev eth0
ip addr show dev eth0
sudo ip addr del 192.0.2.10/24 dev eth0
The first line adds the address with its prefix length to the interface named after dev. The second shows the result, and the third removes the address again. The address range in the example is one reserved for documentation, so use your own.
This changes the running system only. Red Hat’s networking guide says that settings made with ip on the command line do not persist after a restart, and the same goes for restarting the network service on many setups. That is exactly what makes it good for experiments: you cannot forget to clean up, as a reboot does it for you.
Check the interface name first with ip -br addr, because it is not always eth0. On current systems it is often something like enp3s0.
The caveat is that a network manager may undo it. NetworkManager, systemd-networkd or Netplan can reapply their own configuration and remove an address they did not add. Making the address permanent belongs in their configuration, not in this command. Also, do not add an address that is already in use on the same network, since that causes conflicts for the other device.
Further reading: ip-address(8) manual page