[SOLVED] How to duplicate one user's desktop and program settings for another user?
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
How to duplicate one user's desktop and program settings for another user?
I thought I had the right idea how to do this, but it didn't work. I have been using the root account for a lot of things since setting up Slackware (I know, bad idea . . .), mostly because I was building a lot of Slackbuilds and my build environment was in a directory I made called /home/Slackware. I did not know how to change the ownership of this directory so that other users could build in it, so I just kept using it as root.
I finally learned about the chown command and created a new "builder" group to which I gave group ownership of everything in my Slackware folder. I changed the group-owner permissions of everything in there to what the user-owner (root's) permissions had been before. Then I made my regular user a member of this group. So that's all fixed, I hope.
However, now I have a root account with all the desktop and program configurations already set up, and I would like an easy way of transferring all of these preferences to my new user. I thought I could do it simply by copying the contents of the root directory to the new user's home directory like so
Code:
cp -r /root/* /home/testuser/
and then changing the owners of the files like this
Code:
chown -R testuser:users /home/testuser
But it didn't work. All of the folders got transferred in what I thought was the right way, but XFCE, Firefox, and everything else are still blank slates that I have to configure all over again. What did I do wrong?
-k, --skel SKEL_DIR
The skeleton directory, which contains files and directories to be copied in the
user's home directory, when the home directory is created by useradd.
This option is only valid if the -m (or --create-home) option is specified.
If this option is not set, the skeleton directory is defined by the SKEL variable
in /etc/default/useradd or, by default, /etc/skel.
Which means when you create a new user, everything that's in /etc/skel will be in the users' home directory. I use this feature to create default user profiles. Here's a few examples:
However, now I have a root account with all the desktop and program configurations already set up, and I would like an easy way of transferring all of these preferences to my new user. I thought I could do it simply by copying the contents of the root directory to the new user's home directory like so
Code:
cp -r /root/* /home/testuser/
and then changing the owners of the files like this
Code:
chown -R testuser:users /home/testuser
Without comment on general advisability, try this instead...
Code:
cp -r /root/{*,.*} /home/testuser/
Your first try did not copy any of the hidden config files and directories.
Thank you all very much. I tried Habitual's suggestion yesterday, and it duplicated the XFCE panel settings, but the fonts, desktop appearance, and all other program settings I have checked remain the same.
@astrogeek and T3slider: Thanks, I didn't realize I was not copying the hidden files. Would you mind telling me what that syntax is with the curly braces so I can read about it? I have not seen that sort of thing before.
Also, I would not mind a comment on general advisability. Is there some reason I should avoid doing this?
Thank you all very much. I tried Habitual's suggestion yesterday, and it duplicated the XFCE panel settings, but the fonts, desktop appearance, and all other program settings I have checked remain the same.
@astrogeek and T3slider: Thanks, I didn't realize I was not copying the hidden files. Would you mind telling me what that syntax is with the curly braces so I can read about it? I have not seen that sort of thing before.
Also, I would not mind a comment on general advisability. Is there some reason I should avoid doing this?
@kikinovak: That is very useful! I appreciate it.
Hi Miranden!
The curly braces are a shell syntax that allows you to include a comma separated list of specifiers, usually filenames, along a common path.
Offhand I am not sure if the use of curly braces is really a shell syntax or a bashism, but it is nice to know!
And for completeness, using the corrected example T3slider gave...
Code:
cp -r /root/{*,.[^.]*} /home/testuser/
... copies all visible files and directories, plus anything beginning with a '.' followed by anything that is not a '.', which excludes the parent directory '..'. That is a regular expression in case you are not familiar with it, not a shell idea particularly.
My comment on the advisability of doing this was with the thought in mind that depending on the state of the system and all the vagueries of a given user's home directory, you might very well get some unexpected results such as session variables, locks, email caches, who knows what!
So it is probably safe enough on a clean new home directory, but less so on a system in use. Use care.
Offhand I am not sure if the use of curly braces is really a shell syntax or a bashism, but it is nice to know!
And for completeness, using the corrected example T3slider gave...
Code:
cp -r /root/{*,.[^.]*} /home/testuser/
... copies all visible files and directories, plus anything beginning with a '.' followed by anything that is not a '.', which excludes the parent directory '..'. That is a regular expression in case you are not familiar with it, not a shell idea particularly.
My comment on the advisability of doing this was with the thought in mind that depending on the state of the system and all the vagueries of a given user's home directory, you might very well get some unexpected results such as session variables, locks, email caches, who knows what!
So it is probably safe enough on a clean new home directory, but less so on a system in use. Use care.
Aha, I see. It was gibberish a minute ago, but now it makes perfect sense. That was not nearly as hard as it looked. Thank you!
And I will watch out for those issues you mentioned and be careful doing this sort of copy in the future.
Yay, it worked. I copied the profile successfully, but I wanted to post a follow up in case someone needs this in the future. It was not sufficient to change the permissions with
Code:
chown testuser:users /home/testuser/* -R
I tried it this way, but the hidden files and folders were not affected. I found this was due to shell globbing, so turned this off with
Code:
shopt -s dotglob
Then I was executed the above command again and the ownership changed the way I wanted. Now everything is working perfectly.
I tried it this way, but the hidden files and folders were not affected. I found this was due to shell globbing, so turned this off with
Code:
shopt -s dotglob
Wow. Is this a setting that you had changed, or is it the default? The CLI is my preferred way of doing most things, and I've never come across this before!
Which means when you create a new user, everything that's in /etc/skel will be in the users' home directory. I use this feature to create default user profiles.
I tried that a few months back.
Created a user, logged into KDE, set up some sane defaults.
Copied the newly-created files to /etc/skel.
Created more new users, logged into KDE, settings seemed to be as copied.
But there were one or two files which, IIRC were specific to the original user, or had hard-coded paths in them. So, I just excluded those when copying to skel and most things seem to work.
Last edited by commandlinegamer; 06-06-2013 at 05:26 AM.
Wow. Is this a setting that you had changed, or is it the default? The CLI is my preferred way of doing most things, and I've never come across this before!
Sorry for the delay, I was not subscribed to the thread. Need to fix my preferences.
This is a default bash command. Globbing is the way bash carries out filename expansion with wildcards. It does not use regular expressions, and it does not by default match strings starting with the dot to the wildcard character "*". However, you can change this (and get it to match strings starting with "." to "*") by using the shopt command I gave.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.