Linux Tutorials
About Lesson

Linux User

A user or account of a system is uniquely identified by a numerical number called the UID (unique identification number). There are two types of users – the root or super user and normal users. A root or super user can access all the files, while the normal user has limited access to files. A super user can add, delete and modify a user account. The full account information is stored in the /etc/passwd file and a hash password is stored in the file /etc/shadow. Some operations on a user account are discussed below.Creating a user with a default setting: A user can be added by running the useradd command at the command prompt. After creating the user, set a password using the
passwd utility, as follows:

 

[email protected]:~/Desktop#useradd hackonology
[email protected]:~/Desktop#passwd hackonology
Changing password for user hackonology.
New password: 
Retype new password:
passwd: all authentication tokens updated successfully.

Creating a user with the UID:

You can create a user with a custom UID with the –u option, as follows:

[email protected]:~# useradd -u 4036 hackonology

Creating a user with non-default home directory:

A non-default home directory can be set by executing the following command:

[email protected]:~# useradd –d /home/test hackonology

Adding a user to a primary group and supplementary group:

A systems administrator can specify a primary group and a supplementary one by specifying the –g and –G option, respectively.

[email protected]:~# useradd -g “head” -G “faculty” hackonology

Locking and unlocking a user:

A super user can lock and unlock a user account. To lock an account, one needs to invoke passwd with the -l option.

[email protected]:~# passwd -l hackonology Locking password for user hackonology. passwd: Success

The –u option with passwd unlock an account, as shown below:

[email protected]:~# passwd -u hackonology Unlocking password for user hackonology.
passwd: Success

Changing a user name:

The –l option with the usermod command changes the login (user) name, as shown below:

[email protected]:~# usermod -l “Hackonology5” hackonology

Where “hackonology” is old user name and “hackonlogy5” is new username

Removing a user:

Combining userdel with the –r option drop a user and the home directory associated with that user, as shown below:

[email protected]:~# userdel -r hackonology5

Linux group

Linux group is a mechanism to organise a collection of users. Like the user ID, each group is also associated with a unique ID called the GID (group ID). There are two types of groups – a primary group and a supplementary group. Each user is a member of a primary group and of zero or ‘more than zero’ supplementary groups. The group information is stored in /etc/group and the respective passwords are stored in the /etc/gshadow file. Some operations such as creating, deleting and modifying on a group are discussed below.

Creating a group with default settings:

To add a new group with default settings, run the groupadd command as a root user, as shown below:

[email protected]:~#  groupadd employee

If you wish to add a password, then type gpasswd with the group name, as follow:

[email protected]:~# gpasswd employee
Changing the password for group employee New Password:  Re-enter new password:

Creating a group with a specified GID:

To explicitly specify the GID of a group, execute the groupadd command with the –g option, as follow:

[email protected]:~# groupadd -g 1200 manager

Removing group password:

To remove a group password, run gpasswd –r with the relevant group name, as follow:

[email protected]:~# gpasswd -r employee

Changing the group’s name:

To change the group’s name, run the groupmod command with the -n option as a super user, as shown below:

[email protected]:~# groupmod -n hrmanager employee

Changing the group’s GID:

To change the GID of a group, run the groupmod command with –g, as follow:

 

[email protected]:~# groupmod -g 1050 manager

Deleting a group:

Before deleting a primary group, delete the users of that primary group. To delete a group, run the groupdel command with the group name, as shown below:

[email protected]:~# groupdel employee

Let’s Join our Hacking Team

We Are Indian We Are Great

Hope this article helpful for you. Thank You

Indian Cyber Army | Make IT Secure

Enjoy…Stay Happy…Stay Secure…

Hope this article helpful for you. Thank You


If You Appreciate What We Do Here On Hackonology, You Should Consider:

Hackonology is the fastest growing and most trusted community site where you can find lots of courses, articles about Technology/Hacking/Cracking. Millions of people visit Hackonology! to search or browse the thousands of published articles available FREELY to all.

Let's be a part of Hacker's Community! Join our Hacking Team

We Are Indian We Are Great