![]() ![]() Asus Chromebox - Installing OpenELEC (Standalone Setup - No Chrome-OS).Left 4 Dead - Steam Group Server Settings.Installing LibreELEC Kodi in a VMware vSphere Virtual Machine.Inkscape - Change the white background workspace to a transparent color. ![]() ![]() WordPress - Nested and Styled HTML Lists.Search PricklyTech Search for: Top Posts & Pages Read -s -n 1 -p "Press any key to reboot" Sudo sed -i "s/$hostn/$newhost/g" /etc/hostname Sudo sed -i "s/$hostn/$newhost/g" /etc/hosts #change hostname in /etc/hosts & /etc/hostname It’s always handy to have a script to do things – so here is a quick bash script that I put together that uses sed to change the hostname and then reboot: #!/bin/bash Sudo sed -i 's/ubuntu/new-hostname/g' /etc/hostname With sed we can look for our hostname (in /etc/hosts and /etc/hostname) and then replace it with the desired new-hostname: sudo sed -i 's/ubuntu/new-hostname/g' /etc/hosts Use the hostname command to check what your hostname is. Use sed to change the hostnameĪnother way to achieve the same goal is to use the sed command to replace the existing hostname with a new one.įor example, my Ubuntu Server has the default hostname of ‘ubuntu’. Editing /etc/hosts using nano sudo reboot 2. In /etc/hosts you will find the hostname on the line beginning 127.0.0.1 – overwrite only the hostname with the new one, and then reboot. In /etc/hostname simply overwrite the existing hostname with a new one. We can manually edit these files using a basic text editor like nano: sudo nano /etc/hosts There are several ways that we can change the hostname in these files. On Ubuntu the hostname is stored in both the /etc/hosts and /etc/hostname files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |