LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 05-31-2013, 08:14 PM   #1
Miranden
Member
 
Registered: May 2012
Distribution: Slackware
Posts: 205

Rep: Reputation: 19
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.
 
Old 05-31-2013, 08:49 PM   #2
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,624
Blog Entries: 1

Rep: Reputation: Disabled
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.

Last edited by Habitual; 05-31-2013 at 08:50 PM.
 
1 members found this post helpful.
Old 06-01-2013, 05:19 PM   #3
kikinovak
Senior Member
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: Slackware, Slackware64
Posts: 1,960

Rep: Reputation: 976Reputation: 976Reputation: 976Reputation: 976Reputation: 976Reputation: 976Reputation: 976Reputation: 976
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
 
2 members found this post helpful.
Old 06-01-2013, 05:43 PM   #4
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware [64]X{.0|.1|.2|-current} ::X>=12<=14, FreeBSD_10{.0|.1}
Posts: 2,184

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Quote:
Originally Posted by Miranden View Post
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.
 
1 members found this post helpful.
Old 06-01-2013, 06:22 PM   #5
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,298

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Quote:
Originally Posted by astrogeek View Post
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.
 
2 members found this post helpful.
Old 06-01-2013, 07:13 PM   #6
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware [64]X{.0|.1|.2|-current} ::X>=12<=14, FreeBSD_10{.0|.1}
Posts: 2,184

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Quote:
Originally Posted by T3slider View Post
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!
 
Old 06-02-2013, 01:00 AM   #7
Miranden
Member
 
Registered: May 2012
Distribution: Slackware
Posts: 205

Original Poster
Rep: Reputation: 19
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.
 
Old 06-02-2013, 02:32 AM   #8
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware [64]X{.0|.1|.2|-current} ::X>=12<=14, FreeBSD_10{.0|.1}
Posts: 2,184

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Quote:
Originally Posted by Miranden View Post
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.

Last edited by astrogeek; 06-02-2013 at 02:36 AM.
 
1 members found this post helpful.
Old 06-02-2013, 03:21 AM   #9
Miranden
Member
 
Registered: May 2012
Distribution: Slackware
Posts: 205

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by astrogeek View Post
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.
 
Old 06-02-2013, 03:30 AM   #10
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware [64]X{.0|.1|.2|-current} ::X>=12<=14, FreeBSD_10{.0|.1}
Posts: 2,184

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Quote:
Originally Posted by Miranden View Post
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!
 
Old 06-03-2013, 11:17 AM   #11
Miranden
Member
 
Registered: May 2012
Distribution: Slackware
Posts: 205

Original Poster
Rep: Reputation: 19
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!
 
Old 06-05-2013, 09:56 PM   #12
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,808

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by Miranden View Post
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!
 
Old 06-06-2013, 06:18 AM   #13
commandlinegamer
Member
 
Registered: Dec 2007
Posts: 98

Rep: Reputation: 17
Quote:
Originally Posted by kikinovak View Post
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 06:26 AM.
 
Old 06-23-2013, 01:25 PM   #14
Miranden
Member
 
Registered: May 2012
Distribution: Slackware
Posts: 205

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by rkelsen View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
want to copy all user desktop settings and applications dogwind Linux - Desktop 6 11-23-2009 10:02 AM
Gconf-editor settings not sticking for root, sudo user, or user when run sandaili Fedora 1 07-19-2008 09:31 AM
C program to see user log on in system and print user with real user name also naveen245 Programming 2 12-21-2005 01:53 AM
making a backup of user / program settings Cinematography Linux - General 17 05-14-2005 12:42 AM
Changing a user ID (and preserving desktop settings) aethereal Linux - General 1 11-21-2001 01:12 AM


All times are GMT -5. The time now is 09:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration