Solved

change user name

Posted on 2004-03-21
8
493 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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
 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux boot cd to do hardware report on PC? 3 64
bash file 10 50
PHP error function not working on AWS 10 75
trouble on installing syslog-ng on CentOS 7 7 59
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

828 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