The hostname of my name is very long, which is odd. How can change the hostname for my system?
My hostname, currently, is
himanshu@himanshu-Lenovo-ideapad-100-15IBD:~$
Is there any way I can shorten this or change it entirely?
The hostname of my name is very long, which is odd. How can change the hostname for my system?
My hostname, currently, is
himanshu@himanshu-Lenovo-ideapad-100-15IBD:~$
Is there any way I can shorten this or change it entirely?
Open Terminal (Alt+Ctrl+T), and enter this:
sudo -H gedit /etc/hostname
Enter your password, and then a file will open. Just change the name to the new hostname, and save the file. Do the same with the hosts file, by running:
sudo -H gedit /etc/hosts
Edit the name to your new hostname after 127.0.0.1 and save.
Restart your computer, and it should be done.
Edit: Use gksudo
instead of sudo
. It's safer.
sudo gedit
or sudo <any GUY application>
is not a good idea. This will change the ownership of some files and folder within your home directory, that will cause future errors. To recover from this problem you should run sudo chown -R $USER:$USER $HOME
. For future use sudo -i gedit
, or sudo -H gedit
, or better sudo nano filename
.
– pa4080
Oct 11 '17 at 19:44