Managing Users and Groups in Linux | Linux Tutorial | KodeKloud
Summary
TLDRThis tutorial provides an in-depth guide on managing user and group accounts in Linux. It covers how to create, modify, and delete local user accounts using commands like 'useradd', 'usermod', and 'userdel', along with managing passwords and expiration settings. The script also explains the concept of system accounts and groups, demonstrating how to add users to groups, change primary groups, and modify group memberships. Key administrative commands, such as 'groupadd', 'gpasswd', and 'groupdel', are explored to enhance the efficiency of user management and file permissions in a Linux environment.
Takeaways
- 😀 User accounts in Linux provide each person with their own login, personal files, and settings, which helps improve system security and manageability.
- 😀 The `useradd` command is used to create new user accounts, automatically creating a home directory and assigning a default shell (e.g., `/bin/bash`).
- 😀 User accounts are linked to primary groups, which can be seen and managed through the `/etc/passwd` file.
- 😀 You can set or change user passwords with the `passwd` command, and remove accounts with the `userdel` command. Home directories may remain even after account deletion.
- 😀 The `useradd` command allows you to customize settings like the default shell or home directory by passing additional options.
- 😀 System accounts, created using the `--system` option, are intended for programs or system processes and do not require home directories.
- 😀 The `usermod` command is used to modify user details, such as changing the username, home directory, or login shell, and can also lock or unlock accounts.
- 😀 Expiration dates can be set for user accounts and passwords using `usermod` and `chage`, helping enforce security policies like password rotation.
- 😀 Users can belong to multiple groups in Linux, with one primary group and many secondary groups, and group memberships simplify file access and system permissions.
- 😀 The `groupadd`, `gpasswd`, `usermod`, and `groupdel` commands help manage groups and modify group memberships, which are useful for organizing users and controlling access.
Q & A
What is the main benefit of having separate user accounts on a Linux system?
-Having separate user accounts ensures that each person can have personal files and directories protected by proper permissions. It also allows administrators to limit user privileges to only what is necessary for their tasks, improving both security and minimizing the risk of accidental damage.
What does the command `useradd` do when creating a new user?
-The `useradd` command creates a new user on the system. It automatically creates a corresponding user group, assigns the user a home directory, sets a default shell (typically `/bin/bash`), and copies skeleton files from `/etc/skel` into the new user's home directory.
What happens to a user's home directory when their account is deleted with the `userdel` command?
-By default, the `userdel` command only deletes the user account and group, but it does not remove the user's home directory. The home directory is preserved in case the files are needed later. If you want to delete the home directory and the mail spool, you must use the `userdel -r` command.
How can you change a user's login shell after their account has been created?
-You can change a user's login shell using the `usermod` command with the `-s` option followed by the path to the new shell, e.g., `usermod -s /bin/zsh username`.
What is the purpose of a 'system account' in Linux, and how is it created?
-System accounts are used for services and applications, not for human users. They typically do not have home directories and are assigned numeric user IDs (UIDs) smaller than 1000. They can be created using the `useradd` command with the `-r` option, e.g., `useradd -r cisac`.
How can you prevent a user from logging in without deleting their account?
-To prevent a user from logging in, you can lock their account using the `usermod -L` command. This disables the user's password but does not delete the account, allowing them to still use methods like SSH key authentication if set up.
What is the difference between account expiration and password expiration?
-Account expiration disables login access entirely after a certain date, while password expiration forces the user to change their password after a set period. Users with expired passwords can still log in but must change their password the next time they log in.
How can you add a user to a group in Linux?
-You can add a user to a group using the `gpasswd -a username groupname` command. This adds the specified user to the given group, allowing them to inherit the group’s permissions.
What command can be used to modify a user's primary group?
-You can modify a user's primary group using the `usermod -g newgroup username` command. This changes the primary group of the specified user to the new group.
What happens when a user creates a file in Linux regarding ownership?
-When a user creates a file, the file is owned by the user account and their primary group. The primary group is set during account creation and can be modified using the `usermod` command.
Outlines

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифMindmap

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифKeywords

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифHighlights

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифTranscripts

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифПосмотреть больше похожих видео

Session 13 - General Ledger Configuration ( Microsoft Dynamics 365 )

GROUP PROJECT 3: OS INSTALLATION (IMD163) UITM MACHANG

Active Directory: Episode1 - Installing a first Domain Controller in Server 2019

DevOps for Freshers | Bài 7: Quyền truy cập trong Linux | DevOps cho người mới bắt đầu

Penggunaan Perintah Dasar Linux Debian Dengan Penjelasannya

Create AWS EKS Cluster using Terraform: AWS EKS Kubernetes Tutorial - Part 2
5.0 / 5 (0 votes)