{"id":1567,"date":"2016-01-13T22:42:56","date_gmt":"2016-01-14T06:42:56","guid":{"rendered":"http:\/\/systemsolver.com\/StatlerBlog\/?p=1567"},"modified":"2016-01-13T22:42:56","modified_gmt":"2016-01-14T06:42:56","slug":"linux-move-migrate-user-info","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2016\/01\/13\/linux-move-migrate-user-info\/","title":{"rendered":"Linux move migrate user info or transfer a copy of &#8220;\/&#8221; tree"},"content":{"rendered":"<h3>Users from the command line:<\/h3>\n<p><code>adduser techmint -G users,&lt;othergroups&gt;<br \/>\ndeluser username<br \/>\naddgroup groupname<br \/>\nadduser username newgroup<\/code><\/p>\n<h3>System backup<\/h3>\n<p><a href=\"https:\/\/wiki.archlinux.org\/index.php\/Full_System_Backup_with_rsync\">https:\/\/wiki.archlinux.org\/index.php\/Full_System_Backup_with_rsync <\/a><\/p>\n<blockquote><p>This article is about using <a title=\"Rsync\" href=\"https:\/\/wiki.archlinux.org\/index.php\/Rsync\">rsync<\/a> to transfer a copy of your &#8220;\/&#8221; tree, excluding a few select folders. This approach is considered to be better than <a title=\"Disk cloning\" href=\"https:\/\/wiki.archlinux.org\/index.php\/Disk_cloning\">disk cloning<\/a> with <code>dd<\/code> since it allows for a different size, partition table and filesystem to be used<\/p>\n<p>&#8230; &#8230; &#8230;<\/p>\n<p>This command depends on brace expansion available in both the <a class=\"external text\" href=\"https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Brace-Expansion.html\" rel=\"nofollow\">bash<\/a> and <a class=\"external text\" href=\"http:\/\/zsh.sourceforge.net\/Doc\/Release\/Expansion.html#Brace-Expansion\" rel=\"nofollow\">zsh<\/a> shells. When using a different <a class=\"mw-redirect\" title=\"Shell\" href=\"https:\/\/wiki.archlinux.org\/index.php\/Shell\">shell<\/a>, <code>--exclude<\/code> patterns should be repeated manually.<br \/>\n<code># rsync -aAXv --exclude={\"\/dev\/*\",\"\/proc\/*\",\"\/sys\/*\",\"\/tmp\/*\",\"\/run\/*\",\"\/mnt\/*\",\"\/media\/*\",\"\/lost+found\"} \/ <i>\/path\/to\/backup\/folder<\/i><\/code><\/p>\n<p>Using the <code>-aAX<\/code> set of options, the files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, modification times, <a class=\"mw-redirect\" title=\"ACL\" href=\"https:\/\/wiki.archlinux.org\/index.php\/ACL\">ACLs<\/a> and extended attributes are preserved.<\/p>\n<p>The <code>--exclude<\/code> option will cause files that match the given patterns to be excluded. The contents of <code>\/dev<\/code>, <code>\/proc<\/code>, <code>\/sys<\/code>, <code>\/tmp<\/code> and <code>\/run<\/code> were excluded because they are populated at boot (while the folders themselves are <i>not<\/i> created), <code>\/lost+found<\/code> is filesystem-specific. Quoting the exclude patterns will avoid expansion by <a class=\"mw-redirect\" title=\"Shell\" href=\"https:\/\/wiki.archlinux.org\/index.php\/Shell\">shell<\/a>, which is necessary e.g. when backing up over <a class=\"mw-redirect\" title=\"SSH\" href=\"https:\/\/wiki.archlinux.org\/index.php\/SSH\">SSH<\/a>. Ending the excluded paths with <code>*<\/code> will still ensure that the directories themselves are created if not already existing.<\/p>\n<p>Be aware that you will need a Linux compatible file system, eg: <code>ext4<\/code> to maintain symlinks etc, when using the <code>-aAX<\/code> options.<\/p><\/blockquote>\n<h3>Copy old user to new user<\/h3>\n<p>http:\/\/ubuntuforums.org\/showthread.php?t=1280723<\/p>\n<p>sudo adduser newuser<\/p>\n<p>sudo usermod -a -G adm,users newuser<\/p>\n<p>sudo cp -av \/home\/olduser\/. \/home\/newuser\/<\/p>\n<p>&lt;or \u00a0<code> rsync -aP \/home\/olduser\/. \/home\/newuser\/<\/code>\u00a0 &gt;<\/p>\n<p>sudo chown -R &#8211;from=olduser newuser:newuser \/home\/newuser<\/p>\n<p>(logout and in again to see new group permissions active)<\/p>\n<p><code><\/code><code>find -name \"*foo*.filetype\" -exec rename 's\/foo\/bar\/' {} \";\" <\/code><\/p>\n<p><code>find \/folder\/. -name bar -type d -execdir mv {} baz \\;<\/code><\/p>\n<div class=\"post-text\">\n<p><code>-execdir<\/code> changes directory to the parent before executing the command, so the <code>mv<\/code> here will be local to each parent directory.<\/p>\n<\/div>\n<p><a href=\"http:\/\/superuser.com\/questions\/526966\/how-can-i-migrate-all-of-my-linux-settings-home-directory-to-a-new-computer\">http:\/\/superuser.com\/questions\/526966\/how-can-i-migrate-all-of-my-linux-settings-home-directory-to-a-new-computer<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Users from the command line: adduser techmint -G users,&lt;othergroups&gt; deluser username addgroup groupname adduser username newgroup System backup https:\/\/wiki.archlinux.org\/index.php\/Full_System_Backup_with_rsync This article is about using rsync to transfer a copy of your &#8220;\/&#8221; tree, excluding a few select folders. This approach is considered to be better than disk cloning with dd since it allows for a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-1567","post","type-post","status-publish","format-standard","hentry","category-general","category-linux"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=1567"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1567\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=1567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=1567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=1567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}