Reputation: 12190
I'm cloning lots of virtual machines, and I need to edit /etc/hostname and replace old hostname with a new one.
then I would have to run
hostname new-server-name
and log out of the ssd session and login again.
I'm trying to make my job easier by doing this
echo "new-server-name" > /etc/hostname
if there is a way to assign the value to /etc/hostname to host command? Something like
cat /etc/hostname | hostname
but it doesn't work.
Upvotes: 1
Views: 453
Reputation: 9867
You probably want this:
hostname $(cat /etc/hostname)
And don't forget to edit /etc/hosts
to reflect the correct host name as well.
Upvotes: 1