HowTo set hostname/domainname on linux

If you’ve gotten this error: hostname: Name or service not known when typing hostname -f, then here is a solution. I got this error while trying to install Plesk.

I couldn’t find a single clear response, most people spent their time showing how smart they are by explaining how host names work, and what it means to linux, who cares. This is how I fixed the problem, maybe it will help you:

This is on Ubuntu 10.4, don’t know how will this will transfer over to other distros, but I don’t imagine it will be much different.

$ nano /etc/hosts
Add this, replacing mysite with your actual site/domain mysite
$ echo "mysite" > /etc/hostname
$ hostname -F /etc/hostname
$ domainname -F /etc/hostname

About Jason

I am a 31 year old programmer living in the south of France. I currently work actively in the fields of Ruby/PHP/Javascript and server/website administration.
This entry was posted in Computer Science, Linux, Tips and Tricks, Topics and tagged , , , . Bookmark the permalink.
  • Vidya Ravi

    Thanks a helped me.