How To Change or Rename Username and User ID In Linux? – POFTUT

How To Change or Rename Username and User ID In Linux?

The problem is we want to change the already created user name or user id. As we know there is a lot of configuration those rely on the user id like permissions. We will use usermod command to make this change. Keep in mind this changes will effects system wide.

List User Info

Before starting to big changes we will list users detailed info with cat command like below.

List User Info

List User Info

  • test is our user name for this operation
  • 1000 is the current id of our test user.

Change User Name

We will change username with the following command by providing new username. We will provide the -l option with the new username and old username. In this example we will change username ismail into ali.

  • usermod is command we issue to chage
  • -l ali is the new username
  • ismail is the original username

Change User ID

Another opportunity is changing the user ID. Previously we have listed user information of the ismail . We know that the user id of the ismail is 1000. We will use -u option and the new user id with the user name. In this example we will change the user id of ismail into 1010

  • usermod is command used too
  • -u 1010 is new user id provided for the user
  • ismail is the user whose id will be changed.

Check It Again

After these steps we need to the if there is a problem or everything is OK. We will list user information again with the cat command like below.

  • test2 is new username but home directory stays the same
  • 1010 is the users new id

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)