Modify the user name and computer name of ubuntu

Source: Internet
Author: User

Yesterday, I switched to a computer with better configuration. My colleagues used the development environment to configure everything. So, I didn't want to reinstall the system. First, I changed the user password:

1. move up and down at startup, select repair mode Ubuntu-x.x.xx.xx-generic (recovery mode), and then press E (yes, select and then press E)

2. Modify the startup parameter and change Ro single to RW single init =/bin/bash.

3. Press Ctrl + X to start the system and enter single mode without a password,

4. Then we can use the passwd command to change the password, because my user name is XXX, so:

Root @ (none):/# passwd xxx

Enter new Unix Password:
Retype new Unix Password:

Enter a new password and start later!

 

Today, let's change the user name and computer name:

It is best not to simply edit/etc/passwd and/etc/group. Linux has corresponding commands to do these dirty things.

It is recommended that you do not perform operations under the current user. It is more appropriate to do this in the recovery mode.
Start the instance, enter recovery mode, and select root shell.

The following occurs during the first step:

Drop to root shell prompt

Run commands

Mount-O remount RW/

 

1. Modify the user name.
Usermod-l new_username-D/home/new_username-M old_username
Use the usermod command to modify user account information.-L specifies the new Logon Name and-D specifies the new home directory, if the-M option is specified at the same time, the contents of the original user's home directory will be moved to the new user's directory, and the original Login User name will be specified.
2. Modify group name
Groupmod-N new_username old_username
The groupmod command is used to modify group information.-N is used to specify a new group name. The original group name is used as the parameter. The default group with the same name as the user is modified here.
3. Change the full name of a user
Chfn-F new_fullname new_username
The chfn command is used to modify the real user name and other related information.-F specifies the new user name, and the user name must be modified as the parameter.
4. other modifications
After changing the user's home directory, some of them depend on the absolute pathProgramYou need to modify it accordingly. Extensions in the Firefox profile path. INI contains the absolute path dependent on the user name. Modify it and open it with vim. Then: % S/old_username/new_username/g, and then: WQ, prefs. if the same processing is done in JS, Firefox can be used normally. Other things do not need to be moved.

 

PS:Commands may be time-consuming because there are a lot of modified files.

 

Modify the computer name:

Modification of/etc/hostname will result sooner or later. As for the problem, I do not know yet. I still need to modify/etc/hosts. Open the/etc/hosts file:
-$ Sudo gedit/etc/hosts

Related Article

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.