How to change your username on Linux with the command-line. This is very easy indeed.

Posted: July 25, 2013. At: 7:47 PM. This was 4 years ago. Post ID: 6037
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

To change the username of an already created account on a UNIX or Linux system just follow this simple guide.

I am changing the username mailman to mailman2. Firstly; open the /etc/shadow file with the VIM editor.

homer@deep-thought ~ % sudo vim.tiny /etc/shadow

Then find the entry you are after and edit the name and then press ESC and type :wq to save and quit the editor.

mailman2:$6$T2nKWbz8$0O05diwqpTCRswkGFkMrFOsg0A5AvAvpuODT3hEiM7LYnuhNlJlgsSwCg1mS/EPi.8445D1o.qgvzf5tMVExD1:15911:0:99999:7:::

Then open the /etc/passwd file and change that value as well.

homer@deep-thought ~ % sudo vim.tiny /etc/passwd

Leave the /home folder value as is of course; but this will work very well to enable you to

mailman2:x:1003:1003::/home/mailman:/bin/bash

After all of this you can use the /bin/login command to test whether the newly renamed account works or not. And it worked perfectly.

homer@deep-thought /home % sudo login                 
deep-thought login: mailman2
Password: 
Last login: Thu Jul 25 19:37:06 EST 2013 on pts/0
Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-26-generic x86_64)
 
Welcome to Linux Mint
 * Documentation:  http://www.linuxmint.com
mailman2@deep-thought ~ $ pwd
/home/mailman

No comments have been made. Use this form to start the conversation :)

Leave a Reply