I am currently logged in into a CentOS server and I would like to change my home directory from /home/myuserName/
to /var/www/html/
I tried the below command :
> sudo usermod -d /var/www/html myuserName
But this gives me an error:
usermod: user myUserName is currently logged in
Best Answer
short answer : you can't.
long answer:
HOME
dir is set in/etc/passwd
, 6th field. It is read upon login; your shell is started with this home dir.The proper way to change home dir for joe is :
usermod -d /new/home joe
to change home dir for subsequent session.Once session is run, you must do two things:
$HOME
to change home dir for session (to be repeated on all active session).sudo vipw
to edit home dir for next sessionAlso, be aware you might have an issue with permissions/ownership on
/var/www/html
.