Command to change Ubuntu hostname through CLI without rebooting

There are other useful options that you can use with hostamectl command

If you are a developer than showing the host information in json format you can add the –json pretty options to display the host information in Json pretty format for you to import into another application.