Change a users Home Directory

I'm on CENTOS and trying to change an existing user's home directory.  I tried usermod, but says that command is bad.  Any other way?
LVL 12
Nathan RileyFounder/CTOAsked:
Who is Participating?
 
farzanjConnect With a Mentor Commented:
/usr/sbin/usermod -d /home/userid userid
0
 
farzanjCommented:
usermod -d /home/userid userid
0
 
Nathan RileyFounder/CTOAuthor Commented:
I did that, but got this error bash: usermod: command not found.  Do I need to do it from a certain location?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
farzanjCommented:
Other easy way is to edit the /etc/passwd file

Manually change the user and change its home directory
0
 
brb6708Commented:
Easy: As root edit /etc/passwd using texteditor and modify Field No 6.
Fields are separated by colon (:)
Entry loks like
username:x:uid:gid:Comment:/home/username:/bin/bash
0
 
farzanjCommented:
You have to the root user to do so or you have to use sudo
0
 
Nathan RileyFounder/CTOAuthor Commented:
heh, tried that before and had some major issues after the edit, would like to do using usermod,  I am logged in as root, but still getting the error: error bash: usermod: command not found
0
 
farzanjCommented:
You became user by doing
su


You should have done
su -

Just guessing because your path is not set for root user
0
All Courses

From novice to tech pro — start learning today.