The Blog

add adduser and useradd commands in Linux

Difference between add adduser and useradd commands in Linux

If you are learning Linux, and you are using Ubuntu, you might have gone through the adduser and useradd commands when you try to create a user. You might have wondered what is the difference between them. Let’s go through them carefully.

adduser command

It is always good to use adduser when you add a user if you are new to Linux because, it will do all the job for you. You just give the command

The default values are taken from the /etc/adduser.conf

$ sudo adduser user1

This will create the new user ‘user1’, and create a group named ‘user1’. Then add the user1-to-user1 group. It will create the home directory /home/user1. It will copy files from /etc/skel to the home directory.

It will also prompt you for setting the password and you will be asked to give your information.

You can see that this one command will do everything on its own. We just need to give the username. It’s that simple. So, it is recommended to use this command while creating a user.

useradd Command

In useradd command, you will have to give options explicitly for creating the home directory, changing the default shell, etc.

You can see the default value below

Example

$ sudo useradd user_1 -m -s /bin/bash  -g user -c ‘This is a new user’

-m – for creating the home directory

-s – define the shell

-g define the group

-c for comment

If you are using CentOS, adduser and useradd will not be like this. This can be seen in Ubuntu,Debian

In DevOps Gurukul, we focus on giving hands-on experience while studying so that when you enter the industry, you won’t feel the pressure. DevOps Gurukul is one of the best training academies which provides the Best Linux Training Course Institute in Kerala and the Best DevOps Training Course in Kochi. We have experienced training professionals who are passionate about grooming the right candidates to start their successful careers. Come learn with us and have a bright future!

Leave a Comment

Your email address will not be published.

×

Powered by WhatsApp Chat

× How can I help you?