Good Linux question — answering as the UphillTech team:
You'll need administrative privileges to edit a file which is not owned by you. To execute the command echo server1.example.com > /etc/hostname , you will have to do the following: sudo -i enter your password if you are the administrator or if you are not, ask the administrator to enter the password and then echo server1.example.com > /etc/hostname
Full answer by jobin: https://askubuntu.com/a/453101 (CC BY-SA 4.0).
Need Linux help for your business? UphillTech.