How to Move User Account from Linux Server to Another Server

Times change and the needs of your business may mutate as well. Whatever hosting solution you use for your website, sooner or later you may feel the urge to opt for a different hosting service so you will have to migrate your user account. In this article, we are going to have a look at how to move your user account from a Linux server to another server. But first, if you are new to Linux hosting, let’s have a look at what options you have and what are their advantages. 

What is Linux hosting

Web hosting is a type of service that deals with providing you with an uninterrupted web presence. There are different types of hosting services: shared hosting, VPS hosting, and dedicated hosting. All of them provide different quality of service and that’s the reason why eventually you might want to migrate from a weaker solution to a more potent one.

Shared hosting is the type of service that consists in sharing one piece of physical server capacities among several users. There is no order to this sharing, that’s why on this type of hosting you’ll encounter the biggest troubles in terms of performance and security.

Virtual Private Server is so to say an enhanced version of the previous one. It consists too in sharing one physical server, but this sharing is organized with the help of virtualization technology, which allows for dedicating resources to every single user. Nobody disturbs no one, everybody has a fixed number of resources at their disposal and can do with them whatever they want. This makes this service very similar in terms of user experience to a dedicated server, providing users with their RAM, CPU, bandwidth, storage, dedicated IP, and separate operating system. Eventually, it yields to a dedicated server in terms of performance, but it is also a much cheaper option.

Now, it’s perhaps obvious what a dedicated server is – you rent an entire physical server, having all the resources that belong to it at your disposal – but for a correspondingly high price.

As for Linux, it’s one of the operating systems available for your server. In contrast to Windows Server, Linux is a free solution, being also an open-source OS, providing you therefore with an uncountable number of distributions, so you’ll be always able to choose one that suits best to your needs. Linux is also considered a more stable and secure operating system. It’s less susceptible to hacker attacks and viruses and very flexible. 

As you see, there is a big variety of possible hosting solutions, that’s why, if you don’t feel satisfied with a certain server, you can always migrate to another one – and now we’ll see, how it’s done.

Migrating user accounts

One of the main components of a user account on a Linux server is the configuration files that make it up. So, the first thing you need to do is backing up them. These include:

  • /etc/passwd with the user info
  • /etc/group with the group info
  • /etc/shadow with the user’s encrypted password
  • /var/spool/mail with user mails
  • /home/user with user home directory

Keep in mind that Linux user accounts are split into two categories: system users and ordinary or application users. The first ones have default IDs from 0 to 499, and the second ones are ranging from 500 to 60 000.

If we want to copy the user accounts with id above 500, we need to use the following command: 

# mkdir accountbackup

# export UGIDLIMIT=500

# awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > /root/accountbackup/passws.olds

This one is going to sort out the corresponding users from the /etc/passwd file.

Do the same with the /etc/group file:

# awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/group >


Then go to the shadow file: # awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534) {print $1}’ /etc/passwd | tee – |egrep -f – /etc/shadow > /root/accountbackup/shadow.old

Now it’s time for users’ home directory and users’ mails:

# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail

Now, use the scp command to copy all data to a flash drive or a different server.

Backup the data to the new server with these commands:

# cat passwd.old >> /etc/passwd

# cat group.old >> /etc/group

# cat shadow.old >> /etc/shadow

# /bin/cp gshadow.old /etc/gshadow

Together with user’s data and mails:

# tar -zxvf /path/to/location/home.tar.gz

# tar -zxvf /path/to/location/mail.tar.gz


On the quality of hosting depends the quality of your site’s performance, which affects the popularity of the web resource and hence the number of your potential customers and revenues. Therefore, if you feel like you might need a more suitable hosting solution – go and find one. And this guide will certainly facilitate the migration process for you. If you are looking for a hosting provider to migrate your user account to – check out vps hosting debian by HostZealot – they offer a variety of plans to fit any needs and any budget. Take care!