LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to duplicate one user's desktop and program settings for another user? (https://www.linuxquestions.org/questions/slackware-14/how-to-duplicate-one-user%27s-desktop-and-program-settings-for-another-user-4175464289/)

Miranden 05-31-2013 07:14 PM

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?

Thanks.

Habitual 05-31-2013 07:49 PM

desktop and relateds are stored in ~/.gconf and ~/.config

so
Code:

cp -pr /root/.gconf/ /root/.config/ /home/testuser/
chown user:users /home/testuser/.config/* -R
chown user:users /home/testuser/.gconf/* -R

should do the job.

kikinovak 06-01-2013 04:19 PM

From man useradd:

Code:

      -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:

https://github.com/kikinovak/desktop...source/profile

Cheers,

Niki

astrogeek 06-01-2013 04:43 PM

Quote:

Originally Posted by Miranden (Post 4963134)
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.

T3slider 06-01-2013 05:22 PM

Quote:

Originally Posted by astrogeek (Post 4963674)
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.

Would that not try to copy / as well (since .* expands to include ..)? I think
Code:

cp -r /root/{*,.[^.]*} /home/testuser/
would be more appropriate (of course this would ignore files starting with ..). I guess the best real solution is
Code:

find /root -mindepth 1 -maxdepth 1 -print0 | xargs -0 -I{} cp -r {} /home/testuser/
or something similar.

astrogeek 06-01-2013 06:13 PM

Quote:

Originally Posted by T3slider (Post 4963685)
Would that not try to copy / as well (since .* expands to include ..)? I think
Code:

cp -r /root/{*,.[^.]*} /home/testuser/
would be more appropriate (of course this would ignore files starting with ..). I guess the best real solution is
Code:

find /root -mindepth 1 -maxdepth 1 -print0 | xargs -0 -I{} cp -r {} /home/testuser/
or something similar.

You are of course correct - things written in haste...

Thanks for the correction!

Miranden 06-02-2013 12:00 AM

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.

astrogeek 06-02-2013 01:32 AM

Quote:

Originally Posted by Miranden (Post 4963839)
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.

For example...

Code:

cp /home/myname/somedir/{readme.txt,afile.txt,another.xml,something*} .
I equivalent to

Code:

cp /home/myname/somedir/readme.txt .
cp /home/myname/somedir/afile.txt .
cp /home/myname/somedir/another.xml .
cp /home/myname/somedir/something* .

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.

Miranden 06-02-2013 02:21 AM

Quote:

Originally Posted by astrogeek (Post 4963872)
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.

For example...

Code:

cp /home/myname/somedir/{readme.txt,afile.txt,another.xml,something*} .
I equivalent to

Code:

cp /home/myname/somedir/readme.txt .
cp /home/myname/somedir/afile.txt .
cp /home/myname/somedir/another.xml .
cp /home/myname/somedir/something* .

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.

astrogeek 06-02-2013 02:30 AM

Quote:

Originally Posted by Miranden (Post 4963894)
And I will watch out for those issues you mentioned and be careful doing this sort of copy in the future.

Yea, you might want to be a little more selective, but now that you know what was missing you can figure it out! Good luck!

Miranden 06-03-2013 10:17 AM

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.

Thanks again to everyone who helped!

rkelsen 06-05-2013 08:56 PM

Quote:

Originally Posted by Miranden (Post 4964629)
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!

commandlinegamer 06-06-2013 05:18 AM

Quote:

Originally Posted by kikinovak (Post 4963659)
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.

Miranden 06-23-2013 12:25 PM

Quote:

Originally Posted by rkelsen (Post 4966260)
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.

Here is the relevant part of the bash manual:

http://www.gnu.org/software/bash/man...-Shopt-Builtin :)


All times are GMT -5. The time now is 10:32 PM.