change user name and hostname under Ubuntu

Source: Internet
Author: User

Reprint : https://www.cnblogs.com/zeusmyth/p/6231350.html

 change user name and hostname under Ubuntu

Many times, we are not satisfied with the installation of the user name and host name, but because already in this user has done a lot of configuration, so only on the original basis to change the user name and host name.

However, when changing these documents, be careful, because accidentally will cause a restart after the situation can not be logged in. I myself have wasted a lot of time because of this:

   here write my experience, the security of the user name modification, to avoid the changes can not be logged in the situation , I hope to help you, so that you less detours

  1. First change the host name ———— to BBB:

This is easy, and there are no serious errors:

(1) Modify the hostname file

The contents of this file are used to display the host name, after modifying this file, if you restart immediately, we will see the host in the terminal @ becomes BBB

(2) Modify the Hosts file

    

After changing the host name, we need to restart the computer, or the command will be slow to execute.

2. Change user name ———— to CCC

It is usually in this link that a restart cannot be re-logged because of an error, so this step must be in order to

     (1) Modify the Sudoer file

We give the name we want to change in advance to the higher permissions to prevent the process of modifying the following file has insufficient permissions

      

      

    (2) Modify the shadow file

This file stores the contents of the login-related content format as follows:

Username:passwd:lastchg:min:max:warn:inactive:expire:flag

Login : encrypted password : Last modified: Minimum time interval: maximum time interval: Warning Time: Inactivity time : expiry time : flag

We need to change the login name:

(3) Modify the start directory

The user starts the directory, contains the user-related configuration information, we want to match the two

    (4) Modify the passwd file

The passwd file content format is as follows:

User name: Password: uid:gid: User description: Home directory: Login Shell

We changed the username, the home directory, and so on to a new name.

(5) If we also want to modify the group under which the original user's file belongs:

We can also change the old user group in the/etc/group file to a new user group

(6) Finally, re-enter the/etc/sudoer file, the user name AAA will be deleted

      

Reboot and login again, we will find that the username and hostname have been successfully changed.

change user name and hostname under Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.