4

My old user account is not working at all some corrupted files I guess.

The other 2 accounts are working normal.

So I create a new admin account and I wonder how can I copy all my settings, passwords, files from old admin account to new account.

I cant use old admin account gets frozen very badly so will help lots if I can do the migration from new admin account.

Thanks!

2 Answers 2

1

You're basically asking: "How to copy settings and files from my user account to a new user account, skipping some settings?"

Migrating to a new user account

To move files from user old to new, you need to copy over the files and change the ownership accordingly:

sudo cp -r -d --preserve=mode,timestamps -T ~old ~new
sudo chown -R new: ~new

This should copy the files without modifying paths.

Now log in to a shell as new. Either switch to a VTY using Ctrl + Alt + F1 and login as new or login from a terminal using su new. If you chose the first method, you can switch back with Ctrl + Alt + F7. From this point, it's assumed that you're logged in as new.

If symbolic links exist which point to their old directories, find those links:

find ~ -lname '*/old/*' -ls

The file names of the symbolic links are printed, but no action has been taken. To create a new symlink ~new/path/to/symlink pointing to ~old/point/to/target, overwriting the old one, run:

ln -sf ~old/point/to/target ~new/path/to/symlink

There could be configuration files referring to the old ones, you can find those files with grep:

grep -HrnI 'old' ~

If you get many results, consider being more specific, i.e. replace old by /home/old. Files will be listed with lines matching the search criteria, but no action is taken.

Debugging the old account

If you copy all settings and files, you're better off with removing the problematic files. For optimal results, it's a good idea to logout the subject user from a GUI session and log in a virtual console (switch to it using Ctrl + Alt + F1).

If you're suddenly being logged out, check ~/.xsession-errors. You can do so by running:

less ~/.xsession-errors

Use arrow keys, Page Up/Down, Home or End to navigate, press Q to quit.

Sometimes the .gconfd/saved_state file gets corrupt. You can remove this file with:

rm .gconfd/saved_state

After doing this, switch back to a GUI login by pressing Ctrl + Alt + F7. Log in and if the problem went away, you're done. Otherwise, log out and switch back to the virtual console using Ctrl + Alt + F1.

Another directory that can be emptied is ~/.cache:

rm -r ~/.cache/*

Instead of loosing all files and settings, temporary move some folders. That can be done with:

mv folder{,-orig}

If a folder was not causing issues, remove the newly created folder and restore the old one:

rm -r folder
mv folder{-orig,}

Some folders that could cause problems (some may be nonexistent, in that case skip to the next folder):

.gnome
.gnome2
.kde
.config
.local

As with every modification, switch back to a GUI login and test it.

2
  • wow looks very very complicated for me... i dont get all the commands is there an easier way?...
    – tinaf
    Jul 18, 2011 at 7:28
  • Those are shell commands, just login in a terminal and execute those.
    – Lekensteyn
    Jul 18, 2011 at 9:37
1

Assuming that you have already created your newuser and the home folder for the newuser exists:

(1/2) Copy all the files to the new user:

sudo rsync -ah --progress /home/olduser/. /home/newuser

Notes:

  • rsync is a function similar but generally better than cp. It has more options etc
  • -a command retains the permissions of the original files (we will sort ownerships in step 2)
  • -h command turns output info into a human readable format (i.e. file sizes etc)
  • --progress adds a progress bar for each file
  • the /. on the end of the olduser location makes it include hidden files (this will make sure that your bash_aliases and bashrc files etc are copied across and not just normal files. This option is what migrates your settings.)

(2/2) Change the owner of the copied files

Now we change all the ownerships of the files:

sudo chown -R --from=olduser:oldusergroup newuser:newusergroup /home/newuser

Notes:

  • chown is a function to CHange-OWNership of files
  • -R makes it recursive. (If you are just changing one file you don't need this but we are changing all files and directories and everything within your new user folder and so recursive is needed)
  • --from=olduser:oldusergroup this makes sure that we don't change any files (especially relevant for hidden files) that are 'owned' by root. Changing these could mess up a lot. This --from option tells chown that we only want to change files and folders that are currently owned by olduser.

This worked for me and, although I explained a lot here, actually it's only 2 main commands so the process is really simple once you work out how to keep the permissions etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.