Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1: Working in your CentOS Linux machine, find out the steps to add users to

ID: 3685237 • Letter: P

Question

Part 1:

Working in your CentOS Linux machine, find out the steps to add users to the system (regular user accounts) without using any tool (like useradd, or a GUI, or anything alike). You must add them “manually” (understand this as modifying the right files, creating the appropriate directories with appropriate files in them, and setting the appropriate ownership and permissions on the directories and files). The user must be able to log in using a password (which could be set on the first log in attempt) into the system to their home directory. The user’s home directory should also include the following directories: Documents, Desktop, Downloads, and Public.

Explanation / Answer

To add/create a new user, all you’ve to follow the command ‘useradd‘ or ‘adduser‘ with ‘username’. The ‘username’ is a user login name, that is used by user to login into the system.

Only one user can be added and that username must be unique (different from other username already exists on the system).

For example, to add a new user called ‘tecmint‘, use the following command.

When we add a new user in Linux with ‘useradd‘ command it gets created in locked state and to unlock that user account, we need to set a password for that account with ‘passwd‘ command.

Once a new user created, it’s entry automatically added to the ‘/etc/passwd‘ file. The file is used to store users information and the entry should be.

The above entry contains a set of seven colon-separated fields, each field has it’s own meaning. Let’s see what are these fields:

2. Create a User with Different Home Directory

By default ‘useradd‘ command creates a user’s home directory under /home directory with username. Thus, for example, we’ve seen above the default home directory for the user ‘tecmint‘ is ‘/home/tecmint‘.

However, this action can be changed by using ‘-d‘ option along with the location of new home directory (i.e./data/projects). For example, the following command will create a user ‘anusha‘ with a home directory ‘/data/projects‘.

You can see the user home directory and other user related information like user id, group id, shell and comments.

3. Create a User with Specific User ID

In Linux, every user has its own UID (Unique Identification Number). By default, whenever we create a new user accounts in Linux, it assigns userid 500, 501, 502 and so on…

But, we can create user’s with custom userid with ‘-u‘ option. For example, the following command will create a

user ‘navin‘ with custom userid ‘999‘.

Now, let’s verify that the user created with a defined userid (999) using following command.

NOTE: Make sure the value of a user ID must be unique from any other already created users on the system.

4. Create a User with Specific Group ID

Similarly, every user has its own GID (Group Identification Number). We can create users with specific group

ID’s as well with -g option.

Here in this example, we will add a user ‘tarunika‘ with a specific UID and GID simultaneously with the help of ‘-u‘ and ‘-g‘ options.

Now, see the assigned user id and group id in ‘/etc/passwd‘ file.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote