I have a problem. When I enter a Ubuntu machine, I see this messages:

Could not chdir to home directory /home/root: No such file or directory
/usr/bin/xauth:  error in locking authority file /home/root/.Xauthority

When I make whoami, I receive the answer: root

but no directory /home/root exist.

When I am trying to create a new user: adduser blabla, I receive this error:

adduser: Only root may add a user or group to the system.

When I am trying to create it in a different way: useradd -m blabla, I receive:

useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.

someone can explain me what went wrong?

Thanks in Advance

  • 2
    Are you connecting to a remote machine via ssh? Or is this a local machine? ... There typically is no /home/root directory. The root home is typically located at /root From the error messages, it would appear that you are not the root user for the system. Did you create a user named root? – RubberStamp Oct 30 '17 at 16:01
  • I did log in to a machine. It may be indeed a root user created, but not by me - I am checking it now – Eli Borodach Oct 30 '17 at 16:07
  • Can I remove it safely using "sudo userdel root"? – Eli Borodach Oct 30 '17 at 16:17
  • "Can I remove it safely using "sudo userdel root"?" No it hurts..., if you dont need root just block root user with the command passwd -l root (l = lowercase L) .... and if you have ssh, change PermitRootLogin to no for guarantee... If the actual root user is not working properly edit /etc/passwd and change UID and GID to 0 ... – Luciano Andress Martini Oct 30 '17 at 16:40
  • 1
    What is the output of cat /etc/passwd | grep root ... it should look almost identical to this: root:x:0:0:root:/root:/bin/bash – RubberStamp Oct 30 '17 at 17:11

Try to figure out what is your current id (by issuing id command in shell), user root should have uid=0. If your uid is different from 0, you is not under privileged account. Also, what`s happening if you issue command sudo -i ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.