Today I need to complete my College assignment in that I need to put a Terminal screenshot with my Exam seat number. To perform that, I need to update my hostname currently. My hostname is ‘LINUX’ and change to ‘AX84S4D’.
Now you think what a big deal to change hostname? It is pretty simple to change the hostname, go to the /etc/hostname, and update it, that’s all.
Hold your horses that’s the step I know well. The problem is I rarely restart or shut down my System due to most of the services are in the background. Because of that, I don’t want to restart my machine, and you can say I’m indolent.
So I have to find a way to change the hostname without restarting the system or set a temporary hostname for my System.
Do you also have the same problem or maybe different and looking for a solution? Your search end here, In this article, we will see how to set a temporary hostname in Linux and Other Distributions.
Table of Contents
We will not ask much from your end. First, you should be able to access the terminal with a sudo privilege and keep the handy hostname you want to set for a temporary basis. That’s all.
Change hostname Temporary
Step 1. Open Terminal
I’m performing all these steps on my Ubuntu machine, and I believe it will work on all Linux Distributions. The first step is to open a terminal in Ubuntu; we can use the shortcut
Ctrl + Alt + T to open terminal or search terminal in applications manager.
Step 2. Pass hostname with sudo command
In this step, we will change or set the hostname for that pass the below command with sudo privileges otherwise, and you will get the error “hostname: you must be root to change the host name”.
$ sudo hostname AX84S4D
hostname :- Command to change the hostname
AX84S4D :- Temporary hostname to set
Once you pass the command, it will ask for the SUDO password; after authorization, you will not see the changes immediately for that you to perform one step further and one thing forgets to mention even if you pass the hostname command in the terminal, it will show the current hostname not updated hostname.
Step 3. Run bash
We have almost completed the step. We just need to pass the bash command in the current terminal screen, and after that, the hostname will change or set as per our intent.
To get back the original hostname, simply pass the exit command or close the current terminal, and you will back to the original hostname. An Only drawback of using this command it works only on the current terminal. If you open the multiple terminals, it will not show the changes.
That’s all to change or set temporary hostname without restarting the system in Linux or any other Distributions.
Read this to :- 10 Reasons Why You Should Switch From Windows To Linux
If you are stuck somewhere, please feel free to comment down and If you like the article or somewhere I missed something, please let me know to make this article more amazing.
A man with a tech effusive, who has explored some of the amazing technology stuff and exploring more, While moving towards, I had a chance to work on Android Development, Linux, AWS, DevOps with several Open source tools.
One of my life mottos “Always be lifelong Students.”