how to create new users in linux

How to Create New Users in Linux

By William Miller
AD

Welcome to the world of Linux! One of the core functions of a Linux system administrator or user is adding new users. In the Linux universe, creating a new user is quite straightforward and can be accomplished via the command line or through system GUI tools. Let's delve into the process, along with essential details to ensure you're equipped with the right knowledge.

Creating a new user in Linux involves two primary tasks: adding the user and setting up the user's home directory. Let's explore these in detail.

Creating a New User via the Command Line

The Linux command line is a powerful tool for administrators, offering a fast and efficient way to create new users. The primary command for this task is 'useradd' or the more recent 'adduser' command, which is a superset of 'useradd'.

AD
How to create a user in Linux | ION HowTo
How to create a user in Linux | ION HowTo
How to use the groupadd Command in Linux
How to use the groupadd Command in Linux
Master Linux Special Permissions: SUID, SGID, and Sticky Bit
Master Linux Special Permissions: SUID, SGID, and Sticky Bit

Here's how you can create a new user named 'johndoe':

```bash sudo useradd johndoe ```

To set a password for the new user, use the 'passwd' command:

Linux Commands Cheat Sheet: Essential Commands Every Beginner Should Know
Linux Commands Cheat Sheet: Essential Commands Every Beginner Should Know
How to create a user account on Arch Linux [GUI Method]
How to create a user account on Arch Linux [GUI Method]
Learn Linux from Beginner to Advanced (Part-1) | Essential Terminal Commands Cheat Sheet
Learn Linux from Beginner to Advanced (Part-1) | Essential Terminal Commands Cheat Sheet
```bash sudo passwd johndoe ```

Understanding Useradd Parameters

The 'useradd' command accepts various parameters to customize the user creation process. One common parameter is '-m', which creates the user's home directory if it doesn't exist:

```bash sudo useradd -m johndoe ```

A full list of 'useradd' parameters can be obtained by running 'useradd --help' in the terminal.

AD

Setting Up User Permissions

After creating the user, it's essential to set the proper permissions. You can use the 'chown' command to change the ownership of files and directories:

Basic Linux Commands Cheat Sheet for Beginners 🐧 | Linux Commands
Basic Linux Commands Cheat Sheet for Beginners 🐧 | Linux Commands
StudyWithSTEM is Visuals That Make Ideas Click.
StudyWithSTEM is Visuals That Make Ideas Click.
Master the Art of Managing Windows Users with One Command
Master the Art of Managing Windows Users with One Command
How to Add a User in Linux
How to Add a User in Linux
Linux Help Commands Guide (man, info, --help Explained) | Day 7
Linux Help Commands Guide (man, info, --help Explained) | Day 7
Add a New Group in Linux with groupadd
Add a New Group in Linux with groupadd
```bash sudo chown johndoe:johndoe /home/johndoe ```

In this example, we're setting the ownership of johndoe's home directory to johndoe. This ensures that johndoe has the necessary permissions to access their files.

Creating a New User via GUI Tools (for Debian-based Distributions)

If you prefer a graphical interface, Debian-based distributions like Ubuntu provide user-friendly tools for adding users.

AD

To create a new user using the User Accounts tool:

Learn Linux from Beginner to Advanced (Part-2) | File & Directory Commands Cheat Sheet
Learn Linux from Beginner to Advanced (Part-2) | File & Directory Commands Cheat Sheet
Bash Shell Scripting for Beginners | Linux Automation Basics
Bash Shell Scripting for Beginners | Linux Automation Basics
How to Set Up SFTP User on Linux
How to Set Up SFTP User on Linux
  1. Open the System menu and click on 'Admin' to open the 'Users and Groups' tool.
  2. Click the 'Unlock' button and enter your password to authenticate.
  3. Click the '+' icon to add a new user. Fill in the required details (e.g., username, real name, password, and confirmation) and click 'OK'.
  4. Select the groups you want the user to be a part of and click 'OK'.

Managing User Groups

Linux uses groups to manage user access to resources. You can add users to groups and set permissions for groups, providing a convenient way to manage access control.

To add a user to a group, use the 'usermod' command:

AD
```bash sudo usermod -aG groupname johndoe ```

In this example, we're adding johndoe to the 'groupname' group. The '-a' flag appends the user to the group without removing them from other groups.

Now that you've learned how to create new users in Linux, you're well on your way to becoming a proficient Linux user or administrator. Happy exploring, and remember that continuous practice and experimentation are the keys to mastering any skill!

AD