l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2003 Feb 09 14:51

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Can a username be changed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Can a username be changed?

Using vipw or some other tool for editing /etc/passwd is a way to do this.

Be careful in this. Some potential "gotchas":

Often home dirs are namedafter the username. It is a good idea to alter
name of home dir to match new username. Some scripts may do things
"improperly" and do a `whoami` and use this for paths, or assume username
matches /hom/<dirname> when doing shell looped shell scripts...

(Hey kids, dont try this at home)
# cd /home
# for i in * ; do chown ${i}.${i} $i ; done

Also, you may want to grep their homedir "dotfiles" for refs to their old
username. Some apps will redord the user's home dir in env vars and stoe
them in ~/.some.dot.file

If users share apps and have asked others to symlink to stuff they had in
their old dir, then relative links from outside their dir will be broken,
and all absolute path links will be busted.

If you installed other tools that use db generated with the
adduser/useradd scripts, then any username db may "get out of sync by
changing username.

Cron jobs (username based)

If you have filesharing setup with abolute paths (not relative or username
resolvable like samba and netatalk's ~/ or $HOME, then consider changing
those too.

Any .htaccess files that ref specific users by name instead of "require
valid-user" and unwisely use /etc passwd (most of th thime this is not
wise) will ned to be changed.

/var/spool/mail/username ? consider a mail alias and move for new name.

Entries in /etc/groups should be global searched and reolaced to new uid.

As you write, ensure /etc/shadow matches (vipw will likely ask you if you
want to edit shadow after you edit passw if you made changes and are using
shadow passwords.)

You may want to consider ocating files owned by them or named with their
usernamed before enacting changes to help this process:

# find / -name \*USERNAME\* -print > /tmp/USERNAME.named.files.txt
# find / -user USERNAME -print > /tmp/USERNAME.user.owned.files.txt
# find / -group USERNAME -print > /tmp/USERNAME.group.owned.files.txt
# cat /tmp/USERNAME.group.owned.files.txt | sort | uniq -u > \

I'm sure there are other places to check, and hope others will fill in any
holes I have left in omission.

So you can do this -I've done it several times: just be careful and
checkback occasionally with user to make sure all is happy. :-)

(Skip this last step if you are a BOFH.)

(more below)

Bill Kendrick said:
> Is there a way to change a user's login name under Unix?


> Is it safe enough to simply rename their home directory and
> edit their entry in /etc/passwd and /etc/shadow?

Sometimes, but usually, no.

> Or am I dealing with dangerous powers, and would be safe enough
> creating a brand new user and deleting the old one?

You are always dealing with dangerous powers (mr "has a special
relationship with the video frame buffer") but you can manage "dangerous
powers." ;-)


Version: 3.12
GCS/CM$/IT$/LS$/S/O$ !d--(++) !s !a+++(-----) C++$(++++) U++++$(+$) P+$>+++
L+++$(++) E W+++$(+) N+ o K w+$>++>+++ O-@ M+$ V-$>- !PS !PE Y+ PGP++
t@-(++) 5+@ X@ R- tv- b++ DI+++ D+ G--@ e+>++>++++ h(++)>+ r*>? z?
decode: http://www.ebb.org/ungeek/ about: http://www.geekcode.com/geek.html
  Campus IT(/OS Security): Operating Systems Support Specialist Assistant

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.