how to change username in linux code example
Example 1: linux change username
# login as root and make sure that there are no active processes for user
usermod -l NEW_USERNAME OLD_USERNAME
# if user is running kill user w the following command
userUID=$(id -u OLD_USERNAME) && pkill -U $userUID
Example 2: change user linux
sudo su - username
Example 3: change ubuntu username
# To manage every aspect of the user database, you use the usermod tool.
# To change username (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername
# This however, doesn't rename the home folder.
# To change home-folder, use
sudo usermod -d /home/newHomeDir -m newUsername