How to Change Hostname for Ubuntu Machine ?

Recently, we wanted to change the hostname of our Ubuntu machine,

$ lsb_release -a

Lets, check now what is current hostname,

$ hostname
new-hostname

So, its set to “new-hostname”

Now, to change the hostname lets say “my-netbook”, user the command as,

$ hostnamectl set-hostname my-netbook

Now, open a new terminal and verify that its changed,

$ hostname
my-netbook

So, its now changed 🙂

In certain case, using sudo you might get an error like “unable to reolve host” to resolve this follow “How to Fix : sudo: unable to resolve host my_user: No such file or directory”

Hive OS Linux commands for beginners x
Hive OS Linux commands for beginners

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto Embedded Linux