hostname must be between 2 and 63 characters long.hostname must begin and end with a letter or number.hostname can only contain letters, digits, and the hyphen character, and the period character.There are some rules specified for hostname: It’s the same process pretty much in any other desktop environment. Change the hostname through ubuntu settings GUI This ‘Device name’ is your system’s hostname. In here, you’ll see the ‘Device name’ field that is editable. To change the hostname in Ubuntu 22.04 or any other Linux distribution using GNOME desktop, just go to the System Settings and click on About. The beginner-friendly Linux distribution Ubuntu often provides the graphical way of doing things. Though I used Ubuntu here, you can use these methods to change hostname in Debian or most other distributions. Hosts and hostname files containing current hostname This is important otherwise you’ll start seeing “ sudo: unable to resolve host” error. You must also edit the /etc/hosts file in the similar fashion and replace all the occurrences of your old hostname with the new hostname. Change it to the hostname you want and save the file. You’ll only see one line here and that contains your system’s hostname. Ubuntu has Nano editor installed by default so you can use that as well. Since you are in terminal, you need to use a command line based text editor to edit these files like Vi or Vim. To change your hostname permanently, you’ll also need to edit your /etc/hostname and /etc/hosts file, which is where Ubuntu, Mint and other Debian-based distributions store the hostname. Method 2: Change hostname permanently with hostname command If you reboot your system, the old hostname will be back. Now if you use the command hostname, you’ll see that your hostname has been changed.īut the changes you just made are not permanent. Replace with the new hostname you want to use: sudo hostname Change the hostname using hostname command Open a terminal and use the command below to change the hostname. Changing the hostname through terminal command Method 2: Change hostname temporarily with hostname command Of course, replace the with your new hostname in the above command. To change the hostname, you can use this option with the hostnamectl command: hostnamectl set-hostname Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxīoot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx It will give you a lot of details: Static hostname: itsfoss To check your current hostname and some other information, use the command: hostnamectl If your Linux system uses systemd, you can use the tools provided by systemd to change the hostname. Method 1: Change hostname using systemd tools Now, there are several commands for changing the hostname in Linux. If you want to change the hostname in Ubuntu or any other Debian based Linux distribution, you can use the typical Linux way to do that, which is using the command line. Change hostname in Ubuntu & other Linux using command line Here I am assuming you have Ubuntu on your system, but you can try the same command line trick on Linux Mint and some other Debian distributions as they use the same configuration as Ubuntu. There are two ways to change the hostname in Ubuntu: This hostname is supposed to uniquely identify a computer on a network. Note that you shouldn’t use the same hostname on two different computers on the same network, as this can cause problems. If at any point in time you feel like your computer doesn’t have a fancy or relevant name, you can easily change the hostname in Linux. When you install Ubuntu, it asks you to choose a name for your computer. Check the current hostname in terminalĪs you can see in the above screenshot, the username is abhishek while the hostname is itsfoss. You can see the hostname in the terminal using the hostname command. It’s used to identify your computer on the network. The hostname is basically just your computer’s name. Read the rest of the article to learn more about hostname and ways to change it.īefore you see various ways to change the hostname, you should first know what’s a hostname! What is a hostname in Linux?Ī hostname is a name assigned to a “host” i.e. If you don’t like the one you’ve got, you can use the following systemd command to change the hostname on major Linux distributions: hostnamectl set-hostname new_host_name Some will automatically create one for you but you’ll always have a computer name. Some Linux distributions and cloud service providers let you choose the hostname while installing. It can be used to identify and communicate your system on the same network. The hostname is basically your computer’s name.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |