Skip to main content

A hosts file editing tool for command line shell.

Project description

hostsed -- A tiny hosts file command line edit tool

hostsed is a simple python tool for editing hosts file(default /etc/hosts), you can add or delete a DNS entry via command line shell(e.x. bash). Editing hosts file with hostsed would be a more idemponent command line experience, i.e., add/del the same record won't result duplicated or missing entries in the hosts file. hostsed will check the validity ip address for both IPV4 and IPV6.

Install

You may install hostsed via pip. Python3 is preferred:

sudo pip3 install hostsed

Or on system default pip command:

sudo pip install hostsed

Usage

Display the hosts file content

sudo hostsed
# specify a location other than /etc/hosts
hostsed --file hosts.example

Add an entry

sudo hostsed add <ip address> <hostname1> <hostname2> ...

Example:

sudo hostsed add 192.168.1.1 gateway
sudo hostsed add 172.17.0.5 mongo-store-1 mysql-02
hostsed --file hosts.exmaple add 127.0.0.1 valarmorghulis.io

Delete an entry

rm/delete/remove are all alias for del:

sudo hostsed del <ip address> <hostname>

Example:

sudo hostsed remove 192.168.1.1 gateway
hostsed --file hosts.exmaple rm ::1 localhost

Drop lines with specified ip or hostname

sudo hostsed drop <ip or hostname>

Example:

sudo hostsed drop 192.168.1.1
sudo hostsed drop www.example.com
hostsed --file hosts.exmaple drop ::1

Get the ip address of a docker container

sudo hostsed docker <docker-container-name>

Acknowledgement

Thanks for @noahfx provide some awesome improve for hostsed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hostsed-0.5.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hostsed-0.5.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file hostsed-0.5.0.tar.gz.

File metadata

  • Download URL: hostsed-0.5.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.14

File hashes

Hashes for hostsed-0.5.0.tar.gz
Algorithm Hash digest
SHA256 37bec95f3c768efa664e0d47608150ba28947c19db85e93bb8b9a7fb7bf90e1b
MD5 fac036845a2a91b1f2d176f32e33341e
BLAKE2b-256 5475eb057fb854175effd6415a48844e896bb0acf1930ba64c03411c5cddf5af

See more details on using hashes here.

File details

Details for the file hostsed-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: hostsed-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.14

File hashes

Hashes for hostsed-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6177d608aef690055729c1b7cc5aecd043060497d897511ff13ceb699626d2df
MD5 63283da1fc44291eb1f69104d61be49c
BLAKE2b-256 074a7d6ab25082937ba322a6b693ca423dc120726ef0803c266253ac25fcf2be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page