sudo useradd linux command with flags and examples | Pro Tech guides

sudo useradd linux command with flags and examples

sudo useradd command in linux is used to create a new user in linux. Their are many flags you can used with useradd command.

Create user in Linux using useradd command in linux with flags | Examples

How to create user in linux using sudo useradd command in linux
Create user in Linux

Hello, guys welcome to the next session on Linux command line tutorial. In this session, you will learn how to use "useradd command" create users in Linux.

To create a "user" we can use a command called "useradd" and with this command, you can use some flags and the user name to create a user.

Let's see how you can create a user using this command.

create user [sudo useradd]

Create user in linux using sudo useradd command in linux
useradd command

$sudo useradd [user Name]

You just need to type "sudo useradd name of the user". The name of the user can be anything.


Creating a password

Create a password in linux sudo useradd
Create a password using the "passwd" command

$sudo passwd [user Name]

You haven't provided any "password" to this user. So whenever this user wants to log in.

He/She will login with the "username" and the "password". But we haven't provided any passwords here.

So this password can be given to the user with the command called the "passwd".

Note:

When you give this command as it is then it will allow you to change the "password" for the root user.

When you use this command with the userName then this will allow me to change the password of that specific user.

And then you need to use "sudo" command because you may have to give the root access in order to change the password of the user.


Important flags in useradd command

These are important and most used flags.

[-m] flag

sudo useradd command in linux with -m flag
(-m) flag with useradd

  • What this flag is going to do is it's going to create a "default home directory" for this user.

Once this command is executed that the home directory with this name will be created.

[-s] flag

sudo useradd command in linux with -s flag
(-s) flag with useradd

  • "-s" is the flag for the "default shell"
  • So this "-s" flag is used for allowing the "user" to use the shell. Whatever you provide after this flag.


[-g] flag

sudo useradd command in linux with -g flag
(-g) flag with useradd

  • "-g" this flag is the "default user" flag.
  • After this flag whatever user you type the user will be assigned that group.
  • So the default group is "users" and I would recommend that you always use the "-g" flag.


[-c] flag

sudo useradd command in linux with -c flag
(-c) flag with useradd


  • "-c" flag is for providing the "comments".
  • You can provide any comments here for this user.


There are much more flags you can use with "useradd" command.

Just use "man command" on with this user add command and you will be able to see what are the flags which you can use with this useradd command.

Conclusion

So this is how you can create a user in Linux.

With the same command, you can create multiple users.

In the next session, I will show you how you can remove a user in Linux.

I hope you enjoyed this tutorial please rate comment and bye.

HAVE A NICE DAY💕

Related,

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Network-Devices,1,Networking,1,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: sudo useradd linux command with flags and examples
sudo useradd linux command with flags and examples
sudo useradd command in linux is used to create a new user in linux. Their are many flags you can used with useradd command.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNlyKiWroOfgGtZcIDyIg-0k5ViWZwUoX6F25xx0UNSjmo1MyLVy5fibiccn-aA4ZrvGo_s5elG9JIGE62BKOmgn5hIdnXK9G92mgkipH6zunwNv4JZDnIIoz2gQEuRi_bUhPvrZRp7Nk/s16000/create-user-in-linux.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNlyKiWroOfgGtZcIDyIg-0k5ViWZwUoX6F25xx0UNSjmo1MyLVy5fibiccn-aA4ZrvGo_s5elG9JIGE62BKOmgn5hIdnXK9G92mgkipH6zunwNv4JZDnIIoz2gQEuRi_bUhPvrZRp7Nk/s72-c/create-user-in-linux.jpg
Pro Tech guides
https://devops-digest.blogspot.com/2021/01/sudo-useradd-linux-command-with-flags.html
https://devops-digest.blogspot.com/
https://devops-digest.blogspot.com/
https://devops-digest.blogspot.com/2021/01/sudo-useradd-linux-command-with-flags.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content