11

good Day

I want to make a change to a user on my CENTOS server. I want to change his default directory. When running the command:

usermod -d /path_to_new_dir david

terminal gives me the following

User david is currently logged in

I closed all ftp sessions which I was engaged into with that user, and I am logged into terminal as root.

How do I run that command and how do I log out the user? As far as I am concerned he is not logged in...

5 Answers5

10

I ran into this. The user was not logged in according to w, but a ps aux | grep username showed an imap process running as the user. The usermod command ran successfully after the imap connection was closed.

slm
  • 369,824
Stephen
  • 203
9

One way to kick the user is by doing the following:

# w
damaya   pts/5     23:20    1.00s  0.00s  0.00s w

As we can see from "w" output, user damaya is logged in on pts/5. Now type:

# fuser -k /dev/pts/5

That will kick the user off and you can now modify their account.

Franz Kafka
  • 328
  • 1
  • 11
3

I would first lock the user account that he will be not abble to log in after you log out him.

passwd -l username

This command will block user.

If he is still logged in then uou can log him out with

skill -KILL -u username

After that you can modify his path to home dir and unlock account with

passwd -u username

B14D3
  • 151
  • 3
2

You could also modify directly the /etc/passwd file.

That way you don't need to logout the user nor stop any process being run by that user.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
kriegu
  • 121
1

I ran into this issue but the user was not really logged in as # w did not return the user name. Rebooting the machine worked fine.

Uthman
  • 351