Append line to /etc/hosts file with shell script

前端 未结 7 1889
春和景丽
春和景丽 2021-01-30 08:41

I have a new Ubuntu 12.04 VPS. I am trying to write a setup script that completes an entire LAMP installation. Where I am having trouble is appending a line to the /etc/ho

7条回答
  •  忘了有多久
    2021-01-30 09:01

    echo "127.0.0.1 localhost `hostname`">./temp_hosts
    echo "192.241.xx.xx  venus.example.com">>./temp_hosts
    cat /etc/hosts |tail -n +2 >>./temp_hosts
    cat ./temp_hosts > /etc/hosts
    rm ./temp_file
    

提交回复
热议问题