Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

change user name

Posted on 2004-03-21
8
Medium Priority
?
502 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 17

Accepted Solution

by:
owensleftfoot earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

916 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