0

I was renaming home directory user of my another Ubuntu account using terminal:

sudo usermod -d /home/<new_home_directory_name> <another_username>

By mistake, I missed -m option between <directory name> and <user_name>. Now I'm not able to login into that account.

When I login to that user using Ctrl+Alt+F1, pwd returns /. I can see 'Access-Your-Private-Data.desktop' when I do ls in <older_home_directory>.

Let me know how can I recover my account as it is the main account.

1
  • What output do you see for ls /home/* ?
    – ARG
    Commented Nov 7, 2018 at 14:48

4 Answers 4

1

When you forgot the -m option to usermod, you didn't move the home directory at all. You already observed that the old directory is still there and visible from ls, so you can undo your previous change by calling usermod again:

sudo usermod -d /home/<old_home_directory_name> <username>
0

On a terminal you will have / as your home, as you pointed out. So go back there and just change your home in your passwd file...

Ctrl+Alt+F1

sudo vi /etc/passwd

Find your username, the 6th field is your home directory. Set it to your home... e.g. mine is /home/number9. Save and exit that file. Login and be happy.

Note, if you don't know vi/vim, use nano or your favorite editor.

Note further, if your home is encrypted, you will need to follow these instructions. If you are moving it to a new location and not partition, just use the location, not the partition.

6
  • Hi, I did the same and it is working as earlier. But I want to change the name of my 'home' directory. When I try to do that, it changed the name but I'm seeing cross sign on that home directory when seen from another account. And then again I am unable to login to that account. When I logged in using Ctrl+Alt+F1, I can see "Access-Your-Private-Data.desktop" and README.txt file under that home directory. Can't I change the name of my home directory. Commented Nov 8, 2018 at 6:24
  • @GeniusGo you should be able to change the name of your home directory... you would login as your user, sudo vi /etc/passwd, and change the name. Know that you must also change the name of the actual dir. e.g. if your old dir was /home/fred and you want /home/flintstone, you would change it in /etc/passwd and then cd /home ; mv fred flintstone
    – number9
    Commented Nov 8, 2018 at 11:24
  • Then it gives me error: mv: cannot move '<old_directory_name>' to '<new_directory_name>': Device or resource busy Commented Nov 8, 2018 at 17:00
  • @GeniusGo then you are probably in the directory, or something has it open. something like lsof |grep old_directory_name should give you some insight
    – number9
    Commented Nov 8, 2018 at 18:23
  • My old home directory seems to be encrypted with ecryptfs. May be that is one reason it is not allowing me to rename the directory. Commented Nov 10, 2018 at 5:20
0

If I got everything right, you only changed the home-dir in the /etc/passwd. You can rename the home dir: sudo mv /home/<old_home_directory_name> /home/<new_home_directory_name>

-2

Start Ubuntu as root and restore: Press the Shift key during boot to get the grub menu and select a revocery mode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .