How to Append Lines to /etc/hosts File in Linux using Shell Script without Open The hosts file with Text Editor

sudo echo "192.241.xx.xx  venus.example.com venus" >> /etc/hosts

would append the line at the end of the file, which could work as you expect.

Leave a Comment

Required fields are marked *