Solved

change user name

Posted on 2004-03-21
8
485 Views
Last Modified: 2013-12-15
hello...
Can i know how to change user name in linux?
Any command can change user name?
Also, if i change the user name, their mail and ftp account also will be changed?
thx everyone to reply
0
Comment
Question by:newexhsh
8 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 10644416
A change to a user name requires at least:

1) Edit of /etc/passwd, /etc/shadow, /etc/group, & /etc/gshadow

2) Rename /home/old-username /home/new-username

3) Rename of /var/spool/mail/old-username /var/spool/mail/new-username

Other changes may to aliases, virtusertable, Samba, etc may be required.

And yes, the mail and ftp account will typically change when you change the user name.
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 10645657
You can do this quite easily with the usermod command. The usermod command will alter all the system files which need to be changed. Have a look at "man usermode" from a command prompt (without the quotes).
0
 

Author Comment

by:newexhsh
ID: 10649756
Can you give me an example because i am new in linux
thx
0
 
LVL 17

Accepted Solution

by:
owensleftfoot earned 50 total points
ID: 10649961
"usermod -d /home/newusername -m -l newusername username" (without the quotes) would change username to newusername and move the contents of /home/username to /home/newusername. You may still have to create a new mailbox in /var/spool/mail/ by the command "touch /var/spool/mail/newusername" and "chown newusername /var/spool/mail/newusername".
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 10

Expert Comment

by:Mercantilum
ID: 10650740
Just a few remarks:
- don't you have a GUI interface to do the changes, Yast2 or control center... ? (which linux?)
- in the manual editing case (1st answer) use "vipw"  and  "vipw -s" to edit passwd and shadows files - direct edition in some cases may lead to strange results...
0
 

Author Comment

by:newexhsh
ID: 10654810
hello, owensleftfoot
I can run your command sucessfully.
But in "chown that part"
i run
chown -R newusername newusername
and
chown -R newusername:newusername newusername
the group remains unchanged
how can i change it?
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 10656022
You can use "usermod -g newgroup" to change a users initial group.
0
 

Author Comment

by:newexhsh
ID: 10668708
oh....owensleftfoot
you help me alot, thx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now