Managing user (linux) 👤

# UID/GUID

$ id

# Changing user id ⮺

Changing a UID does not automatically update file ownership in the filesystem. You need to fix ownership of the user’s files manually.

$ sudo usermod -u 2001 john

# creating user with specific id

# To create a user named john with UID 1050
$ sudo useradd -u 1050 john

# Changing username ⮺

It’s easier than changing id.

A few cautions:

  • Do not modify the currently logged-in user.
  • Ensure you have a second admin path (another account, root shell, SSH session, recovery access).
  • NFS usually cares about numeric UID/GID, not usernames, so matching 1000:1000 across machines is often what matters.
  • Some services cache identities; a reboot after changes is often easier than chasing stale state.
# changes the account name itself.
$ sudo usermod -l newusername oldusername

# You’ll often also want to rename the user’s home directory
$ sudo usermod -d /home/newusername -m newusername

# and if user has matching primagry group with the old name, rename that too:
$ sudo groupmod -n newusername oldusername

# Admin user ⮺

# Create the user
$ sudo adduser newusername

# Give the user administrative (sudo) privileges.
$ sudo usermod -aG sudo newusername

# Verify the group membership
$ groups newusername

# Test the account
## Switch to the user
$ su - newusername
$ sudo whoami
Written on July 2, 2026, Last update on
linux-system