• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Linux-Ubuntu | Users
  1. References
  2. Who is logged in (users)
  3. Add a new user (useradd)
  4. Change the user account (usermod)
  5. Delete the user account (userdel)
  6. Hide a user from the login screen
  7. Enable/Disable remote SSH login to a specific user

  1. References
    See this page for more details about user management:
    https://help.ubuntu.com/lts/serverguide/user-management.html
  2. Who is logged in (users)
    Print the user who is currently logged in:
  3. Add a new user (useradd)
    Use the useradd command to add a new user (man useradd):

    The command useradd affects two files "/etc/passwd" and "/etc/group".
    Here's how data is structured in these files:
    • /etc/passwd

      Where:
      • mtitek: user name.
      • x: Placeholder for password. The password is obtained from the "/etc/shadow" file.
      • 1000: User ID.
      • 1000: Group ID.
      • mtitek: Comment.
      • /home/mtitek: Home directory.
      • /bin/bash: User shell.

    • /etc/group

      Where:
      • mtitek: group name.
      • x: Placeholder for password information. The password is obtained from the "/etc/gshadow" file.
      • 1000: Group ID.
      • mtitek: Commas separated list of users that belong to the group.

    Examples:
    • Create a user named "mtitek1" with a default group named "mtitek1".

    • Create a user named "mtitek1" with a default group named "mtitek1".
      + create the home directory "/home/mtitek1".
      + set the "/bin/bash" as the default shell for the user.

    • Create a user named "mtitek1" with a default group named "mtitek1".
      + create the home directory "/home/mtitek1".
      + assign the user to group "group1" and "group2".
      + set the "/bin/bash" as the default shell for the user.

    • Create a user named "mtitek1" with a default group named "mtitek1".
      + set the base home directory to "/mtitek1_home_dir".
      + create the base home directory "/mtitek1_home_dir".

    • Create a user named "mtitek1" with a default group named "mtitek1".
      + set the base directory to "/user_base_dir".
      + create the base home directory "/user_base_dir/mtitek1".
  4. Change the user account (usermod)
    Update the account information of the user (man usermod):

    Examples:
    • Change the user home directory and the user shell:

    • Restrict the user from accessing his account:
  5. Delete the user account (userdel)
    Delete a user (man userdel):

    Examples:
    • Delete the user "mtitek1":
  6. Hide a user from the login screen
    You need to configure AccountsService.
    To hide a user named "admin1", create a file named "/var/lib/AccountsService/users/admin1" and add the following.
  7. Enable/Disable remote SSH login to a specific user
    You may need to edit file "/etc/ssh/sshd_config" and do one the following:
    Reload SSH configs:
© 2025  mtitek