User accounts and file permissions on Ubuntu (P1)

Tram Ho

Today, I will introduce you to the User Account (NSD) and decentralization of access on Ubuntu. This article is divided into two parts: part one about user accounts and part two about permissions on Ubuntu.

In this part 1 article, I would like to introduce the concept of user and user account management on Ubuntu.

Users and Groups of Users.

Ubuntu is a multi-user operating system, which also means that multiple people can use the same Ubuntu computer. So for the purpose of easy management, in Ubuntu there are two concepts: User and Group. User is used to identify a user in the system. And Group is an identifier for a group of users who share a certain feature. A group can have many users and a user can be a member of many groups.

User

  • There are two types of users: super user and regular user .
  • Each user has a unique identifier represented by a UID (User Identification). If people use Username to distinguish users from each other, the system will use UID to distinguish between users.
  • The file that contains all the user accounts information is the /etc/passwd . This file stores all information about the user including the fields: Username: password: UID: GID: Info: Home: Shell on the same line.
  • There are three special user accounts: root, nobody and bin. Root account : is an administrator account, has full access to the system. This is the super user account mentioned above. Because this root account has full access on the system, be very careful because all operations will directly affect the system.
  • Each user will be given a private directory (home directory). This directory is structured as a subdirectory of / home. Take the form /home/username . For the root account, the home directory is / root.
  • In Ubuntu, the user’s password is not located in the /etc/passwd but in the /etc/shadow . Only an administrator can view this /etc/shadow .

User Groups

Ubuntu uses groups to manage users. Each user can join multiple groups and each group also contains many users. When a user’s account is created, a default GID (Group Identification) corresponding to that user is created. People in the group share certain, same rights. The /etc/group contains and controls the list of group members.

Actions to manage Users and groups of Users.

Add and delete a user using the command line

  • To add a new user, we use the command useradd

Syntax: adduser <tên người dùng>

After that, we will enter the necessary information such as password, and some other information.

  • To delete a user, we use the userdel command

Syntax: userdel <tên người dùng>

  • If you want to delete the user directory in / home, you can use the command:

userdel -r <tên người dùng>

Add and delete a group of Users using the command line

Normally, after we create a new user, a corresponding new group will be created. However, if we need to add another group then we use the groupadd command

Syntax: groupadd <tên nhóm>

  • To create a new user and add it to the new group, we use the command useradd

Syntax: useradd -a -G <tên nhóm> <tên người dùng>

  • To add an existing user in the system to the group, we use the command usermod

Syntax: usermod -a -G <tên nhóm> <tên người dùng>

  • To delete a group we use the groupdel command

Syntax: groupdel <tên group>

  • To check the user groups just created, we use the command tail /etc/group

Thus, I have briefly introduced the basics of user accounts in Ubuntu. See you in the next article, part 2 about decentralizing access.

Share the news now

Source : Viblo