10

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...

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.

  • 1
    another options pkill -u damaya use -9 for forceful kill – Rahul Patil Aug 22 '13 at 17:45
  • ^That's the answer. Boss! – Anwar Nov 11 '15 at 8:02
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.

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

  • I didn't know skill. ps axf |grep jenkins showed nothing, but the user was supposedly still logged in. Thanks. – android.weasel Mar 4 '14 at 15:56
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.

1

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.

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.