Changing user name

Ed Wilts ewilts at ewilts.org
Fri Dec 17 17:24:11 UTC 2004


On Fri, Dec 17, 2004 at 03:10:40PM +0100, Maciek R. wrote:
> how do I change my current user name on Linux? I there a way to rename
> it (with all folders and the whole stuf)?

Since you've already gotten 2 bad answers, here's my approach:

1.  Assume OLDUSER is the old name
2.  Assume NEWUSER is the new name

# /usr/sbin/groupmod -n $NEWUSER $OLDUSER
# /usr/sbin/usermod -l $NEWUSER -d /home/$NEWUSER $OLDUSER
# mv /home/$OLDUSER /home/$NEWUSER
# mv /var/spool/cron/$OLDUSER /var/spool/cron/$NEWUSER

If you have a Samba entry, you need to update this too:

# cp /etc/smbpasswd /etc/smbpasswd.backup
# sed "s/^$OLDUSER:/$NEWUSER:/" /etc/smbpasswd > /etc/smbpasswd.tmp
# mv /etc/smbpasswd.tmp /etc/smbpasswd

-- 
Ed Wilts, RHCE
Mounds View, MN, USA
mailto:ewilts at ewilts.org
Member #1, Red Hat Community Ambassador Program




More information about the users mailing list