Missing /etc/hosts file – How can I create a new hosts file? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite













This question already has an answer here:



  • How can I restore configuration files?

    7 answers



I have googled and searched Ask Ubuntu on this, but got no relevant answers.
I have no hosts file in /etc, I cannot find a hosts file in search, I am talking about the system hosts file not lampp/etc. I mention that because there is no hosts file there either - maybe that is a clue.



I want to know how to create a hosts file in Ubuntu or obtain a sample file I could copy and paste or I am happy to use the terminal if someone can help with best way to create the file and edit it.



I am not even sure what extension it should have - basically I just want the default hosts file that I understand Ubuntu should come with in my /etc folder.










share|improve this question















marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 18 at 11:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
    – muru
    Feb 18 at 11:37














up vote
0
down vote

favorite













This question already has an answer here:



  • How can I restore configuration files?

    7 answers



I have googled and searched Ask Ubuntu on this, but got no relevant answers.
I have no hosts file in /etc, I cannot find a hosts file in search, I am talking about the system hosts file not lampp/etc. I mention that because there is no hosts file there either - maybe that is a clue.



I want to know how to create a hosts file in Ubuntu or obtain a sample file I could copy and paste or I am happy to use the terminal if someone can help with best way to create the file and edit it.



I am not even sure what extension it should have - basically I just want the default hosts file that I understand Ubuntu should come with in my /etc folder.










share|improve this question















marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 18 at 11:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
    – muru
    Feb 18 at 11:37












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • How can I restore configuration files?

    7 answers



I have googled and searched Ask Ubuntu on this, but got no relevant answers.
I have no hosts file in /etc, I cannot find a hosts file in search, I am talking about the system hosts file not lampp/etc. I mention that because there is no hosts file there either - maybe that is a clue.



I want to know how to create a hosts file in Ubuntu or obtain a sample file I could copy and paste or I am happy to use the terminal if someone can help with best way to create the file and edit it.



I am not even sure what extension it should have - basically I just want the default hosts file that I understand Ubuntu should come with in my /etc folder.










share|improve this question
















This question already has an answer here:



  • How can I restore configuration files?

    7 answers



I have googled and searched Ask Ubuntu on this, but got no relevant answers.
I have no hosts file in /etc, I cannot find a hosts file in search, I am talking about the system hosts file not lampp/etc. I mention that because there is no hosts file there either - maybe that is a clue.



I want to know how to create a hosts file in Ubuntu or obtain a sample file I could copy and paste or I am happy to use the terminal if someone can help with best way to create the file and edit it.



I am not even sure what extension it should have - basically I just want the default hosts file that I understand Ubuntu should come with in my /etc folder.





This question already has an answer here:



  • How can I restore configuration files?

    7 answers







command-line filesystem hosts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 11:32









muru

130k19275470




130k19275470










asked Feb 18 at 7:02









kerry

164418




164418




marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 18 at 11:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 18 at 11:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
    – muru
    Feb 18 at 11:37
















  • The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
    – muru
    Feb 18 at 11:37















The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
– muru
Feb 18 at 11:37




The default contents are created by the netbase package. See /var/lib/dpkg/info/netbase.postinst.
– muru
Feb 18 at 11:37










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










Lines in the /etc/hosts file have the following format:



<IP> <HOSTNAME>.<DOMAIN> <ALIAS>


You can create and/or edit the file with your preferred editor:





sudo nano /etc/hosts # with nano in a terminal
gksudo gedit /etc/hosts # with gedit
kdesudo kate /etc/hosts # with kate


Here are some useful lines for the file – lines beginning with # are comments and get ignored, empty lines are allowed:



# The following line is desirable for IPv4 capable hosts
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


You can read more about the format and get examples on the manpage (How can I get help on terminal commands?):



man hosts


There's also a Howto on ubuntuforums.org.



Further reading:



  • What is the use of /etc/hosts?

  • What are the default settings for 'etc/hosts' and 'etc/hostname'?

  • How should I add a host name to /etc/hosts?





share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    Lines in the /etc/hosts file have the following format:



    <IP> <HOSTNAME>.<DOMAIN> <ALIAS>


    You can create and/or edit the file with your preferred editor:





    sudo nano /etc/hosts # with nano in a terminal
    gksudo gedit /etc/hosts # with gedit
    kdesudo kate /etc/hosts # with kate


    Here are some useful lines for the file – lines beginning with # are comments and get ignored, empty lines are allowed:



    # The following line is desirable for IPv4 capable hosts
    127.0.0.1 localhost

    # The following lines are desirable for IPv6 capable hosts
    ::1 localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters


    You can read more about the format and get examples on the manpage (How can I get help on terminal commands?):



    man hosts


    There's also a Howto on ubuntuforums.org.



    Further reading:



    • What is the use of /etc/hosts?

    • What are the default settings for 'etc/hosts' and 'etc/hostname'?

    • How should I add a host name to /etc/hosts?





    share|improve this answer


























      up vote
      3
      down vote



      accepted










      Lines in the /etc/hosts file have the following format:



      <IP> <HOSTNAME>.<DOMAIN> <ALIAS>


      You can create and/or edit the file with your preferred editor:





      sudo nano /etc/hosts # with nano in a terminal
      gksudo gedit /etc/hosts # with gedit
      kdesudo kate /etc/hosts # with kate


      Here are some useful lines for the file – lines beginning with # are comments and get ignored, empty lines are allowed:



      # The following line is desirable for IPv4 capable hosts
      127.0.0.1 localhost

      # The following lines are desirable for IPv6 capable hosts
      ::1 localhost ip6-localhost ip6-loopback
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters


      You can read more about the format and get examples on the manpage (How can I get help on terminal commands?):



      man hosts


      There's also a Howto on ubuntuforums.org.



      Further reading:



      • What is the use of /etc/hosts?

      • What are the default settings for 'etc/hosts' and 'etc/hostname'?

      • How should I add a host name to /etc/hosts?





      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Lines in the /etc/hosts file have the following format:



        <IP> <HOSTNAME>.<DOMAIN> <ALIAS>


        You can create and/or edit the file with your preferred editor:





        sudo nano /etc/hosts # with nano in a terminal
        gksudo gedit /etc/hosts # with gedit
        kdesudo kate /etc/hosts # with kate


        Here are some useful lines for the file – lines beginning with # are comments and get ignored, empty lines are allowed:



        # The following line is desirable for IPv4 capable hosts
        127.0.0.1 localhost

        # The following lines are desirable for IPv6 capable hosts
        ::1 localhost ip6-localhost ip6-loopback
        ff02::1 ip6-allnodes
        ff02::2 ip6-allrouters


        You can read more about the format and get examples on the manpage (How can I get help on terminal commands?):



        man hosts


        There's also a Howto on ubuntuforums.org.



        Further reading:



        • What is the use of /etc/hosts?

        • What are the default settings for 'etc/hosts' and 'etc/hostname'?

        • How should I add a host name to /etc/hosts?





        share|improve this answer














        Lines in the /etc/hosts file have the following format:



        <IP> <HOSTNAME>.<DOMAIN> <ALIAS>


        You can create and/or edit the file with your preferred editor:





        sudo nano /etc/hosts # with nano in a terminal
        gksudo gedit /etc/hosts # with gedit
        kdesudo kate /etc/hosts # with kate


        Here are some useful lines for the file – lines beginning with # are comments and get ignored, empty lines are allowed:



        # The following line is desirable for IPv4 capable hosts
        127.0.0.1 localhost

        # The following lines are desirable for IPv6 capable hosts
        ::1 localhost ip6-localhost ip6-loopback
        ff02::1 ip6-allnodes
        ff02::2 ip6-allrouters


        You can read more about the format and get examples on the manpage (How can I get help on terminal commands?):



        man hosts


        There's also a Howto on ubuntuforums.org.



        Further reading:



        • What is the use of /etc/hosts?

        • What are the default settings for 'etc/hosts' and 'etc/hostname'?

        • How should I add a host name to /etc/hosts?






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 18 at 16:12









        pa4080

        12.3k52357




        12.3k52357










        answered Feb 18 at 8:49









        dessert

        20k55795




        20k55795












            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error