PDA

View Full Version : [all variants] [SOLVED] changing user account name



tr333
November 27th, 2008, 05:06 AM
Is it possible to change the username of the main user account? If not, how do I create a new account with the same sudo privs. as the main account (so i can delete the other account)?

unutbu
November 27th, 2008, 05:17 AM
As you use an account, the username insidiously becomes entwined in the paths and contents of many config files. Changing your account name is possible, but it becomes a horrendous mess. I think it is much better to create a new user and then copy data over.
Config files have to be redone or copied with care.

To create a new user:

sudo useradd -D NEWUSER
for group in `groups`; do echo $group; sudo gpasswd -a NEWUSER $group; done
The first command creates NEWUSER with default settings. The second command makes NEWUSER a member of all the groups you currently are a member of.

tr333
November 27th, 2008, 06:37 AM
I just tried creating a new user with "sudo useradd -D username" and its printing out the useradd help info to stderr. The help information says that this is the correct syntax :?


Usage: useradd [options] LOGIN

Options:
...

unutbu
November 27th, 2008, 06:44 AM
Sorry, my mistake. Try


sudo useradd --create-home NEWUSER

tr333
November 27th, 2008, 07:28 AM
That seemed to work for adding the user and the groups, but it created the default shell as /bin/sh. How do i set this to /bin/bash?

benhur99ph
November 27th, 2008, 07:31 AM
Go to System>Administration>Users and Groups...
Then edit it from there...
You may need to unlock it ... just type the password and you're all set...

tr333
November 27th, 2008, 07:51 AM
Go to System>Administration>Users and Groups...
Then edit it from there...
You may need to unlock it ... just type the password and you're all set...

I'm running Ubuntu Server. I don't have the GUI preferences.

tr333
November 27th, 2008, 07:56 AM
Found the solution in 'chsh'. Thanks for the help on this.