LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Renaming a user? (https://www.linuxquestions.org/questions/linux-newbie-8/renaming-a-user-357317/)

Nuvious 08-26-2005 03:19 PM

Renaming a user?
 
Any easy way to rename a linux user in the console?

saman007uk 08-26-2005 03:24 PM

edit the /etc/passwd, /wtc/group and /etc/shadown group. After that, change the owner of the homedirectory to the new user.

bosewicht 08-26-2005 03:31 PM

why not just create a new user then change permissions on the home dir? it's easier than editing the files

# useradd -m -s /bin/bash newuser
# passwd newuser

mv -fr /home/olduser /home/newuser
chown -R newuser /home/newuser

tredegar 08-27-2005 12:58 AM

saman007uk and bosewicht,

Unfortunately, this doesn't work, although, intuitively, it feels as though it should.

The problem is that many of the configuration files (~/dotSomething) contain references to olduser. They do not work when simply chown'd. For example, see the output of grep -r /home/olduser/.*

I suppose you could write some sort of script with sed to change all the references to olduser to newuser within these files, but then there are also some files in /tmp which have the same problem, but this time the change needs to be made to the filename, and in my experience this all turns into a major nightmare!

The only solution I have managed to get to work is to create a new user, set up all those preferences, then copy over data files (eg docs, mp3's), and then chown them. A real pain!


All times are GMT -5. The time now is 12:15 PM.