How do I change my username?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Some time ago when I installed Ubuntu I chose a rather stupid username for my account that I do not want to use anymore.
How do I change this (including the name of my home directory, and the name in the terminal) without loosing settings for applications?
How do I keep permissions and my keys for various authentification (e.g. email, SSH, GPG and more)?
What settings could possibly get lost if I changed my username?
permissions keyrings gnupg ssh user-profile
add a comment |
Some time ago when I installed Ubuntu I chose a rather stupid username for my account that I do not want to use anymore.
How do I change this (including the name of my home directory, and the name in the terminal) without loosing settings for applications?
How do I keep permissions and my keys for various authentification (e.g. email, SSH, GPG and more)?
What settings could possibly get lost if I changed my username?
permissions keyrings gnupg ssh user-profile
add a comment |
Some time ago when I installed Ubuntu I chose a rather stupid username for my account that I do not want to use anymore.
How do I change this (including the name of my home directory, and the name in the terminal) without loosing settings for applications?
How do I keep permissions and my keys for various authentification (e.g. email, SSH, GPG and more)?
What settings could possibly get lost if I changed my username?
permissions keyrings gnupg ssh user-profile
Some time ago when I installed Ubuntu I chose a rather stupid username for my account that I do not want to use anymore.
How do I change this (including the name of my home directory, and the name in the terminal) without loosing settings for applications?
How do I keep permissions and my keys for various authentification (e.g. email, SSH, GPG and more)?
What settings could possibly get lost if I changed my username?
permissions keyrings gnupg ssh user-profile
permissions keyrings gnupg ssh user-profile
edited Dec 16 '14 at 15:48
Mateo
7,43385073
7,43385073
asked Apr 8 '11 at 8:25
TakkatTakkat
109k37254379
109k37254379
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod
tool.
To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and sudo su -
to become true root (as opposed to sudo -s
, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username
, look for the matching PID and kill them by kill PID-number
.
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname
or you can change the file contents with sed -i.bak 's/*oldname*/*newname*/g' *list of files*
It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). To get around this:
Login with your old credentials and add a new user, e.g. "temporary" in TTY1:
sudo adduser temporary
set the password.
Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command
exit
. - Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit
(until you get the login prompt) - Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary
10
This is unfortunately not true for different configuration files under $HOME, try running something likegrep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.
– arrange
Apr 8 '11 at 9:17
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
For those with an encrypted home folder, you'll have to edit/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.
– raphael
Jan 22 '16 at 21:57
2
sudo usermod -d /home/edge -m edge
yields:usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.
– empedokles
Oct 13 '16 at 10:50
2
@JTC never editsudoers
with plainnano
. Always usevisudo
.
– styrofoam fly
Jan 4 '18 at 11:09
|
show 7 more comments
To put it all together:
- At the start screen press Ctrl+Alt+F1.
- Log in using your username and password.
Set a password for the "root" account.
sudo passwd root
Log out.
exit
Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.
usermod -l <newname> -d /home/<newname> -m <oldname>
Change the group name to the new name that you want.
groupmod -n <newgroup> <oldgroup>
Lock the "root" account.
passwd -l root
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using
ecryptfs-recover-private
and edit<mountpoint>/.ecryptfs/Private.mnt
to reflect your new home directory.
Log out.
exit
Press Ctrl+Alt+F7.
And now you can log in using your new username.
6
If afterusermod -l
you get auser <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) usingps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you cankill <processno>
.
– RedPixel
Sep 30 '15 at 8:46
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
|
show 4 more comments
Restart in recovery mode and go to the root prompt shell ("Drop to root shell prompt")
First remount the root
mount -o remount,rw /
To change the username and home folder name,
usermod -l <newname> -d /home/<newname> -m <oldname>
For group name,
groupmod -n <newgroup> <oldgroup>
1
when I useusermod -l <newname> -d /home/<newname> -m <oldname>
this gives me errorusermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10
– Waqas
Nov 24 '13 at 13:48
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
add a comment |
(Using Ubuntu 13.10, 14.04, 16.04) Click on the "System Settings" icon. Then click on "User Accounts". Your administrator account should be displayed. Click on the "Unlock" button. Enter your user password as requested to allow changes to your account. Once unlocked, you can click on your old User name that you wish to change and type in a new User name to replace it. When you have typed in the new name, click on the "Lock" button to make the change permanent. Restart Ubuntu.
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
add a comment |
When receiving usermod: can't change /etc/password
just run the following commands:
In the root recovery console run:
mount -o remount,rw /
Then rerun:
usermod -l <newname> -d /home/<newname> -m <oldname>
add a comment |
when you do usermod -l <newname> -d /home/<newname> -m <oldname>
you will get
useradd: can't change /etc/passwd
error message to avoid this just add sudo --
to above command like
sudo -- usermod -l <newname> -d /home/<newname> -m <oldname>
and
sudo -- groupmod -n <newgroup> <oldgroup>
add a comment |
Since not all the PCs have the usermod
app you can do it manually. As of root open /etc/passwd
to edit:
sudo vim /etc/passwd
and change the user's name at the beginning of a line:
user:x:500:501:username:home/user:/bin/bash
to:
newuser:x:500:501:username:home/user:/bin/bash
then if you worked of root just login, and if you have been logged in to user
, logoff, and relogin.
I tried this way (before I discovered theusermod
command) and the user's password is no longer accepted.
– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
It's Ubuntu! If it doesn't haveusermod
your install is broken as it is part of thepasswd
package, which is required.
– Auspex
Mar 6 '17 at 14:10
add a comment |
protected by heemayl Nov 19 '15 at 10:38
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod
tool.
To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and sudo su -
to become true root (as opposed to sudo -s
, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username
, look for the matching PID and kill them by kill PID-number
.
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname
or you can change the file contents with sed -i.bak 's/*oldname*/*newname*/g' *list of files*
It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). To get around this:
Login with your old credentials and add a new user, e.g. "temporary" in TTY1:
sudo adduser temporary
set the password.
Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command
exit
. - Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit
(until you get the login prompt) - Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary
10
This is unfortunately not true for different configuration files under $HOME, try running something likegrep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.
– arrange
Apr 8 '11 at 9:17
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
For those with an encrypted home folder, you'll have to edit/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.
– raphael
Jan 22 '16 at 21:57
2
sudo usermod -d /home/edge -m edge
yields:usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.
– empedokles
Oct 13 '16 at 10:50
2
@JTC never editsudoers
with plainnano
. Always usevisudo
.
– styrofoam fly
Jan 4 '18 at 11:09
|
show 7 more comments
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod
tool.
To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and sudo su -
to become true root (as opposed to sudo -s
, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username
, look for the matching PID and kill them by kill PID-number
.
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname
or you can change the file contents with sed -i.bak 's/*oldname*/*newname*/g' *list of files*
It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). To get around this:
Login with your old credentials and add a new user, e.g. "temporary" in TTY1:
sudo adduser temporary
set the password.
Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command
exit
. - Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit
(until you get the login prompt) - Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary
10
This is unfortunately not true for different configuration files under $HOME, try running something likegrep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.
– arrange
Apr 8 '11 at 9:17
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
For those with an encrypted home folder, you'll have to edit/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.
– raphael
Jan 22 '16 at 21:57
2
sudo usermod -d /home/edge -m edge
yields:usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.
– empedokles
Oct 13 '16 at 10:50
2
@JTC never editsudoers
with plainnano
. Always usevisudo
.
– styrofoam fly
Jan 4 '18 at 11:09
|
show 7 more comments
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod
tool.
To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and sudo su -
to become true root (as opposed to sudo -s
, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username
, look for the matching PID and kill them by kill PID-number
.
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname
or you can change the file contents with sed -i.bak 's/*oldname*/*newname*/g' *list of files*
It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). To get around this:
Login with your old credentials and add a new user, e.g. "temporary" in TTY1:
sudo adduser temporary
set the password.
Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command
exit
. - Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit
(until you get the login prompt) - Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod
tool.
To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and sudo su -
to become true root (as opposed to sudo -s
, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username
, look for the matching PID and kill them by kill PID-number
.
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname
or you can change the file contents with sed -i.bak 's/*oldname*/*newname*/g' *list of files*
It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). To get around this:
Login with your old credentials and add a new user, e.g. "temporary" in TTY1:
sudo adduser temporary
set the password.
Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command
exit
. - Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit
(until you get the login prompt) - Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary
edited Mar 23 '18 at 12:08
muru
1
1
answered Apr 8 '11 at 8:48
EgilEgil
10.9k23546
10.9k23546
10
This is unfortunately not true for different configuration files under $HOME, try running something likegrep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.
– arrange
Apr 8 '11 at 9:17
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
For those with an encrypted home folder, you'll have to edit/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.
– raphael
Jan 22 '16 at 21:57
2
sudo usermod -d /home/edge -m edge
yields:usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.
– empedokles
Oct 13 '16 at 10:50
2
@JTC never editsudoers
with plainnano
. Always usevisudo
.
– styrofoam fly
Jan 4 '18 at 11:09
|
show 7 more comments
10
This is unfortunately not true for different configuration files under $HOME, try running something likegrep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.
– arrange
Apr 8 '11 at 9:17
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
For those with an encrypted home folder, you'll have to edit/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.
– raphael
Jan 22 '16 at 21:57
2
sudo usermod -d /home/edge -m edge
yields:usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.
– empedokles
Oct 13 '16 at 10:50
2
@JTC never editsudoers
with plainnano
. Always usevisudo
.
– styrofoam fly
Jan 4 '18 at 11:09
10
10
This is unfortunately not true for different configuration files under $HOME, try running something like
grep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.– arrange
Apr 8 '11 at 9:17
This is unfortunately not true for different configuration files under $HOME, try running something like
grep -IRFl /home/username ~
and you will see how many references to your home directory are stored there.– arrange
Apr 8 '11 at 9:17
1
1
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
Was a simple fix -- Just had to use the User Accounts editor in unity, followed by restart.
– Steve Koch
Feb 24 '14 at 17:29
5
5
For those with an encrypted home folder, you'll have to edit
/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.– raphael
Jan 22 '16 at 21:57
For those with an encrypted home folder, you'll have to edit
/home/.ecryptfs/oldusername/.ecryptfs/Private.mnt
to point to your new home folder, else you won't be able to login via Unity.– raphael
Jan 22 '16 at 21:57
2
2
sudo usermod -d /home/edge -m edge
yields: usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.– empedokles
Oct 13 '16 at 10:50
sudo usermod -d /home/edge -m edge
yields: usermod: Directory /home/empedokles could not be renamed in /home/edge
i.e. step 4 won't work.– empedokles
Oct 13 '16 at 10:50
2
2
@JTC never edit
sudoers
with plain nano
. Always use visudo
.– styrofoam fly
Jan 4 '18 at 11:09
@JTC never edit
sudoers
with plain nano
. Always use visudo
.– styrofoam fly
Jan 4 '18 at 11:09
|
show 7 more comments
To put it all together:
- At the start screen press Ctrl+Alt+F1.
- Log in using your username and password.
Set a password for the "root" account.
sudo passwd root
Log out.
exit
Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.
usermod -l <newname> -d /home/<newname> -m <oldname>
Change the group name to the new name that you want.
groupmod -n <newgroup> <oldgroup>
Lock the "root" account.
passwd -l root
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using
ecryptfs-recover-private
and edit<mountpoint>/.ecryptfs/Private.mnt
to reflect your new home directory.
Log out.
exit
Press Ctrl+Alt+F7.
And now you can log in using your new username.
6
If afterusermod -l
you get auser <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) usingps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you cankill <processno>
.
– RedPixel
Sep 30 '15 at 8:46
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
|
show 4 more comments
To put it all together:
- At the start screen press Ctrl+Alt+F1.
- Log in using your username and password.
Set a password for the "root" account.
sudo passwd root
Log out.
exit
Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.
usermod -l <newname> -d /home/<newname> -m <oldname>
Change the group name to the new name that you want.
groupmod -n <newgroup> <oldgroup>
Lock the "root" account.
passwd -l root
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using
ecryptfs-recover-private
and edit<mountpoint>/.ecryptfs/Private.mnt
to reflect your new home directory.
Log out.
exit
Press Ctrl+Alt+F7.
And now you can log in using your new username.
6
If afterusermod -l
you get auser <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) usingps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you cankill <processno>
.
– RedPixel
Sep 30 '15 at 8:46
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
|
show 4 more comments
To put it all together:
- At the start screen press Ctrl+Alt+F1.
- Log in using your username and password.
Set a password for the "root" account.
sudo passwd root
Log out.
exit
Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.
usermod -l <newname> -d /home/<newname> -m <oldname>
Change the group name to the new name that you want.
groupmod -n <newgroup> <oldgroup>
Lock the "root" account.
passwd -l root
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using
ecryptfs-recover-private
and edit<mountpoint>/.ecryptfs/Private.mnt
to reflect your new home directory.
Log out.
exit
Press Ctrl+Alt+F7.
And now you can log in using your new username.
To put it all together:
- At the start screen press Ctrl+Alt+F1.
- Log in using your username and password.
Set a password for the "root" account.
sudo passwd root
Log out.
exit
Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.
usermod -l <newname> -d /home/<newname> -m <oldname>
Change the group name to the new name that you want.
groupmod -n <newgroup> <oldgroup>
Lock the "root" account.
passwd -l root
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using
ecryptfs-recover-private
and edit<mountpoint>/.ecryptfs/Private.mnt
to reflect your new home directory.
Log out.
exit
Press Ctrl+Alt+F7.
And now you can log in using your new username.
edited Nov 19 '15 at 8:30
hg8
9,992125591
9,992125591
answered Jul 6 '13 at 9:43
Valentin UvegesValentin Uveges
1,119185
1,119185
6
If afterusermod -l
you get auser <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) usingps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you cankill <processno>
.
– RedPixel
Sep 30 '15 at 8:46
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
|
show 4 more comments
6
If afterusermod -l
you get auser <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) usingps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you cankill <processno>
.
– RedPixel
Sep 30 '15 at 8:46
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
6
6
If after
usermod -l
you get a user <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) using ps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you can kill <processno>
.– RedPixel
Sep 30 '15 at 8:46
If after
usermod -l
you get a user <oldname> is currently used by process <processno>
, you can find that process (probably a daemon, or tmux/screen) using ps aux | grep <processno>
. You might want to gracefully stop that process, otherwise you can kill <processno>
.– RedPixel
Sep 30 '15 at 8:46
1
1
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
Thank you for putting this comment together. It was very useful. Two things that might be mentioned though. After step 4 I rebooted so I wouldn't get error messages at step 6. Also, after this process is complete, the /etc/passwd file will have and ID comment matching the old username. This will cause the login screen to display the old login name. I couldn't find a decent way to fix it from the command line, but I did fix it by logging into the user account, going to the account settings and changing the "Login Name" to the username. This updated the /etc/passwd file and fixed the problem.
– Jibbers
Mar 28 '16 at 17:17
1
1
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
This is the most easy and fool-proof way to do it. It's better reboot after step 4 as @Jibbers suggested.
– Yerke
Apr 8 '16 at 5:45
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
I'd mention that the "bookmarks in the File browser windows" are now pointing to the old folders, so I have to delete those bookmarks.
– ollydbg23
Jun 4 '16 at 8:47
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
Won't work. If you press Ctrl+Alt+F1 at the beginning it's trying to log in into the newly created user which it won't allow.
– empedokles
Oct 13 '16 at 8:54
|
show 4 more comments
Restart in recovery mode and go to the root prompt shell ("Drop to root shell prompt")
First remount the root
mount -o remount,rw /
To change the username and home folder name,
usermod -l <newname> -d /home/<newname> -m <oldname>
For group name,
groupmod -n <newgroup> <oldgroup>
1
when I useusermod -l <newname> -d /home/<newname> -m <oldname>
this gives me errorusermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10
– Waqas
Nov 24 '13 at 13:48
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
add a comment |
Restart in recovery mode and go to the root prompt shell ("Drop to root shell prompt")
First remount the root
mount -o remount,rw /
To change the username and home folder name,
usermod -l <newname> -d /home/<newname> -m <oldname>
For group name,
groupmod -n <newgroup> <oldgroup>
1
when I useusermod -l <newname> -d /home/<newname> -m <oldname>
this gives me errorusermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10
– Waqas
Nov 24 '13 at 13:48
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
add a comment |
Restart in recovery mode and go to the root prompt shell ("Drop to root shell prompt")
First remount the root
mount -o remount,rw /
To change the username and home folder name,
usermod -l <newname> -d /home/<newname> -m <oldname>
For group name,
groupmod -n <newgroup> <oldgroup>
Restart in recovery mode and go to the root prompt shell ("Drop to root shell prompt")
First remount the root
mount -o remount,rw /
To change the username and home folder name,
usermod -l <newname> -d /home/<newname> -m <oldname>
For group name,
groupmod -n <newgroup> <oldgroup>
edited Dec 5 '13 at 12:18
Eric Carvalho
42.6k17118148
42.6k17118148
answered Apr 8 '11 at 9:23
karthick87karthick87
50.3k54167218
50.3k54167218
1
when I useusermod -l <newname> -d /home/<newname> -m <oldname>
this gives me errorusermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10
– Waqas
Nov 24 '13 at 13:48
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
add a comment |
1
when I useusermod -l <newname> -d /home/<newname> -m <oldname>
this gives me errorusermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10
– Waqas
Nov 24 '13 at 13:48
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
1
1
when I use
usermod -l <newname> -d /home/<newname> -m <oldname>
this gives me error usermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10– Waqas
Nov 24 '13 at 13:48
when I use
usermod -l <newname> -d /home/<newname> -m <oldname>
this gives me error usermod: user oldusername is currently used by process 3170
and if I kill the process still it gives me the same error. using ubuntu 13.10– Waqas
Nov 24 '13 at 13:48
4
4
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!! I followed this procedure and it sent me for a wild 2 hour ride... The only way to recover is to perform this procedure again and put the original (disliked) name back in. The problem you will have is "Cannot chdir into mount point"
– Mike
Oct 28 '16 at 12:21
add a comment |
(Using Ubuntu 13.10, 14.04, 16.04) Click on the "System Settings" icon. Then click on "User Accounts". Your administrator account should be displayed. Click on the "Unlock" button. Enter your user password as requested to allow changes to your account. Once unlocked, you can click on your old User name that you wish to change and type in a new User name to replace it. When you have typed in the new name, click on the "Lock" button to make the change permanent. Restart Ubuntu.
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
add a comment |
(Using Ubuntu 13.10, 14.04, 16.04) Click on the "System Settings" icon. Then click on "User Accounts". Your administrator account should be displayed. Click on the "Unlock" button. Enter your user password as requested to allow changes to your account. Once unlocked, you can click on your old User name that you wish to change and type in a new User name to replace it. When you have typed in the new name, click on the "Lock" button to make the change permanent. Restart Ubuntu.
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
add a comment |
(Using Ubuntu 13.10, 14.04, 16.04) Click on the "System Settings" icon. Then click on "User Accounts". Your administrator account should be displayed. Click on the "Unlock" button. Enter your user password as requested to allow changes to your account. Once unlocked, you can click on your old User name that you wish to change and type in a new User name to replace it. When you have typed in the new name, click on the "Lock" button to make the change permanent. Restart Ubuntu.
(Using Ubuntu 13.10, 14.04, 16.04) Click on the "System Settings" icon. Then click on "User Accounts". Your administrator account should be displayed. Click on the "Unlock" button. Enter your user password as requested to allow changes to your account. Once unlocked, you can click on your old User name that you wish to change and type in a new User name to replace it. When you have typed in the new name, click on the "Lock" button to make the change permanent. Restart Ubuntu.
edited Sep 6 '16 at 6:31
answered Jul 7 '14 at 22:45
ChicodoodooChicodoodoo
10114
10114
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
add a comment |
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
1
1
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
This did not change the username for me, just the name. The old username still appears in the terminal, and as the home directory and group (even after rebooting).
– DougC
Mar 7 '18 at 19:30
add a comment |
When receiving usermod: can't change /etc/password
just run the following commands:
In the root recovery console run:
mount -o remount,rw /
Then rerun:
usermod -l <newname> -d /home/<newname> -m <oldname>
add a comment |
When receiving usermod: can't change /etc/password
just run the following commands:
In the root recovery console run:
mount -o remount,rw /
Then rerun:
usermod -l <newname> -d /home/<newname> -m <oldname>
add a comment |
When receiving usermod: can't change /etc/password
just run the following commands:
In the root recovery console run:
mount -o remount,rw /
Then rerun:
usermod -l <newname> -d /home/<newname> -m <oldname>
When receiving usermod: can't change /etc/password
just run the following commands:
In the root recovery console run:
mount -o remount,rw /
Then rerun:
usermod -l <newname> -d /home/<newname> -m <oldname>
edited Jul 30 '14 at 13:08
chaos
19.9k86068
19.9k86068
answered Jul 30 '14 at 12:14
user1511576user1511576
412
412
add a comment |
add a comment |
when you do usermod -l <newname> -d /home/<newname> -m <oldname>
you will get
useradd: can't change /etc/passwd
error message to avoid this just add sudo --
to above command like
sudo -- usermod -l <newname> -d /home/<newname> -m <oldname>
and
sudo -- groupmod -n <newgroup> <oldgroup>
add a comment |
when you do usermod -l <newname> -d /home/<newname> -m <oldname>
you will get
useradd: can't change /etc/passwd
error message to avoid this just add sudo --
to above command like
sudo -- usermod -l <newname> -d /home/<newname> -m <oldname>
and
sudo -- groupmod -n <newgroup> <oldgroup>
add a comment |
when you do usermod -l <newname> -d /home/<newname> -m <oldname>
you will get
useradd: can't change /etc/passwd
error message to avoid this just add sudo --
to above command like
sudo -- usermod -l <newname> -d /home/<newname> -m <oldname>
and
sudo -- groupmod -n <newgroup> <oldgroup>
when you do usermod -l <newname> -d /home/<newname> -m <oldname>
you will get
useradd: can't change /etc/passwd
error message to avoid this just add sudo --
to above command like
sudo -- usermod -l <newname> -d /home/<newname> -m <oldname>
and
sudo -- groupmod -n <newgroup> <oldgroup>
edited Nov 19 '15 at 10:37
heemayl
68.4k11145216
68.4k11145216
answered Aug 6 '13 at 6:12
Sriraj HebbarSriraj Hebbar
1
1
add a comment |
add a comment |
Since not all the PCs have the usermod
app you can do it manually. As of root open /etc/passwd
to edit:
sudo vim /etc/passwd
and change the user's name at the beginning of a line:
user:x:500:501:username:home/user:/bin/bash
to:
newuser:x:500:501:username:home/user:/bin/bash
then if you worked of root just login, and if you have been logged in to user
, logoff, and relogin.
I tried this way (before I discovered theusermod
command) and the user's password is no longer accepted.
– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
It's Ubuntu! If it doesn't haveusermod
your install is broken as it is part of thepasswd
package, which is required.
– Auspex
Mar 6 '17 at 14:10
add a comment |
Since not all the PCs have the usermod
app you can do it manually. As of root open /etc/passwd
to edit:
sudo vim /etc/passwd
and change the user's name at the beginning of a line:
user:x:500:501:username:home/user:/bin/bash
to:
newuser:x:500:501:username:home/user:/bin/bash
then if you worked of root just login, and if you have been logged in to user
, logoff, and relogin.
I tried this way (before I discovered theusermod
command) and the user's password is no longer accepted.
– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
It's Ubuntu! If it doesn't haveusermod
your install is broken as it is part of thepasswd
package, which is required.
– Auspex
Mar 6 '17 at 14:10
add a comment |
Since not all the PCs have the usermod
app you can do it manually. As of root open /etc/passwd
to edit:
sudo vim /etc/passwd
and change the user's name at the beginning of a line:
user:x:500:501:username:home/user:/bin/bash
to:
newuser:x:500:501:username:home/user:/bin/bash
then if you worked of root just login, and if you have been logged in to user
, logoff, and relogin.
Since not all the PCs have the usermod
app you can do it manually. As of root open /etc/passwd
to edit:
sudo vim /etc/passwd
and change the user's name at the beginning of a line:
user:x:500:501:username:home/user:/bin/bash
to:
newuser:x:500:501:username:home/user:/bin/bash
then if you worked of root just login, and if you have been logged in to user
, logoff, and relogin.
edited May 11 '16 at 18:26
answered Dec 16 '14 at 13:15
Малъ СкрылевъМалъ Скрылевъ
234213
234213
I tried this way (before I discovered theusermod
command) and the user's password is no longer accepted.
– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
It's Ubuntu! If it doesn't haveusermod
your install is broken as it is part of thepasswd
package, which is required.
– Auspex
Mar 6 '17 at 14:10
add a comment |
I tried this way (before I discovered theusermod
command) and the user's password is no longer accepted.
– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
It's Ubuntu! If it doesn't haveusermod
your install is broken as it is part of thepasswd
package, which is required.
– Auspex
Mar 6 '17 at 14:10
I tried this way (before I discovered the
usermod
command) and the user's password is no longer accepted.– Ben Voigt
May 11 '16 at 17:51
I tried this way (before I discovered the
usermod
command) and the user's password is no longer accepted.– Ben Voigt
May 11 '16 at 17:51
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
@BenVoigt not all the pcs have the usermod
– Малъ Скрылевъ
May 11 '16 at 18:25
2
2
It's Ubuntu! If it doesn't have
usermod
your install is broken as it is part of the passwd
package, which is required.– Auspex
Mar 6 '17 at 14:10
It's Ubuntu! If it doesn't have
usermod
your install is broken as it is part of the passwd
package, which is required.– Auspex
Mar 6 '17 at 14:10
add a comment |
protected by heemayl Nov 19 '15 at 10:38
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?