Howto re-create a user profile / home dir for an existing user a/c

Hi there, i was hoping someone could let me know what is the correct way/procedure to re-create a user home directory. For instance, on a Mac/Windows machine, i would just rename the existing user profile [home dir], and then just log back in as the user - job done. On OpenSuse/Linux, it seems it does not work that way…?!:\

When i try to rename my home folder to say me.old via root, and log back in as me, i get all kinds of errors. Opensuse does create a new home dir, but it appears not properly.

I guess i could just remove the account via User and Group Management…? Then re-create it…?

Any help on this would be much appreciated - thanks, vj

Probably the safest way is to create a new account via Yast
Backup anything you need from your old account, then logout and in to your new account. Delete the old account.

Cheers caf4926 - I shall give it a go…nice one!

It’s an ownership thing the new directory you create (as root?) would need to ownership changed to match the UID of the user you are creating it for.

First log out from any desktop session and go to console. Then, as user (not as root!), type the following :

cd /
sudo mv $HOME{,.old}
sudo mkdir $HOME
sudo chown $(id -u):$(id -g) $HOME $HOME.old

Your current home directory will be saved under your login name with ‘.old’ appended to it and you will have a new one with correct ownership.

Hello everyone,

gogalthorp - I’m just renaming my existing home dir using root, not creating a new home folder using root. The system is doing that for me when I next login, albeit not properly?!:\

I did what caf4926 suggested last night via YaST, and whilst the new account works perfectly, moving my old data back over to my new profile/account does however have permissions/ownership issues. Trying to change ownerships using the GUI is not that effective, one by one if fine but mass applying just does not work properly…

please_try_again - i think you may have nailed it my friend…!! I will give it a go and post back this evening. One question tho - how would I repair my permissions/correct ownership on my existing data…? As I did what caf4926 suggested last night, moved my existing data back over to my new profile - and now have a ‘pad-lock’ icon/emblem on each file [above right of each file]. Opening files and folders is fine, just ownership is showing my old account. I can change ownership manually using the GUI, but its quiet tedious, and the apply to all subdirectiries / entries does not work properly.

Top draw everyone, thanks all cheers… vj

Maybe I didn’t explain myself very well. I said backup your data, that means whilst in that account copy all you need to a pen drive or external HD. Create and login to new account, then copy in your backup. I suspect you have copied everything from the old account?!

I have never tried as suggested by: @please_try_again
But I understand exactly what it is doing.
Do you still have the old account and all the data?

Hello caf4926 – what I did was, backup whatever i needed… files, folders, config files etc. etc. whilst logged in as me, not root nor as new user. Moved my backed up data to a share on my machine which all can read/write too.

1 - Created a new account using yast, logged into my new account [which was perfect].

2 - Just moved my existing data from my sharepoint i created on my machine into my new profile.

My files and folders open fine, just that now all my files have a pad-lock symbol above, right of each icon. When checking permissions, it shows my old account as being the owner, which is correct I guess, its behaving correctly as I did move data from one profile to another.

Old account and profile still intact – I left it their until I got everything sorted :relaxed:

Thanks again caf4926 for your help

What you could do is delete the new account and try the plan laid out by @please_try_again

Another idea came to mind also, but no going back to the old account after this

I’m wondering. I never tried this. But if you go to the users settings in Yast. (You must have everything backed up, but you said you have). Delete the old account. Then rename the new account via yast, to match exactly your old user name.

If it’s about changing ownership recursively, from userA to userB, then, a find command would do it :

sudo find /home/userA -user UserA -exec chown -h UserB "{}" ";"

With the command above files and directories under /home/userA belonging to UserA will belong to UserB. I did assume that UserA and UserB are members of the same group and so didn’t change group ownership.

please_try_again - how would i apply your command to one folder within my new account. For instance, a folder called “backup” within UserB profile - my new account. UserA being my old profile, and owner of all the contents within the “backup” folder - i do like to confuse :slight_smile: :slight_smile:

I’m presuming groups, means both accounts are part of “users”…? I could be wrong:shame:

I just ran you command within terminal, and owner of my backup folder is still my old user account [UserA]…

Cheers, vj

Oh wow - i think i’v kinda messed this up now… UserA is now the owner of UserB’s profile and UserB is now owner of UserA’s profile - bloody hell!

Alright fellas - I think iv sorted it… I typed in terminal “sudo chown -hR UserB:users /user/UserB” – ownership/permissions seems correct at first glance. Group is set to “users” / access is none for now. I can read/write/delete fine and no pad-lock icons on my backed up data from old profile [UserA].

Would be be correct…?

Thanks again everyone for all your input and help thus far, cheers…vj

Sounds good to me. :slight_smile:

Yep. I didn’t mention you should also change the home directory ownership cause I thought you would figure out yourself. :wink:

On Wed, 17 Feb 2010 13:36:01 GMT, please try again <please_try_again@no-mx.forums.opensuse.org> wrote:

>
>If it’s about changing ownership recursively, from userA to userB, then,
>a find command would do it :
>
>
>Code:
>--------------------
> sudo find /home/userA -user UserA -exec chown -h UserB “{}” “;”
>--------------------
>
>
>With the command above files and directories under /home/userA
>belonging to UserA will belong to UserB. I did assume that UserA and
>UserB are members of the same group and so didn’t change group
>ownership.

Personally i would have used this:

Code

su -c ‘chown -chR newowner:group] .*’ // for . hidden directories and files
su -c ‘chown -chR newowner:group] .’ // for all other directories and files

JosephKK - One question tho, would code su -c ‘chown -chR newowner:group] .’ not apply to dot/hidden files also – because your using a wildcard for all files/folders…?

Cheers, vj

On Sat, 20 Feb 2010 12:06:01 GMT, vmohan <vmohan@no-mx.forums.opensuse.org> wrote:

>
>JosephKK - One question tho, would code su -c ‘chown -chR
>newowner:group] .’ not apply to dot/hidden files also – because your
>using a wildcard for all files/folders…?
>
>Cheers, vj

It often does not pick them up, that is why i gave two lines. One specifically for “.*”.