[SOLVED] Repopulate home without creating new users
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I had /home on a separate disk/partition and the SSD died, on a nearly new machine. The root install is still intact. Since I lost a few weeks' worth of files since my last backup, I'd at least like to try and salvage the system configuration and whatever might remain in temp files and elsewhere relating to the users and their setups. That last backup is on my old machine running an older distro with a lot of outdated cruft, so I'm reluctant to copy things over wholesale from there, I'd rather do things piecemeal after recovering what I can of the new system.
I've bought a new disk and created the new /home partition on it (as this is openSUSE Leap 15.1, I've booted the rescue system and used the YaST Partitioner to do so). The new /home is empty. I want to populate all the user directories with default files and directories, but without creating new users, then login to the desktop (Plasma) under each user. I read in another thread about the xdg-user-dirs-update command, but would this only create a few empty subdirectories, not an entire home layout with all the hidden files and default configurations?
I suspect this is too niche a scenario for there to be a dedicated function. If I use the useradd command I'd presumably have to create entirely new users and cannot merely perform actions on an existing one?
I'm slightly confused on what you're trying to say, but if is just move/copy all of the user data onto a new partition into /home/user
then you just recreate a the same user again putting in the info, and passwd it will see that you already have the dir created, ask if you want it somewhere else > NO say nope, then it asks if you want to change permissions, say nope. done.
it really does not matter when you replace whatever is in the user /home/user before or after you create that user. Just know files will or can be changed whenever you overwrite them with another by the same name.
I'm slightly confused on what you're trying to say, but if is just move/copy all of the user data onto a new partition into /home/user
then you just recreate a the same user again putting in the info, and passwd it will see that you already have the dir created, ask if you want it somewhere else > NO say nope, then it asks if you want to change permissions, say nope. done.
Is this just by running the useradd command without any special arguments?
Quote:
Originally Posted by BW-userx
it really does not matter when you replace whatever is in the user /home/user before or after you create that user. Just know files will or can be changed whenever you overwrite them with another by the same name.
Once I have the new /home populated with defaults, I would then copy bits and bobs over via SSH from my old machine, directly overwriting some of the default new files in /home, as and when needed. I don't quite understand your use of /srv. Or is that just a generic reference to the new machine?
As I understood the question the OP wants to recreate a user's home directory skeleton i.e ~/.profile etc without having to run useradd. The basic skeleton is located in /etc/skel and to it run the command:
cp -r /etc/skel/* ~/
The useradd command needs the -m option to create the home directory skeletion. adduser automatically copies the skeleton but useradd does not. However the OP does not want to recreate existing users.
For obvious reasons that has to be done as root, but root login over SSH can be turned on for the task and then turned off when it is completed.
Once the transfer has been completed, check if the owners match the directories. If the user IDs do not line up, then you'll need to set them manually or with a few lines of script. Either way chown will be involved.
[SOLVED] Repopulate home without creating new users
Quote:
Originally Posted by michaelk
As I understood the question the OP wants to recreate a user's home directory skeleton i.e ~/.profile etc without having to run useradd. The basic skeleton is located in /etc/skel and to it run the command:
cp -r /etc/skel/* ~/
This is essentially what I wanted to do, thanks.
One slight difference though with the command required. The above only copied the /bin subfolder in the user home, so in order to copy all the hidden files and subdirectories I needed to do
This allowed me to login to Plasma, and it seems that this automatically induces the populating of the default xdg subdirectories, no further action required there.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.