Solved

change user name

Posted on 2004-03-21
8
490 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS CLI - Issue with name display 2 73
route 2 traffic streams on single NIC 6 49
Coding C# in Linux 8 71
Migrating php-mysql-jquery application to Microsoft Azure Cloud 7 31
Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

832 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