How to Add a User to Linux With Home Directory and Group Id?
If you are a Linux newcomer and you are wondering how to add user to Linux, then this article is for you. Many people who are new to Linux or not used in using it feel intimidated by the useradd command. But the truth is, useradd is one of the easiest commands to understand. It is like an interface that lets you to create, edit and manage user accounts on your Linux system. Here are some useful tips that you should remember when using the useradd command on Linux.
The first thing you have to do when trying to add user to Linux is, make sure to have your username and password ready. Usually a Linux system comes with a default set of username and password, if you need to change it, just change the values with the help of your Linux package manager. You can also create your own set of username and password, if you don’t find the default ones suitable. After successfully creating a user account, you can log in as the new user. The Linux system will ask for your confirmation to allow you to enter your home directory.
As per the requirement, we can login as the new user. The next step is to enter our new user name, normally the user name is blank but if you want to restrict the user id to a specific group, you can enter a group id for it. Next step is to confirm our new user name, so that we can assign a good user name to the user. When you have successfully entered all these information, your Linux system will assign a good user name and password to your newly created account.
The next command that you have to follow when you want to add user to Linux is useradd command. As per the above command, we are just going to type our user name and our new user id. Next, the system will ask for confirmation, so don’t forget to enter your confirmation. Once your userid is successfully registered, you can login as the new user.
Linux has built-in features for useradd command like creation of home directory, adding and editing users, groupid creation, and many more. These features will help you easily create user and add them to your Linux system. But, if you want to create user without home directory, you can use su command. For groupid installation, you can use chgrp command. The installation is completed after successful completion.
To add user to Linux using adduser command, the first thing that you have to do is to get root privileges. This is needed so that you can execute the chroot command and create home directory for your user. For groupid installation, you can use chgrp command. Now, to adduser demo_user, you can run the following command in Linux console: su – root – demo_user – adduser demo | home directory | directory} The next step is to set the password for your Linux user. You can use the typical password of the Linux system or else you can create a completely new password for yourself. When you set the password of your user, it will be used for logging into the Linux system. For groupid installation, you can use chgrp command.
For adding user to Linux, you have to follow few simple steps. If you want to add user to Linux without home directory, you can use su, but if you want to add user to Linux with home directory and group id, you have to use the chroot command. If you are interested in doing system administration task, you can try to learn the basic adduser commands in Linux.