Code Monkey home page Code Monkey logo

add-etc-hosts's Introduction

Add/Remove hostnames from the /etc/hosts file

Introduction

This script was created for simplifying the addition/removal of hostnames to the /etc/hosts file. It's particularly useful if you're developing a site locally and want that site to have a "handle" that is related to the project name.

For example if I'm developing a site that is for a widget maker that will use the domain mywidgetmaker.com I'll do:

add-etc-hosts mywidgetmaker.com.local

Now I can enter http://mywidgetmaker.com.local on the address bar of the browser and it will show me the site that I'm developing.

It's particularly useful for working with Nginx, you just add the server_name directive to your vhost configuration (server context), like this:

server_name mywidgetmaker.local;  

If I want to add an IPv6 hostname I specify the optional argument -6:

add-etc-hosts -6 mywidgetmaker.local

Now there's an IPv6 loopback hostname. You can access your new IPv6 host.

Installation

  1. Clone the git repo or download it.

  2. Put the scripts in a directory included in your PATH or define aliases like this:

    alias add-etc-hosts='/path/to/add-etc-hosts'
    alias rm-etc-hosts='/path/to/rm-etc-hosts'
    

    Source the new aliases, if you have them in a ~/.bash_aliases file:

    . ~/.bash_aliases
    

    or something similar, depending on the name and location of the file where the aliases are defined.

  3. Install the manual pages man/add-etc-hosts.8 and man/rm-etc-hosts under the man/man8 section of your local documentation directory.

  4. Done.

Documentation

Full documentation is on the manpage add-etc-hosts(8).

add-etc-hosts's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.