to dir
change username 
rev 14 nov 2022
Category: gnu-linux
» usermod↓  title↓   source↓

You only want to do this on a freshly-installed system.
If the system is in production, or has been used for
a while with many files, it is better to just make
a new user, and then copy over the files you want
from the old user.

.........................
➽ usermod:

  # On success, the usermod command does not display any output.

  # You can't change the username of the currently logged-in user.
  # So - you can sudo *as a different user*, or log in as root. 

  # change the username:
  $ usermod -l newusername oldusername

  # make new directory, and move files from old dir to this new one,
  #   with correct file permissions and ownership:
  $ usermod -d /home/newusername -m newusername

  # Change the new username group:
  $ groupmod -n newgroupname oldgroupname
  |
  # or
  # make a new group?
  $ groupadd newgroupname
  # and
  $ usermod -g newgroupname newusername

  # Assign sudo privileges to the new username
  #   (in debian-based distro):
  $ usermod -aG sudo newusername

  # Change the user's ID:
  $ usermod -u nnnn username

  # change the display  name:
  $ usermod -c "First Last" username
  # or
  $ chfn -f "First Last" username

  # Check the changes with the id command:
  $ id newusername

  # Now exit from the root user, log in as new user,
  # and verify if the hostname, username, and $HOME directories are changed:
  $ whoami
  $ echo $HOME


  * https://ostechnix.com/how-to-properly-change-username-in-linux/
      This one looks most clear for basic username change.

  * https://www.makeuseof.com/change-username-of-a-user-on-linux/
  * https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-rename-linux-users-and-their-home-directory/
  * https://linuxize.com/post/usermod-command-in-linux/
      These are good for alternative reading and grokking.

  * https://phoenixnap.com/kb/usermod-linux
      Examples of all the options for usermod. Pretty clear.

.........................
➽ title:

  ...


.......................................................
➽ sources:

  ...


_______________________________________________________
begin dd mmm 2022
-- 0 --