LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2008, 03:26 AM   #1
Ashhere
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Rep: Reputation: 15
Question Change user name


Hi,

Can anyone tell me how to change my user name?
Someone suggested to use the usermod command as:

usermod -l login_name user_name
login_name being the new user name.

But,
usermod : unable to lock password file
is the output.
 
Old 08-05-2008, 03:34 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 528

Rep: Reputation: 78
Do you want to change your user name or your login?

Last edited by angel115; 08-05-2008 at 03:40 AM.
 
Old 08-05-2008, 03:35 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Are you running this command as root? If you're running on Ubuntu you can do
Code:
sudo usermod -l new_name -d /home/new_name -m old_name
on other system you have to do su - and enter the root password when prompted to get root privileges. Also - as shown in my example - you can change the home directory as well, since it is not done automatically. The -d option specifies the new home dir and the -m option is meant to move the content of the old home directory to the new one. See man usermod for future reference.
 
Old 08-05-2008, 03:38 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Personally, I just do:

sudo -s
vipw
mv /home/olduser /home/newuser
# the chown below is only necessary of UID or GID change
chown -R newuser:newgroup /home/newuser

The commands like usermod and useradd, etc. are good for scripts.

Add "sudo" in front of the usermod command if you are not root, or become root with either sudo or su, and then run the command.

You also need to move the users home directory (so add -the -m option to usermod) and you need to change all the file and directory permissions from the old user to the new user.

[ edit: again only need to change UID/GID on files if UID/GID if you change UID/GID in passwd file. ]

Last edited by Mr. C.; 08-05-2008 at 12:07 PM.
 
Old 08-05-2008, 03:48 AM   #5
Ashhere
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Original Poster
Rep: Reputation: 15
Thumbs up Thanks

Thanks everyone.
I am new to linux and didnt know had to log in as root.
 
Old 08-05-2008, 05:12 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Quote:
Originally Posted by Mr. C. View Post
Personally, I just do:

sudo -s
vipw
mv /home/olduser /home/newuser
chown -R newuser:newgroup /home/newuser

The commands like usermod and useradd, etc. are good for scripts.

Add "sudo" in front of the usermod command if you are not root, or become root with either sudo or su, and then run the command.

You also need to move the users home directory (so add -the -m option to usermod) and you need to change all the file and directory permissions from the old user to the new user.
If you don't want to use usermod, why not just edit /etc/passwd, changing your username field and the home page field. This would retain the UID which might be in tar backups, or external drives. If you keep your old UID, you don't need to run chown on your home directory.
 
Old 08-05-2008, 12:05 PM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Yes, you are right of course. I don't know what made me think UID/GID was changing here too.
 
Old 08-06-2008, 08:50 AM   #8
Ashhere
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Original Poster
Rep: Reputation: 15
Thumbs down The thing has worsened!!

I tried changing the username. But now there is another problem.
When I try to log in,a dialog says:

"User's $HOME/.dmrc file is being ignored. This prevents the default session and language from being saved. Fild should be owned by the user and have 644 permissions. User's $HOME directory must be owned by user and not writable by other users.

and when I hit the OK button, it says:

"Your session only lasted less than 10 seconds. If you have not logged out yourself, this could mean that there is some installation problem or that you may be out of disk space. Try logging in with some of the filesafe sessions to see if you can fix this problem."

I logged in in filesale GNOME but the dialogs appear as such again.
What shall I do?
Should I reinstall ubuntu or what? And if to reinstall it too, how?
and can u explain about 644 permissions too?
 
Old 08-06-2008, 02:56 PM   #9
junpa
Member
 
Registered: Aug 2008
Location: Northern Hemisphere
Distribution: Slackware, OpenVMS, fbsd
Posts: 50

Rep: Reputation: 16
Ashhere,

well my first question would be...which method did you use to change the username?

and which user are you trying to log in as? old? new?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i change to super user then revert back to ordinary user ,using shell script? wrapster Solaris / OpenSolaris 6 03-18-2009 04:37 AM
samba(global security=user) useful tools for client.ex: user change password. hocheetiong Linux - Newbie 1 03-18-2008 10:20 AM
Help! Cannot Add a User to User Manager or Change Root Password lennysokol Linux - General 2 06-25-2005 10:59 AM
what is the command to make a user change their password after creating a new user? naweenio Linux - Newbie 7 01-05-2005 08:07 AM
How do I change the cursors globaly for a user? and how do I change them in the E-WM? enigma Z Linux - Software 1 09-18-2004 04:59 PM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration