how do you change your user-name in lucid?

Asked by Stephen Hamer

How do you change your user-name in lucid? Is this even possible?

By “user-name”, here, I mean the name that appears as the name of a directory in the “Home” folder, the name that appears before the command-line prompt, the name that is broadcast to the world from the top panel of the desktop courtesy of the indicator applet session 0.3.6, and quite possibly a whole lot of other places as well. I do not mean what I shall call here my login name; that is, to the name that appears on the welcome screen after start-up, the name I can (and have) changed via the “Users & Groups” dialogue-box, using the (confusingly-named) “change user-name” option.

This last option does not change the user's user-name (in the sense of the first sentence of the paragraph above) at all; it merely changes the name appearing in the user-name group (have I got this right?), and thus the name I log in with. In particular, it t does not change the name of the user-name group, the contents of the Home folder, or any of the appearances of the user-name mentioned above.

All contributions welcome, but I am particularly keen to hear from ubuntu-nauts who have actually changed their user-name (name of their user-account?): their method, the results they got, the problems they encountered, etc. Of course if what I want to do is “not possible” that will do very well as an answer.

P.S. I am not trying to hi-jack someone else's system (honest).

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Hamer
Solved:
Last query:
Last reply:
Revision history for this message
kernowyon (kernowyon) said :
#1

System > Administration > Users and Groups.

Select the username and then click Change on the right of the name. That will change the username which is shown at login and on the Home folder.

Revision history for this message
kernowyon (kernowyon) said :
#2

Apologies, I see you have apparently done the suggestion I made.

Revision history for this message
Marc Stewart (marc.stewart) said :
#3

There are so many things that depend on the username, I wouldn't suggest you even try renaming. You should just create a new user and then move any important files to their new location before removing the old home directory. You can then use:
sudo chown user:user filename
in a terminal (replacing user and filename as appropriate) to reassign ownership of those files to the new username.

Don't forget to give the new user administration privileges if the the account being replaced has them.

Revision history for this message
zvacet (ivicakolic) said :
#4
Revision history for this message
Stephen Hamer (stephen-hamer-uk) said :
#5

A big thank you to Kernowyon, for responding so promptly to my question, to Marc Stewart for his valuable cautionary words and practical advice, and, in particular, to zvacet for nudging me in the direction of a thread which yielded two or three more very useful looking suggestions. I am going to test these out on my flash install, and, ultimately, my full-install. I will post the results I get here shortly.

Revision history for this message
Stephen Hamer (stephen-hamer-uk) said :
#6

OK there would appear to be two approaches to the problem of changing your user-name:

We could do as Marc Stewart suggests and set up a second admin-account, transfer to the new account the files we want to keep, then delete the old account.

This is like moving house for real; inevitably, some of the files created in the old account - bookmarks, browser history, and probably a whole bunch of other things - won't survive the move ('Hey doll, where's that ornamental cork-crusher your mother gave us, I can't find it?'), but no system files are changed by this method, so it is presumably absolutely safe. A pretty full account of the subtleties of this method may be found here in this recent post from paqman:

http://ubuntuforums.org/showthread.php?t=967404

The alternative is to try to alter the identity of the existing user-account by modifying system files using terminal commands, possibly supplemented by the use of file-editing tools like 'gedit' or 'sed' (Stream Editor').

This approach is like repainting, or perhaps even reconstructing, your house in situ; it is fraught with potential dangers and pitfalls, but you keep the same view and neighbours. The thread zvacet drew to my attention to above yielded three methods of this kind. All these methods use some form of the 'usermod' command (which, in the case of an admin account, creates a difficulty, which I shall come to shortly). They differ from each other in the extent and manner of their supplementary editing of system files.

In what follows:

"new" = the user's desired new user-name

"old" = the user-name the user wishes to discard

"user-name" = the name to the left of the '@' sign in the command-prompt, not the parameter changed by the “change user-name” option of the “Users & Groups” dialogue box (accessed from the Administration menu).

The problem with the 'usermod' command is this: it cannot be used to alter the account of a user who is logged in or who has a process running under his user-name; in particular, since the 'usermod' command requires administrator privileges, it cannot be used to change the characteristics of the system-administrator's account! Some ingenuity is needed to overcome this unwelcome fact.

FIRST METHOD

The first method is due to bodhi-zazen (p. 2 of the above thread). He suggests the following:

sudo -i

to get a root shell, ie become the 'root-user', thereby obviating the restrictions on the use of 'usermod' (CAUTION. You can make unlimited changes to your system as root-user, and thus do unlimited damage), and then

usermod -d /home/new -m old

to re-name your old home-folder and transfer all your old files to the new folder.

Then to actually change the user-name the three editing commands:

sed -i -e 's_old_new_g' /etc/passwd

sed -i -e 's_old_new_g' /etc/group

ed -i -e 's_old_new_g' /etc/shadow

To which I shall add:

leave root shell with

exit

The syntax of these commands is as follows: 'sed' is a file-editing tool; the option -i instructs sed to replace the files it edits with the edited version (rather than save them as something else); the -e option instructs sed to carry out the editing-task specified by the expression in quotes. The first "s" in this expression is an instruction to substitute, the understrike is just a separator (any symbol can be used here provided it does not appear in "old" and "new"), "new" is the expression to be substituted, and "old" is the expression to be substituted for. The final "g" (=global) tells sed to substitute all occurrences of "old". The terminal filename is, of course, simply the file sed is going to act on. Thus the first command above simply substitutes the new user-name for the old one, wherever the latter occurs in the file /etc/passwd. The other two commands carry out similar editing jobs, but on different files.

According to its 'man'-page the usermod command itself acts on the /etc/passwd, /etc/group, /etc/shadow, and /etc/gshadow. Thus if we adopt this method we will be directly changing only these 4 system files.

I couldn't get this method to work in my flash install, even on the easier case of changing the user-name of an ordinary desktop user (set-up for testing purposes); it did effect a user-name change, but on re-starting I always got a boot-failure, which necessitated dumping the persistence-file on my flash and replacing it with a copied back-up (in effect a whole-system restore). This left me back at square one.

A little practical experience working on this problem leads me to query some aspects of the above method: eg the use of 'sudo -i' to get a root login (done to avoid restrictions on the use of 'usermod'?) is problematic. As I understand it 'sudo -i' merely simulates most of the features of a root-login; some password permissions are still denied. My theoretical knowledge of computing matters is extremely limited, so apologies to BZ if I'm blowing gas here.

Then there is the question of what bodhi-zazen means by "old" and "new" in his sed commands. In a clarifying comment on his method, posted in the same thread, he suggests these expressions mean (respectively) "/home/old" and "/home/new". Again, I may just be parading my ignorance of computing-matters here, but it seems to me, having worked with the /etc/-files we are trying to edit, that this cannot be correct (and BZ's clarification contradicts his own use of these terms in the 'usermod' command he gives). At least one user reports success with BZ's method, but did this user get his system back when he re-started? Some additional clarificaton is required here, I think.

SECOND METHOD

Let us put the above method aside, for the moment. The thread (suggested by zvacet, above) in which the above method appeared also produced the following suggestion, this time from dark1 (I'm going to cut and paste this, because the second and final command, below, a bit of a mouthful):

usermod -d /home/new -m old

find /home/new /etc/ -path '/home/new/idontwanttosearchthisdirbcuzitshugeandiknowitsok' -prune -o -type f -exec sed -i 's,/home/old,/home/new,g' {} +

Dark1 comment on BZ's method does not exactly inspire confidence in his own. I quote:

“This is cool but it doesn't address short-cuts, desktop settings and other things that might get broken. DISCLAIMER: I'm a complete Linux n00b so if this breaks your system - don't cry to me! But this is how I do it:” (see above)

[Back to me] The 'usermod' command above is the familiar device for, in effect, renaming the user's home folder But what is that second command all about, and what's the deal with that wacky filename?. And how do we avoid the restrictions on the use of 'usermod'?

As far as I can make out the command as a whole is a sophisticated application of the "find" tool: it looks through a specified range of files (all the files below a specified directory), and for each file that that it finds that meets certain specified criteria it invokes the sed command to replace "/home/old" by "/home/new". The wacky file-name remains a mystery to me. I can't say more; I'm not an expert (Comments from better-informed forum-users welcome here).

Dark1's comment rather leads me to suppose, though, that this command edits a wider range of files than BZ's method. This is scary, not least because you don't know what files are being changed. This raises the question of the reversibility of the above method (should we not like the results it produces). Since I like to know what I'm doing, I did not pursue this approach.

Methods which make use of manual or automated file-editing share another problem: how do you ensure that you make changes that are consistent with the contents of other system files?

What we really want is a set of commands, which act in a consistent way on a known (small) group of files, and whose effects are trackable and fully reversible.

THIRD METHOD

jondodson, in the same thread that produced all the methods so far discussed, offers an amazingly simple possibility:

To obviate the restrictions on th use of 'usermod', he suggests:

a) re boot into 'recovery mode'. This is not difficult. We will deal with it in due course (but not in this post)

and then in recovery (as the full root-user):

usermod -l new -m -d /home/new old

The "-l new" part of the above effects the change of user-name, the rest of the command (whose syntax seems to me to be slightly unorthodox) renames the user's home folder.

Can it be that simple?

Jondodson claims that he has tested-out this method successfully on his own system. But what is he counting as success?

He comments:

“There may be a few bits of tidying up to do afterwards:
1. If you have auto log in set, you'll need to log in manually first time after the change and re-set it up (system>administration>login screen, unlock). So make sure you know your old username password (which might be different to your root password)
2. You might need to change the command path of programs you have installed yourself outside of software centre/synaptic, depending on where you installed them. I had to change the path of Google Earth (right click Ubuntu sign>edit menus>internet>google earth>properties, then edit the 'command' line to use your new username.
3. Any other programs you have that use and point to directory paths may need those paths tweaking. I had MAME installed and so I had to edit the roms directory path, no biggie. I also had to edit paths in Compiz for wallpaper/skydome/cubecaps needed redoing as well.

All went smoothly for me. I totally misunderstood what I was doing during the original OS installation and ended up with dellinspiron6000@dellinspiron6000, but now it's a much more sensible jon@dellinspiron6000.”

He mentions some (to me) pretty esoteric applications, here. Does this mean that the more basic applications: nautilus, office, firefox, evolution, sundry media-players all functioned as normal?

OK let's regroup; let's get clear in our minds exactly what we want to achieve. We have 3 requirements:

1. We want to end up with a desktop environment that is as close as possible to the environment we would have had if we had selected the new user-name when we first installed. Thus, for example, we want:

a) the new user-name to be shown in the login screen, on the top-panel user-indicator applet and on the latter's associated drop-down menu

b) the new user-name to be displayed in the command prompt

c) the user's home-folder to be renamed, and the new name to be shown in the nautilus file-browser in, for example, the browser's left-hand list-pane, and in the path displayed along the top of the browser.

d) The new name to be shown correctly in the file-permissions obtained with the terminal command: “sudo ls -l file-name”

We also want (at a minimum):

e) documents created with Office to open normally

f) applications and desk-top launchers to function without error messages

g) browser-history and e-mail records to be preserved

h) Rhythmbox to maintain links to previously-imported files, and playlists created in other media-players, e.g. audacious, to continue to function.

2. We want to achieve these outcomes:

a) using a small, straightforward group of terminal commands (so that we maintain a consistent set of system files); i.e. our method is to involve no hand- or automated-editing of files.

b) using commands that, in the first instance, act on a known, small number of system-files (which can thus be backed-up) to produce known, trackable file-changes.

Finally,

3. We want the method we use to be reversible if an unacceptable number of the desired changes listed under 1. cannot be achieved. In particular, we require an 'exit strategy' allowing us to recover, as nearly as possible, the initial state of our system, should things go badly wrong.

It would also be nice if our system could be re-started normally.

These are the conditions of the problem.

Is this problem solvable? The fact that the 'usermod' command has a user-name change option rather suggests that it is. My own experiments changing the name of an ordinary desktop-user in a flash-install (not a perfect model of a full-install), tends to re-inforce this conclusion. But I have written enough for now. I will post again shortly.

Revision history for this message
Stephen Hamer (stephen-hamer-uk) said :
#7

Oops! We also want, under heading 1. above:

i) peripherals, like screens, printers and modems (I use dial-up), to function, and (since I am running ubuntu from an ext. HDD attached to a samsung N110 netbook) wireless-internet to work from previously-established connections

j) the system to be updateable (I don't intend to upgrade it).

OK, job done: I have changed my (system administrator) user-name, and got a very good result.

The notes below, and my final conclusions, are based on the observations I made while experimenting on the system loaded on my fully backed-up flash-install (not a perfect model of a full install to a HDD, but the best model available to me for the purposes of making experiments), which gave me an encouraging result, and then later on my full system , which confirmed the previous good outcome.

TO CHANGE THE USER-NAME OF AN ORDINARY DESKTOP USER (NON-ADMINISTRATOR)

This is the simpler case, in that we have ready access to the 'usermod' command, but it illustrates nicely the basic method. The latter is easily adapted (full details given later) to deal with the more difficult case of changing the identity of a system-administrator.

The usermod command acts on the following system-files: /etc/passwd, /etc/group, and /etc/shadow; and, accordingly, these are the files of greatest interest to us.

Our first command changes what we shall call the user's “user-information” name. This is the parameter appearing in the fifth field of the last line (assuming the user we are discussing is the last user added to the system) of the /etc/passwd file (the user's actual user-name is contained in the first field of this line). Lets have a quick look at that line now; it consists of 7 fields separated by colons (grab it from a terminal with: sudo gedit /etc/passwd):

user-name:password-marker:user-ID(a number):group-ID(a number):user-info:home-dir:shell

The fifth field above is further subdivided into (I think) 5 sub-fields (separated by commas). What we are calling here the user-information name appears in the first of these sub-fields.

This name, which, by default, is given the same form, on installation, as the user's user-name appears most visibly on your system's login welcome box. Yes, you read that right, the name on your login box after installation is not–repeat not–your user-name. It has the same form as your user-name, but it is a different parameter, and can be separately varied. You can see your real user-name, at login, by hovering the mouse pointer above the login box.

What we are calling the user-information name also appears on the drop-down menu of the indicator-applet attached to the top panel of the user's desktop (the indicator applet itself shows the user's actual user-name). Finally it appears in bold type in the user-list pane of the Administration menu's 'Users & Groups' dialogue box (where it is 'under-shadowed' by the user's actual user-name).

To change what we have called the user-information name (and hence get a sensible-looking login screen), we use the command:

sudo chfn -f new* old

where “old” = old user-name, “new*” = name the user wishes to use as the new user-information name (we are assuming, here, that the user will want this to be the same as the new user-name: the end-state of our name-change – as in the full case of a change in the identity of an administrator account - is to be the system we would have had when the user-account was originally created).

This command acts on /etc/login.defs in addition to the user-information field of /etc/passwd, so we can add /etc/login.defs to our list of important files.

WARNING: what we have called, here, the user-information name has a role in authenticating the user at login, so do not try to change it by hand-editing /etc/passwd.

The above command is strictly-speaking optional. What we have called the user-information name is the parameter changed by the confusingly-named 'change user-name' option of the 'Users & Groups' dialogue-box referred to above. The reader who is so disposed can use this last tool to separately change this parameter, after he has made the main user-name change. We include the above as one of our commands because we want to make all our name-changes, with commands, in one go.

To change the name of our ordinary desktop user's main group, we use:

sudo groupmod -n new** old

“new**”, here refers to the new name of the desktop user's main group, which we are assuming the reader will want to chose so that it continues to match his user-name, as it did when the account was first created.

Again this command is optional: in the case of an ordinary home-user, a change in the name of a user's main group will not make one jot of difference to how his system functions; such a user will not ordinarily be an active member of his main group, which, by default, is set up void of active users. The new group-name will, however, appear in (say) file-permissions, so we change it.

The groupmod command acts on /etc/group, where it changes the name in the last line of the file, and also /etc/gshadow, so we add the latter to our list of important files.

To change the an ordinary desktop-user's home directory, which, by default, has the form /home/user-name, we use:

sudo usermod -d /home/new -m old.

As far as I can make out, the only system file changed by this command (it also acts on all the user's personal files) is /etc/passwd, where it has the effect of replacing “/home/old” in the sixth field of the line headed by the user's user-name (usually the last line of the file) by “/home/new”.
To change the user-name proper of an ordinary desktop-user, we use:

sudo usermod -l new old

This affects /ect/passwd, where it changes only the name in the first field of the line containing all the user's parameters, /etc/group, where it adjusts a variety of group-memberships, and also /etc/shadow, where it renames the encrypted form of the user's password.

Finally, to deal with any applications that might still be inclined to look for the old home-folder, we create a symbolic link, pointing from the old home-folder to the new, thus:

sudo ln -s /home/new /home/old.

This symbolic link will appear in the user's system as a folder with the same name as the old (now-vanished) home-folder (it is distinguished from the latter by the presence of a black 'swoosh'-arrow, curling up from under it). Nonetheless, it does have the same 'name' as the old home-folder proper.

SUMMARY OF METHOD (USER-NAME CHANGE OF AN ORDINARY DESKTOP USER):

Thus in changing the user-name of an ordinary desktop-user, changes are made to the following files:

/etc/passwd
/etc/group
/etc/shadow
/etc/login.defs
/etc/gshadow

We thus begin the name-changing process by backing up the above files with:

sudo cp /etc/passwd /etc/passwd.backup

sudo cp /etc/group /etc/group.backup

etc.

Backing-up these files will give us a chance of recovering the user-account if we make a complete hash of things in the name-changing process.

Then to actually change the user-name of an ordinary desktop user-account (not a system-administrator – we will come to that eventually), we would do, from an administrator account:

1. sudo chfn -f new* old (OPTIONAL – changes the content of the user-info field. * gives us a user-information name identical to the new user-name)

2. sudo groupmod -n new** old (OPTIONAL – changes the name of the user's main group. ** gives us a main-group name identical to the new username)

3. sudo usermod -d /home/new -m old

4. sudo usermod -l new old

5. sudo ln -s /home/new /home/old

where “old” = old user-name; “new” = new user-name.

NOTES:

If you intend to dispense with the optional commands above, you need only back up /etc/passwd, /etc/group and /etc/shadow

The order of the above commands is not arbitrary; 1-3 all make use of the old user-name, and so must be given before 4. Once 4 has been given, the old user-name is no longer available for use (it no longer exists). If you wanted to use 3 (say) after 4, you would have to replace “old” by “new”!

3 and 4 can be combined in the single command:

3+4. sudo usermod -d /home/new -m -l new old

5 is included in to deal with the possibility case that, after the name-change, there are still applications looking for the old home-folder. From the experiments I have undertaken, 5 does seem to be necessary.

Thus, for the user who wishes to make minimal changes, our final recipe is very similar to that given by jondodson in the thread previously referred to.

I must say, here, that I have never actually used commands 3 and 4 in the form '3+4', which is the form (it seems to me) that the combined command should take if the prescriptions of the 'usermod' man-page are followed. Maybe these don't matter: jondodson seems to be pretty clued-up and confident about his method.

To reverse a change in the user-name of an ordinary desktop user

We first remove the symbolic-link with:

sudo rm /home/old

We have to do this first, otherwise we will not be able to re-create the user's old home-folder; its name will still be being used by the symbolic-link.

We then repeat commands 1-4, above, but with “old” and “new” transposed; i.e., we do:

1a sudo chfn -f old new

etc.

OK, we have succeeded in our basic aim of finding a small, reversible set of commands that will allow us to completely expunge an old user-name and install a new one (at least for a desktop-user account).

THE METHOD FOR AN ORDINARY DESK-TOP USER TESTED

But does this scheme actually work? To find out, I set up a new ordinary desktop-user account in the system on my flash-install (not an admin account – not available on a flash-install), configured Evolution and fired off a couple of e-mails, hopped about on firefox to give the new user same browser history, dropped some text and music files into the relevant folders, imported some music files into Rhythmbox, and added some launchers to the desktop.

I then changed the name of the account using the above method (this necessitated a restart: even visiting an account - logging in and out – seems to 'break' the use of usermod). What happened?

I was going to write about this, here; but the results I got with this experiment were so encouraging that I went ahead and changed my user-name on my main system, so I will defer discussion of the results I obtained after changing my user-name until after I have described how to change the user-name of an administrator account (since this is what the reader will, I imagine, be most wanting to hear about). I will merely remark, here, that the user-name change made in the case of an ordinary desk-top user was fully reversible.

TO CHANGE THE NAME OF AN ADMINISTRATOR ACCOUNT:

The restrictions on the use of usermod (not available to change the user-name of a logged-in user) may be overcome by booting into 'recovery-mode' so that you are, in effect, logging into your system's 'root-account' and not into your own administrator account.

To do this start (or restart) the computer, then access the grub menu.

If you have more than one OS accessible to your computer (as I have), the 'grub menu' will automatically appear. If ubuntu is the only OS installed on your box, you will have to press SHIFT (some say ESC) at the start of boot-process. The grub-menu should then be displayed. You can't miss it; white print on a black background, it lists recovery-mode in its list of options.

Select 'recovery-mode' with the up and down arrow keys, then hit enter.

The system will then put up a new menu: select the option containing 'drop to a root-prompt' (or similar) from this menu. When I did this three days ago, the required option was the fifth option on a five option list. Your system (to go by my own experience once more) will then spend about 30-60s coughing up a lot of computer-ese. Be patient; it will eventually put up a root-prompt (marked by a terminal '#') You will then be logged into your system's root-account. Be very careful what you do now: as root you have unlimited privileges and thus an unlimited ability to damage your system.

Do the necessary file-backups (if you have not already done them). Just to remind you:

Back-up the files you will be changing with:

cp /etc/passwd /etc/passwd.backup
cp /etc/group /etc/group.backup
cp /etc/shadow /etc/shadow.backup
cp /etc/login.defs /etc/login.defs.backup
cp /etc/gshadow /etc/gshadow.backup

[The last two back-ups need not be carried out if you omit the optional commands below]

Then make your selection from the 5 'change user-name commands', which to remind you are:

1. chfn -f new* old (OPTIONAL – changes the content of the user-info field. * gives us a user-information name identical to the new user-name )

2. groupmod -n new** old (OPTIONAL – changes the name of the user's main group. ** gives us a main-group name identical to the new username)

3. usermod -d /home/new -m old (ESSENTIAL)

4. usermod -l new old (ESSENTIAL)

5. ln -s /home/new /home/old (ESSENTIAL)

[ The initial 'sudo' has been omitted here, because, in this context (as root), we don't need it]

Now leave the root-account and re-start your system with the command:

6. shutdown -r now

If you have included the first command, above, in your command-selection you should be welcomed back to your system with your new user-name on the login screen.

Some basic tidying-up of your new user-account will probably be necessary, notably of the nautilus file-browser (see pont c), below).

THE ADMINISTRATOR METHOD TESTED

The above method was tested on a system comprised of Ubuntu 10.04 installed on an ext USB HDD (actually a STORM MP180 HDD/mp3 player) attached to a Samsung N110 netbook.

I shall review the success of the user-name change according to the success-criteria mentioned in my previous post. In what follows “OK”=”no discernible difference in performance”, or “hopes fully realised”

To remind the reader:

1. We want to end up with a desktop environment that is as close as possible to the environment we would have had if we had selected the new user-name when we first installed. Thus, for example, we want:

a) the new user-name to be shown in the login screen (OK), on the top-panel user-indicator applet (OK) and on the latter's associated drop-down menu (OK).

I might also add, here, that the names on the user list-pane of the 'Users & Groups' dialogue-box (accessed from the Administration menu) were also correctly displayed.

The new user-name was also correctly displayed on the screen that the system puts up when you lock your account with Ctrl+Alt+l (“ell”)

b) the new user-name to be displayed in the command prompt (OK)

c) the user's home-folder to be renamed, and the new name to be shown in the nautilus file-browser in, for example, the browser's left-hand list-pane, and in the path displayed along the top of the browser.

A new home-folder was present in the home directory, along with the old home-folder in the form of a symbolic link [Q: Is there a way of hiding such links? A (after an extensive Internet- and library-search): NO.]

The nautilus file-browser presented a couple of small problems, and these should, perhaps, be addressed immediately after logging in: 1) the new home-folder was correctly displayed at the top of the left-hand folder list-pane, but the Documents-folder, Music-folder, etc. indicators were stripped of their icons, and when these links were used to access files: 2) the old user-name was still present in the file-path at the top of the browser.

To remedy 1), remove the old links by right-clicking on the Documents-, Music-, etc. folders and choosing “remove” from the menu the system puts up. Now re-establish new links by clicking on the new home-folder (at the top of the left-hand list-pane) to display the Documents-, Music- etc. folders in your new home-folder in the main window of the Nautilus-browser. Then left-drag new versions of the Documents-, Music-, etc. folder-links from the browser-window to the left-hand list-pane. These folders should retain their icons, and 2) file-paths of files accessed via these links should be correctly shown at the top of the browser. Problems solved.

NOTE: the above problems would perhaps have caused an application failure, or at least an error-message, if the sym-link had not been in place

d) The new name to be shown correctly in the file-permissions obtained with the terminal command: “sudo ls -l file-name” (OK)

We also want (at a minimum):

e) documents created with Office to open normally.

I only tested the word-processing and spreadsheet applications, since these are the only parts of the Office-suite that I regularly use. I only met with one small (easily remedied) problem, which recurred in all applications (media-players, for example) that feature an “Open (file)”-command. When this command is used, the system puts up a browser-window, showing the last place that you accessed a file from, and (more importantly) for our purposes here, the last path the system followed to get to this place. Thus, immediately after a user-name change, this path will contain the old user-name. The solution here is simple: just establish a new path, say via the (new) Documents-, Music-, etc. links in the browser-window. This only has to be done once for each application.

NOTE: If we did not have the symbolic-link in place, the application (trying to traverse the old path) might fail and, at the very least, put up an error-message here.

f) applications and desk-top launchers to function without error messages (OK)

Launchers functioned fine.

I had a slight problem with Evolution, but one that solved itself: the first few e-mails I sent off were copied twice to the “sent”-folder. But after deleting on of each pair and re-starting, this aberrant behaviour ceased.

I must remark here (basing myself once more on my experiments with a flash-install) that Evolution seems to be quite sensitive to a change of user-name. On the flash-install, with no sym-link in place, it put up an error message when first started, but this behaviour disappeared when I re-started. It also put up another error message when saving a sent e-mail. And this error-message (which concerned the absent old home-folder) did not go away after a re-start. However, even without the sym-link, evolution continued to function OK, albeit with an error message adding an unsightly nuisance.

g) browser-history and e-mail records to be preserved

The browser was fine. E-mails preserved. Contacts preserved

h) Rhythmbox to maintain links to previously-imported files, and playlists created in other media-players, e.g. audacious, to continue to function.

My music-library in Rythmbox emerged unscathed and I had no problems importing and playing new files.

Podcast feeds accessed via Rythmbox continued to function OK.

Other media-players (Totem movie-player, audacious, and vlc functioned perfectly; in particular, both audacious and vlc played previously-created playlists without problems.

i) peripherals, like screens, printers and modems (I use dial-up), to function, and (since I am running ubuntu from an ext. HDD attached to a samsung N110 netbook) wireless-internet to work from previously-established connections.

Dial-up modem (OK), detachable Monitor (OK), USB optical drive (OK), USB HDD (OK), sundry flash-drives (OK), Floppy (OK).

Wireless Internet connections established in the various pubs offering free Wi-Fi that I use for major downloads were remembered and functioned OK.

I do not have a printer at home (I usually e-mail stuff that I want to print out to a convenient printer-location), so I wasn't able to test this.

j) the system to be updateable (I don't intend to upgrade it).

The system came through a system-update with flying colours.

I have also installed a couple of new applications via the terminal and synaptic. No problems.

All in all, the new account (with the symbolic link in-place) was, after minor nautilus-adjustments, a very accurate simulacrum of a fresh install. Unless you visited the home directory (with its tell-tale) symbolic-link, you would not know, from the appearance of the system or its functioning, that the name of the user-account had been changed.

TO RECOVER YOUR OLD USER-NAME

I haven't actually done this in the case of an administrator account (I am very happy with my new account). The notes to follow are therefore based on my experiments with my flash-install, which suggest that to reverse a change of user-name for an admin. account, the user should:

Restart and login to a root-account as before, then:

Remove the symbolic link to the new home-folder with:

5* rm /home/old

Then repeat your selection from commands 1-4 above with “new” and “old” transposed; i.e make an appropriate selection from:

1* chfn -f old new

2* groupmod -n old new

3* usermod -d /home/old -m new

4* usermod -l old new

restart once more with:

shutdown -r now

My experiments with a flash install suggest that some tidying-up will then be necessary, specifically:
Reversing the name-change (for an ordinary desktop user on a flash-install) brought the old account back OK, but links to files created under the new-name were broken: thus, for example' files imported into Rhythmbox were absent after the change back to the old name. Additionally, there were no Document-, Music-, etc. folder-icons in the left-hand folder list-pane of the nautilus file-browser; these had to be re-instated by dragging them from inside a window onto the old (now reinstated) home-folder. But this was but the work of a moment.

Some cautionary words are perhaps necessary here: I spent only about an hour in “new user-name”-land on my flash install, and the set-up I was using there was a rather simple one. In particular, I did not install and run new applications under the new user-name, so I can't advise the reader about how such installs would respond to a reversal of user-name. Obviously, you should only go ahead with a change of user-name on your main system if you are sure that this is what you want to do.

WHAT IF YOU MAKE A COMPLETE MESS OF THE NAME-CHANGE?

What's the 'exit strategy' if, through some typing error, or distracting family-emergency, or otherwise, you make a hash of the user-name changing process. What if, due to some unforeseen contingency, your system “hangs”, or has a massive fit? How do you get back to Kansas? Again, I have not had to do this “for real”; I refer here again to my experiments with a flash-install, which lead me to suppose you could do this:

If your system hangs, or is dramatically misbehaving, get to an emergency restart with:

Ctrl+Alt+Del

[Giving the power button a 'nudge' might also help things along here]

Once the system has re-started, log in as root as previously described.

If you have no idea as to what the state of your system now is (how much of the user-name change has been carried out), restore everything with the back-ups; i.e. do:

cp /etc/passwd.backup /etc/passwd

cp /etc/group.backup /etc/group

etc.

[This overwrites the existing files with the back-ups, while leaving the back-ups in place]

Now cd to the home-directory and have a look at your home folder. If this is your old home-folder, you should be able to get your system back by re-starting; i.e., by doing:

shurdown -r now

once more.

If you still have your new home-folder, you will have to hand-edit the last line in /etc/passwd (the line which now begins with your old user-name), and replace “/home/old” in this line by “/home/new”. I am not sure how you would do this in a non-graphical interface (I usually edit with gedit). Would “nano /etc/passwd” work? However you do it, save the edited file. You will now be able to re-name your home-folder with:

usermod -d /home/old new

[If you haven't previously hand-edited /etc/passwd, the above command, before it makes any change to your system, will look into /etc/passwd, see the old home-folder already in place and return “no change needed”, leaving your unwanted new home-folder still in place]

Then re-starting with:

shutdown -r now

should get your (old) system and account back. What you do then is up to you.

Moral: ALWAYS MAKE BACK-UPS

You will, of course, have backed-up essential personal files to an external volume, before you undertook to change your user-name, as you would before making any system-wide change.

CLOSING ASSESSMENT

I am sitting writing this under my new user-name on the evening of the third day after the name-change. Everything has (so far) gone well. I have not met with a single application- or process-failure, and I have not had even one error message. Some qualifications: my set-up is a relatively simple one and is only 6 months old. My needs are simple: I use my computer to create documents of various kinds; I fire-off e-mails; I download the occasional podcast and application; I listen to music; and I watch DVDs. Thus satisfaction of these needs does not require recourse to esoteric applications, or dodgy, third-party, built-from-binaries-with-hand-crafted-file-paths-software, or applications running in WINE, or any other kind of Ubuntu-esoterica. That said, my experiences (so far) suggest that the method for changing the user-name of an (administrator account) presented above is a valid one: it can be speedily implemented; it produces a result which, after minor adjustments, is very close to the result that the user would have got if he had originally created the account with the new user-name (in particular, things like browser history, files imported into, say, rhythmbox, are completely preserved); it does not de-stabilise the user's system; and it is (in principle) reversible. At the very least, it would appear to be a competitive alternative to the setting-up of a wholly new administrator account.

This assessment may change, of course, over time. If I have problems with my system (traceable to the user-name change), I will post them here.

IN CONCLUSION

I was moved to carry out the investigations reported in these posts by the confusion, even mystery, that seems to shroud the question of how best to change your user-name. There would seem to be several methods on offer, but testimonials from people who have actually successfully used these methods to change their user-name are few and far between. And the testimonials that do claim success, typically don't make clear what the user means by this, or how applicable their experience is to the general user. What exactly did they do? How much of a change did they achieve? What sort of a system did they start with? Where did they finish up? What problems did they have after the change? How easy was it to overcome these problems? These are the questions that need to be answered, and which I have tried to answer above.

Thus, in conclusion, do not e-mail me screaming “YOU DUMB F***, YOU HAVE RUINED MY LIFE!!!!!”, or similar, if you make use of the method described above and have problems. I am not a computer expert. I am not even a reasonably computer-literate lay-person. I have merely reported here, as accurately as I can, what I have done, its rationale, and the results I got. All decisions relating to a change of user-name, and to the methods used to achieve this objective are ultimately, dear, patient reader, yours alone to make.

If you use the above-described method to change your user-name, whether successfully or not, please report your results in this thread; it will make a valuable resource.