Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Regarding changing Hostname and Server name in Terminal

  1. #1
    Join Date
    Dec 2017
    Beans
    20

    Regarding changing Hostname and Server name in Terminal

    Hello,
    If i open a terminal i am getting as
    Code:
    dilip@Dilip:~$
    where "dilip" is Server name and "Dilip" is Hostname (correct me if i am wrong....
    I tried to change hostname by the command:
    Code:
    gksudo gedit /etc/hostname /etc/hosts
    But i am unable to change the Server name ie., "dilip"

    So, How can i change this server name...? What are the commands need to be given..??

    Any suggestions are appreciated.

    Thank you.
    Last edited by slickymaster; March 28th, 2018 at 12:13 PM. Reason: code tags and normalized font

  2. #2
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Regarding changing Hostname and Server name in Terminal

    Thread moved to Server Platforms.

  3. #3
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Regarding changing Hostname and Server name in Terminal

    Quote Originally Posted by dilip.h.n View Post
    Hello,
    If i open a terminal i am getting as
    Code:
    dilip@Dilip:~$
    where "dilip" is Server name and "Dilip" is Hostname (correct me if i am wrong....
    I tried to change hostname by the command:
    Code:
    gksudo gedit /etc/hostname /etc/hosts
    But i am unable to change the Server name ie., "dilip"

    So, How can i change this server name...? What are the commands need to be given..??

    Any suggestions are appreciated.

    Thank you.
    dilip is the username for the current user
    Dilip is the hostname of the server

    After changing the server hostname you'll have to reboot it so the change takes effect
    Last edited by slickymaster; March 28th, 2018 at 12:16 PM.

  4. #4
    Join Date
    Dec 2017
    Beans
    20

    Re: Regarding changing Hostname and Server name in Terminal

    Sorry,
    I want to change the username for the current user ie., "dilip".
    I am able to change the hostname of the server but unable to change the username for the current user...

    So, How do i change the username for the current user ie., "dilip"...???

    Thank you.

  5. #5
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Regarding changing Hostname and Server name in Terminal

    Code:
    sudo usermod -l newUsername oldUsername
    After that done rename your home folder
    Code:
    sudo usermod -d /home/newHomeDir -m newUsername
    Log out and log in using your new username

  6. #6
    Join Date
    Jul 2005
    Beans
    54

    Re: Regarding changing Hostname and Server name in Terminal

    You'll need to use the "usermod" command with the --login flag. Note that this may not be as simple as you think it is, since you may want to also change the location of your HOME directory as well to match. It's not entirely clear whether you want to do that or not.

    Look at the manual page for the command to see if any of the other options are necessary for what you want to accomplish.

    EDIT: The previous post is a better answer. We just happened to post at approximately the same time.

  7. #7
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Regarding changing Hostname and Server name in Terminal

    There are a few other ways, but using usermod is probably safest.
    I would sudoedit the /etc/passwd and /etc/shadow files. This will only change the username, not the HOME directory for that userid, which is also in the passwd file and it will leave the default groupname alone too. If you want, you can change those by editing the group and gshadow files in /etc/.

    There is a manpage for each of these config files which explains what each field means. Section 5 is for config files, so man -s5 passwd will show information about the config and not the passwd command. manpages rock.

    There is also a group-mod command - I'd have to look it up and read the manpage on it to get the correct options.

    Also, editing these files only works for simple setups. In a corporate environment with LDAP (or some other) userid/groupid controls, it may be necessary to use those other tools to rename a username.

  8. #8
    Join Date
    Dec 2017
    Beans
    20

    Re: Regarding changing Hostname and Server name in Terminal

    If i give the following command in the terminal as:-
    sudo usermod -l DILIP dilip

    it shows the message as:-
    usermod: user dilip is currently used by process 1365

    How do i solve this issue..??

  9. #9
    Join Date
    Dec 2017
    Beans
    20

    Re: Regarding changing Hostname and Server name in Terminal

    If i give the following command in the terminal as:-
    sudo usermod -l DILIP dilip

    it shows the message as:-
    usermod: user dilip is currently used by process 1365

    How do i solve this..??

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Regarding changing Hostname and Server name in Terminal

    See post #7 for manual steps.

    Or use a different account to make the changes.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •