January 26, 201214 yr User settings are stored in the Home folder by design. So, if you copy your /home/your-username to your new computer, you should be fine... ...but there are caveats: Permissions. It is common that "programs" (shellscripts, custom build programs) are put in the home folder. To preserve permissions, use the --preserve=mode switch (using cp) or -p (using tar) UserID / GroupID. Even if the usernames are equal on both systems, the user ID do not have to. Usually, this is not a problem, but if you've scripts/programs/settings relaying on the UserID, you should make sure that the user ID and group ID should be the same on the target system.You can find the current userID and groupID by executing id. For example, to change the userID of user "your-username", run sudo usermod --uid 1234 your-username. To change the groupID, you have to run sudo groupmod --gid 1234 your-username. Settings (Firefox profile, appearance, ...) are often stored in hidden folders (or files). Hidden folders/files are prefixed with a dot, like .mozilla for Firefox (and other Mozilla applications). As security is not an issue, and you want to have the copying job done as fast as possible, I suggest a combination of the netcat and tar programs. Both applications are installed by default. Make sure that the firewalls on both computers allows ingoing access to destination port 8888 (source computer) and outgoing to destination port 8888 (target computer). Put the nettop next to the computer so you can run the commands quickly. On the source computer, type the next command in a terminal (do not press Enter yet): tar cz -C/home your-username|nc -l -p 8888 -w 10 Explanation: tar is an utility for packing files cz creates such a packed file ("tarball") The tarball is compressed using the GZip algorithm to lower the file size. -C/home your-username changes the working directory to /home and puts the your-usernamefolder in the tarball nc (netcat) is used for setting up connections between machines easily -l: Listening mode, allows other machines to connect to the current machine -p 8888: Listens on port 8888 (randomly chosen number, it could be any other number higher than 1024 as well) -w 10: quit netcat after 10 seconds silence. You must connect to this source computer within this time. Now go to the target computer (nettop). To add the files to the target machine, type (do not run it yet): nc 192.168.1.2 8888|tar xzp -C/home[/code] 192.168.1.2 is the IP address of the source computer. To get its IP address, run: ifconfig on the source machine 8888 is the port number as entered on the source machine xzp: extracts the GZip-compressed tarball while preserving permissions. -C/home: extracts the your-username folder to /home/your-username Optionally, add the -v switch to the tar command for verbose extraction, so you can get an idea of the progress. This could slow down the copy process because every file has to be printed. Now go to the source computer, press Enter to run the server command. Quickly switch to your nettop and press Enter to run the client command.
January 26, 201214 yr Following files/dirs are required for traditional Linux user management:
/etc/passwd - contains various pieces of information for each user account /etc/shadow - contains the encrypted password information for user's accounts and optional the password aging information. /etc/group - defines the groups to which users belong /etc/gshadow - group shadow file (contains the encrypted password for group) /var/spool/mail - Generally user emails are stored here. /home - All Users data is stored here. You need to backup all of the above files and directories from old server to new Linux server. Commands to type on old Linux system migrating from First create a tar ball of old uses (old Linux system). Create a directory: sudo mkdir /root/move/ Setup UID filter limit: sudo export UGIDLIMIT=500[/code]Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts) ''.str_replace('', '', 'sudo awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig').'' Copy /etc/group file:''.str_replace('', '', 'sudo awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig').'' Copy /etc/shadow file:''.str_replace('', '', 'sudo awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig').'' Copy /etc/gshadow (rarely used):''.str_replace('', '', 'sudo cp /etc/gshadow /root/move/gshadow.mig').'' Make a backup of /home and /var/spool/mail dirs:''.str_replace('', '', 'sudo tar -zcvpf /root/move/home.tar.gz /homesudo tar -zcvpf /root/move/mail.tar.gz /var/spool/mail').'' Where,Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:'" \n".self::process_list_items("'.str_replace('', '', ' RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf). Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf). [*]You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro. [*]export UGIDLIMIT=500 - setup UID start limit for normal user account. Set this value as per your Linux distro. [*]awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig - You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command. [*]tar -zcvpf /root/move/home.tar.gz /home - Make a backup of users /home dir [*]tar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir').'")."\n"'Use scp or usb pen or tape to copy /root/move to a new Linux system.''.str_replace('', '', 'sudo scp -r /root/move/* user@new.linuxserver.com:/path/to/location').'' Commands to type on new Linux systemFirst, make a backup of current users and passwords:''.str_replace('', '', 'sudo mkdir /root/newsusers.baksudo cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak').'' Now restore passwd and other files in /etc/''.str_replace('', '', 'cd /path/to/locationsudo cat passwd.mig >> /etc/passwdsudo cat group.mig >> /etc/groupsudo cat shadow.mig >> /etc/shadowsudo /bin/cp gshadow.mig /etc/gshadow').'' Please note that you must use >> (append) and not > (create) shell redirection.Now copy and extract home.tar.gz to new server /home''.str_replace('', '', 'cd /sudo tar -zxvf /path/to/location/home.tar.gz').'' Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail''.str_replace('', '', 'cd /sudo tar -zxvf /path/to/location/mail.tar.gz').'' Double check the changes went in..''.str_replace('', '', 'cat /etc/passwdls -l /home').'' Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system :''.str_replace('', '', 'sudo reboot').'' Please note that if you are new to Linux perform above commands in a sandbox environment. Above technique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of changes but overall the concept remains the same.
Create an account or sign in to comment