User Management
Tarih: 2026-06-15 | Kategori: Linux
Etiketler: Linux
User management in Linux operating systems is of vital importance for system security and efficient resource sharing. This section focuses on how to create, manage, and delete users in Linux.
What is a User in Linux?
In Linux systems, users are defined as individuals or entities performing various tasks by logging into the system. User management is crucial for controlled access, resource allocation, and overall system administration.
In Linux, a user is associated with a user account that has several attributes defining their identity and privileges within the system. These attributes include the username, UID (User ID), GID (Group ID), home directory, default shell, and password.
Types of Users
Linux supports two types of users: system users and regular users.
Creating a User
To create a user, use the `useradd` command. For example, to create a user named "john," use the following command:
root@hackerbox:~$ useradd -u 1002 -d /home/john -s /bin/bash john
This command creates a user account for john with a user ID (UID) of 1002, a home directory set as `/home/john`, and a default shell of `/bin/bash`.
You can verify the newly created user account by running the `id john` command. This command shows the ID and group memberships for the john user.
root@hackerbox:~$ id john
uid=1002(john) gid=1002(john) groups=1002(john)
User Attributes
In Linux systems, user accounts have various attributes that define their properties and access privileges.
In Linux systems, registered users are stored in the `/etc/passwd` file. You can display the contents of this file to see the list of users on the system.
root@hackerbox:~$ cat /etc/passwd
root:x:0:0:System Administrator:/root:/bin/bash
...
john:x:1002:1002:John Doe:/home/john:/bin/bash
The user list within the `/etc/passwd` file follows this format:
Changing User Passwords
User passwords can be easily changed using the `passwd` command. For example, to set a new password for the `john` user, use the following command:
root@hackerbox:~$ sudo passwd john
This command prompts you to enter a new password interactively. Note that nothing will appear on the screen as you type for security reasons. Simply type the new password and press ENTER.
Deleting a User
To remove a user named John and their associated files, use the `userdel` command.
root@hackerbox:~$ sudo userdel john
This command deletes the john user's account, including their home directory and all files owned by the user.