Linux move migrate user info or transfer a copy of “/” tree

Users from the command line:

adduser techmint -G users,<othergroups>
deluser username
addgroup groupname
adduser username newgroup

System backup

This article is about using rsync to transfer a copy of your “/” tree, excluding a few select folders. This approach is considered to be better than disk cloning with dd since it allows for a different size, partition table and filesystem to be used

… … …

This command depends on brace expansion available in both the bash and zsh shells. When using a different shell, --exclude patterns should be repeated manually.
# rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

Using the -aAX set of options, the files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, modification times, ACLs and extended attributes are preserved.

The --exclude option will cause files that match the given patterns to be excluded. The contents of /dev, /proc, /sys, /tmp and /run were excluded because they are populated at boot (while the folders themselves are not created), /lost+found is filesystem-specific. Quoting the exclude patterns will avoid expansion by shell, which is necessary e.g. when backing up over SSH. Ending the excluded paths with * will still ensure that the directories themselves are created if not already existing.

Be aware that you will need a Linux compatible file system, eg: ext4 to maintain symlinks etc, when using the -aAX options.

Copy old user to new user

sudo adduser newuser

sudo usermod -a -G adm,users newuser

sudo cp -av /home/olduser/. /home/newuser/

<or   rsync -aP /home/olduser/. /home/newuser/  >

sudo chown -R –from=olduser newuser:newuser /home/newuser

(logout and in again to see new group permissions active)

find -name "*foo*.filetype" -exec rename 's/foo/bar/' {} ";"

find /folder/. -name bar -type d -execdir mv {} baz \;

-execdir changes directory to the parent before executing the command, so the mv here will be local to each parent directory.

Comments are closed.