SOLVED! GUI Tool to change hostname

Forum rules
Before you post please read this

SOLVED! GUI Tool to change hostname

Postby ccc on Mon Jan 27, 2014 4:31 am

hi

I need a GUI tool to change hostname and domain in LXDE.
Last edited by ccc on Wed Jan 29, 2014 6:03 pm, edited 1 time in total.
ccc
Level 2
Level 2
 
Posts: 98
Joined: Sat Jul 23, 2011 7:40 pm

Linux Mint is funded by ads and donations.
 

Re: GUI Tool to change hostname

Postby xenopeek on Mon Jan 27, 2014 5:05 am

You can just use your text editor. Change your hostname in /etc/hostname and update it also in /etc/hosts.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14565
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: GUI Tool to change hostname

Postby ccc on Mon Jan 27, 2014 5:13 am

xenopeek wrote:You can just use your text editor. Change your hostname in /etc/hostname and update it also in /etc/hosts.


Yep, I can do this, but other admins in my office need a GUI.
ccc
Level 2
Level 2
 
Posts: 98
Joined: Sat Jul 23, 2011 7:40 pm

Re: GUI Tool to change hostname

Postby xenopeek on Mon Jan 27, 2014 10:31 am

Ah :) I tried this on Xfce but should work on LXDE also I think. Install the package gnome-network-admin. That installs network-admin, probably called "Network" in your menu. The tool has three tabs;
- General tab where you can edit the host and domain name (change to host name updates both /etc/hostname and /etc/hosts)
- DNS tab where you can edit DNS
- Hosts tab where you can basically edit /etc/hosts file contents

Hosts file is ignored on Linux Mint from release 13 IIRC, as NetworkManager starts dnsmasq as local DNS forwarder and starts it with option to not load hosts file.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14565
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: GUI Tool to change hostname

Postby ccc on Mon Jan 27, 2014 11:24 am

xenopeek wrote:Ah :) I tried this on Xfce but should work on LXDE also I think. Install the package gnome-network-admin. That installs network-admin, probably called "Network" in your menu. The tool has three tabs;
- General tab where you can edit the host and domain name (change to host name updates both /etc/hostname and /etc/hosts)
- DNS tab where you can edit DNS
- Hosts tab where you can basically edit /etc/hosts file contents

Hosts file is ignored on Linux Mint from release 13 IIRC, as NetworkManager starts dnsmasq as local DNS forwarder and starts it with option to not load hosts file.


Thx, but gnome-network-admin needs more than 50 additional packages and I don't need this.
ccc
Level 2
Level 2
 
Posts: 98
Joined: Sat Jul 23, 2011 7:40 pm

Re: GUI Tool to change hostname

Postby eanfrid on Mon Jan 27, 2014 12:42 pm

On the other hand, you want to use LXDE - a lightweight and minimalist DE - which primarily targets CLI adepts. Your fellow admin users seem to want a GUI for everything. LXDE is not the right choice for them.
Main desktop: Debian GNU/Linux Wheezy 64bit w/custom 3.14 longterm kernel - MATE 1.8.1
(i5 2400@3.7GHz - 16GB DDR3 - HD6770 w/radeon driver - SSD+RAID1)
User avatar
eanfrid
Level 7
Level 7
 
Posts: 1624
Joined: Mon Apr 30, 2012 2:49 am
Location: there is no place like ~

Re: GUI Tool to change hostname

Postby ccc on Mon Jan 27, 2014 1:23 pm

eanfrid wrote:On the other hand, you want to use LXDE - a lightweight and minimalist DE - which primarily targets CLI adepts. Your fellow admin users seem to want a GUI for everything. LXDE is not the right choice for them.


Sorry, but we dont have really admins in the branches, just power users.
They can recover linux image using Acronis but they cannot edit files over command line.
Perhaps exists a script for the desktop, to change computer name in /etc/hostname and etc/hosts?
Last edited by ccc on Wed Jan 29, 2014 6:23 pm, edited 1 time in total.
ccc
Level 2
Level 2
 
Posts: 98
Joined: Sat Jul 23, 2011 7:40 pm

Re: GUI Tool to change hostname

Postby ccc on Wed Jan 29, 2014 6:03 pm

This bash script seems to works well:
Code: Select all
#!/bin/bash
#assign existing hostname to $hostn
hostn=$(cat /etc/hostname)

#display existing hostname
echo "Existing hostname is $hostn"

#ask for new hostname $newhost
echo "Enter new hostname: "
read newhost

#change hostname in /etc/hosts & /etc/hostname
sudo sed -i "s/$hostn/$newhost/g" /etc/hosts
sudo sed -i "s/$hostn/$newhost/g" /etc/hostname

#display new hostname
echo "Your new hostname is $newhost"

#press a key to reboot
echo "Press any key to reboot..."
read 1 -p 'Press any key to reboot...';echo
sudo /sbin/reboot


BTW I have created a desktop icon to start this script and I have changed /etc/sudoers, to run as a normal user:
Code: Select all
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Change hostname
Type=Application
Comment=
Categories=Application;
Exec=lxterminal --working-directory=/usr/bin -e sh /usr/bin/hostname.sh
Icon=/usr/share/pixmaps/lxterminal.png
Terminal=false
StartupNotify=true
GenericName[en_US]=
Name[en_US]=Change hostname
ccc
Level 2
Level 2
 
Posts: 98
Joined: Sat Jul 23, 2011 7:40 pm

Linux Mint is funded by ads and donations.
 

Return to Others

Who is online

Users browsing this forum: No registered users and 1 guest