LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-27-2005, 12:29 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Changing a User


Is there a way in Linux that I can change a user name and keep the same password and permissions for that user?

It's a generic user I created for FTP and I would like to change the user name but keep the same password. I also don't want to lose the files folders and permissions.

I did a search here and only found someone wanting to change their forum user name.

Thanks!
 
Old 10-27-2005, 01:00 PM   #2
chemdawg
Member
 
Registered: Jan 2005
Distribution: Mandriva
Posts: 206

Rep: Reputation: 31
not sure about the absolute answer to your question, but you could always create another user, then move the files over to the new user and change all the permissions on everything using

Code:
# chown user:group <files>
that would get you where you want to go eventually. You'd then have to delete the old user.
 
Old 10-27-2005, 01:02 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Haven't tried this, but it looks to be theoretically possible.

Have a look at the man pages for the useradd program. You can specify a UID and GID as options. That may mean you will need to first remove the existing user. But the files he owns should still retain the same UID/GID.

Then just change the password to what you're using now after you have added him.

Warning: Test this first with a user and files you don't care about! (i.e. create a test case.)
 
Old 10-27-2005, 01:17 PM   #4
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
OK - How do I remove this user and all it's associated files and folders so I can start fresh?
 
Old 10-27-2005, 01:43 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Change the user name using the command: usermod
usermod -d /home/new_name -m -l new_name old_name
 
Old 10-27-2005, 02:11 PM   #6
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Quote:
Originally posted by homey
Change the user name using the command: usermod
usermod -d /home/new_name -m -l new_name old_name
Here is what I did:

Old = peostri

New = stricom

Code:
stricom:~# usermod -d /home/stricom -m -l stricom peostri
It still shows peostri when I list the home directory. What section is defined "peostri"& how do I change that?

Code:
stricom:/home# ls
carlos  ftp  laura  stricom
stricom:/home# cd stricom/
stricom:/home/stricom# ls -lh
total 16K
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-26 12:35 chris
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-14 16:42 derek
-rw-r--r--  1 root    root     990 2005-10-26 07:25 readme.txt
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-14 16:42 tim
 
Old 10-27-2005, 08:46 PM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I gave it a try and looks ok to me.
Old_user = fred
New_user = sam
Code:
usermod -d /home/sam -m -l sam fred
chown -R sam:users /home/sam/\.
Using the command: id
it looks like it would be a good idea to add -g for the new user.
usermod sam -g sam

Last edited by homey; 10-27-2005 at 09:06 PM.
 
Old 10-30-2005, 06:46 PM   #8
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Guys - I still show the old group "peostri" when I list the directory. Can someone please tell me how I can change the group that owns this directory.

I want the group to be the same as the user and delete everything anything associated with the old user name "peostri"

Code:
stricom@stricom:~$ ls -lh
total 16K
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-26 12:35 chris
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-14 16:42 derek
-rw-r--r--  1 root    root     990 2005-10-26 07:25 readme.txt
drwxr-xr-x  2 stricom peostri 4.0K 2005-10-14 16:42 tim
 
Old 10-30-2005, 07:11 PM   #9
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
stricom is still part of the peostri group (many Linux distros put each user in their own group by default) so you need to change the name of the peostri group like this
Code:
groupmod -n stricom peostri
 
Old 10-31-2005, 10:26 AM   #10
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
You could use vipw to change the username in the passwd and shadow files, then rename the home directory to the new username. If you don't change the UID in the files, then the user permissions should "automagically" change.
 
Old 10-31-2005, 10:29 AM   #11
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Quote:
Originally posted by tkedwards
stricom is still part of the peostri group (many Linux distros put each user in their own group by default) so you need to change the name of the peostri group like this
Code:
groupmod -n stricom peostri
That worked!

Code:
stricom:/home/carlos/music# groupmod -n stricom peostri
stricom:/home/carlos/music# su stricom
stricom@stricom:/home/carlos/music$ cd /home/stricom/
stricom@stricom:~$ ls -lh
total 16K
drwxr-xr-x  2 stricom stricom 4.0K 2005-10-26 12:35 chris
drwxr-xr-x  2 stricom stricom 4.0K 2005-10-14 16:42 derek
-rw-r--r--  1 root    root     990 2005-10-26 07:25 readme.txt
drwxr-xr-x  2 stricom stricom 4.0K 2005-10-14 16:42 tim
 
Old 11-29-2005, 02:25 PM   #12
zeshan_b
LQ Newbie
 
Registered: Sep 2004
Location: Arlington
Distribution: installed mandrake
Posts: 19

Rep: Reputation: 0
Thank you this was helpfull

Thank you this was very helpfull. I needed to change the owner and user for some files and folders on a linux webserver.

Thanks
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing user group atze Linux - Newbie 12 06-08-2004 08:27 AM
User id (needs changing) podollb Linux - Software 2 05-15-2004 09:26 AM
changing the password of a user sadiboyz Linux - Newbie 2 04-21-2003 02:22 PM
changing user shells Syncrm Linux - General 3 02-17-2002 03:36 PM
Changing Mysql user? Ricardo77uk Programming 13 06-30-2001 05:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:09 PM.

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
Open Source Consulting | Domain Registration