1

This question already has an answer here:

First I am logged into root and executed this command:

# sudo su

Then:

# usermod -l lazybug peter

Getting this error:

usermod: user peter is currently used by process 19895

So I have killed the process

# kill 19895

It will come out of root and if I run the same command it will give the same error message. I am really confused and please help.

marked as duplicate by muru, Braiam, karel, pomsky, Eric Carvalho May 29 '18 at 15:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What is the process? – wjandrea May 29 '18 at 2:52
  • I am trying to execute this on SSH session – Shamya U May 29 '18 at 3:35
  • 1
    @wjandrea The process is likely sudo su, which is run by peter. – Chai T. Rex May 29 '18 at 3:54
  • Try exec sudo -i instead of sudo su. – muru May 29 '18 at 3:58
5

You cannot change username while in the session already run by the same user. PID that you mentioned is the terminal you are currently using. You have to log out from current session and log as root user. If you cannot log as root user add another account temporary and log in with it. Then run sudo usermod -l lazybug peter from that account. Make sure new account can run sudo. Run this to add new user with sudo privileges. sudo adduser <username> sudo. This need in case of you cannot log as root.

If you need to change home directory too run this sudo usermod -d /home/newHomeDir -m newUsername

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