The following warnings occurred:
Warning [2] Use of undefined constant postnum - assumed 'postnum' (this will throw an Error in a future version of PHP) - Line: 253 - File: inc/plugins/my_activity.php PHP 7.2.13 (Linux)
File Line Function
/inc/plugins/my_activity.php 253 errorHandler->error
/inc/class_plugins.php 139 my_activity_postbit
/inc/functions_post.php 826 pluginSystem->run_hooks
/showthread.php 1070 build_postbit

Welcome to UltratechHost Forum, Guest. Please take the time to register if you haven't, or click

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

guide to “useradd” command in linux part 1

RedHat Guide to “useradd” Command in Linux [Part 1]

In this thread we will be know how to add user in a Linux OS, Prior to that we need to be cleared that useradd/adduser command can only be executed using root previlages.

It has many options and they are:

To add a new user called ‘dinesh‘, use the following command:
#useradd dinesh

When a user is added and we need to assign a password then we need to execute the command as:
#passwd dinesh
Changing password for user dinesh.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

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:

  • Username: User login name used to login into system. It should be between 1 to 32 charcters long.

  • Password: User password (or x character) stored in /etc/shadow file in encrypted format.

  • User ID (UID): Every user must have a User ID (UID) User Identification Number. By default UID 0 is reserved for root user and UID’s ranging from 1-99 are reserved for other predefined accounts. Further UID’s ranging from 100-999 are reserved for system accounts and groups.

  • Group ID (GID): The primary Group ID (GID) Group Identification Number stored in /etc/group file.

  • User Info: This field is optional and allow you to define extra information about the user. For example, user full name. This field is filled by ‘finger’ command.

  • Home Directory: The absolute location of user’s home directory.

  • Shell: The absolute location of a user’s shell i.e. /bin/bash.

So the in general /etc/passwd content stored as follows:

username:password(as x):uid:gid:userinfo:user's home directory:Shell(Absolute Location of a user)

Create a User with Different Home Directory
By default ‘useradd‘ command creates a user’s home directory under /home directory with username. If we want to add the user to a different directory then command will be:

# useradd -d /data/logs harry

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

#cat /etc/passwd | grep harry

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 ‘suraj‘ with custom userid ‘891‘.

# useradd -u 891 suraj

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

# cat /etc/passwd | grep suraj


Dinesh Kumar Mohanty
Ultra Web Solutions®
Bhubaneswar, Odisha, India.

UltratechHost - Your One Stop Offshore & Onshore Hosting Provider
Server Locations : Netherlands, Germany, Russia, Singapore & USA
Service Offers: Shared hosting | Reseller hosting | Cloud server | Dedicated server | VPS Hosting

Forum Jump:

Users browsing this thread: 1 Guest(s)