How to change home folder and all its subfolder

September 17, 2014 2.6k views

I have changed my username from “user” to “newuser”, but when I checked, with :

ls -la

I got that some folder is used in my old name, like this.

drwxr-xr-x 3 root      root  4096 Sep 16 01:35 ..
-rw------- 1 newuser   user 2643 Sep 17 11:25 .bash_history
-rw-r--r-- 1 newuser   user  220 Sep 16 01:06 .bash_logout

I want to change the “user” to “newuser”

Can I do it ?

1 comment
  • If the old username is still appearing, then that means the old user still exists and you’re using a new one. You can use ‘chown’ to take ownership of the files, however the files you listed are user specific and would be better left as-is (unless they are in the wrong user’s home directory)

1 Answer


you can rename the “user” to “newuser” with

usermod -l user -m -d /home/newuser newuser

-m for move-home, -d for new home directory path

If you want to rename the group “user” to “newuser”, you need this command

groupmod -n newuser user

-n for new-name

Have another answer? Share your knowledge.