Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #6077

user-management

Skill này làm gì

Tính năng này cho phép bạn quản lý ai có thể truy cập hệ thống Linux và họ được làm gì. Bạn có thể tạo, sửa hoặc xóa tài khoản người dùng, nhóm người dùng vào các nhóm và đặt quyền cụ thể, như lệnh nào người dùng được chạy với quyền quản trị.

Khi nào nên dùng

  • ✓Khi bạn cần thêm hoặc xóa một nhân viên khỏi máy chủ.
  • ✓Khi thiết lập ai được chạy các lệnh quản trị.
  • ✓Để tổ chức quyền truy cập của các nhóm khác nhau vào hệ thống.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/user-management/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/user-management/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để thêm người dùng mới tên 'john' có thể chạy lệnh với quyền quản trị mà không cần mật khẩu?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ chạy các lệnh trên hệ thống Linux để tạo hoặc thay đổi tài khoản, nhóm và quyền. Điều này đảm bảo chỉ những người đúng mới có quyền truy cập vào thông tin đúng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

User Management

Manage users, groups, permissions, sudo access, PAM modules, and LDAP integration on Linux systems. Includes practical scripts for bulk user operations and access auditing.

When to Use

  • Creating and managing local user accounts on Linux servers
  • Configuring sudo access with fine-grained privilege controls
  • Setting up group-based access control for teams
  • Integrating Linux hosts with LDAP or Active Directory for centralized auth
  • Auditing user accounts, permissions, and access patterns
  • Automating bulk user provisioning and deprovisioning

Prerequisites

  • Root or sudo access on the target system
  • shadow-utils package (provides useradd, usermod, etc.) -- installed by default
  • libpam-modules for PAM configuration
  • For LDAP: sssd, realmd, libpam-ldapd, or nslcd packages
  • For auditing: auditd package

User Operations

Creating Users

# Create a user with home directory, default shell, and comment
useradd -m -s /bin/bash -c "Jane Smith" jsmith

# Set the user's password interactively
passwd jsmith

# Create a user with a specific UID and primary group
useradd -m -s /bin/bash -u 1500 -g developers -c "Deploy Account" deploy

# Create a system account (no home, no login shell) for running services
useradd -r -s /usr/sbin/nologin -d /opt/myapp -c "MyApp Service Account" myapp

# Create a user with an expiration date (contractor access)
useradd -m -s /bin/bash -e 2025-12-31 -c "Contractor - Bob Lee" blee

# Create user and add to multiple supplementary groups at creation time
useradd -m -s /bin/bash -G docker,developers,ssh-users -c "Dev User" devuser

Modifying Users

# Add a user to a supplementary group (preserving existing groups with -a)
usermod -aG sudo jsmith
usermod -aG docker,developers jsmith

# Change the user's login shell
usermod -s /bin/zsh jsmith

# Change the user's home directory and move existing files
usermod -d /home/jsmith-new -m jsmith

# Lock a user account (disable login without deleting)
usermod -L jsmith

# Unlock a user account
usermod -U jsmith

# Set an account expiration date
usermod -e 2025-06-30 blee

# Change a user's login name
usermod -l jsmith-new jsmith

# Force password change on next login
chage -d 0 jsmith

# Set password aging: min 7 days, max 90 days, warn 14 days before
chage -m 7 -M 90 -W 14 jsmith

# View password aging info
chage -l jsmith

Deleting Users

# Remove a user and their home directory
userdel -r jsmith

# Remove a user but keep their home directory (for auditing)
userdel jsmith

# Find and reassign files owned by a deleted user (by UID)
find / -uid 1500 -exec chown newowner:newgroup {} \;

Group Management

# Create a new group
groupadd developers

# Create a group with a specific GID
groupadd -g 2000 devops

# Add a user to a group
usermod -aG developers jsmith
# Alternative using gpasswd
gpasswd -a jsmith developers

# Remove a user from a group
gpasswd -d jsmith developers

# Set group administrators (can add/remove members without root)
gpasswd -A jsmith developers

# Delete a group
groupdel developers

# List all groups a user belongs to
groups jsmith
id jsmith

# List all members of a group
getent group developers

# Show all groups on the system
cat /etc/group | cut -d: -f1 | sort

Sudo Configuration

# Always edit sudoers via visudo (syntax validation prevents lockout)
visudo

# Better: use drop-in files in /etc/sudoers.d/
visudo -f /etc/sudoers.d/developers

/etc/sudoers.d/developers

# Allow the developers group to restart specific services
%developers ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart myapp, /usr/bin/systemctl status myapp

# Allow a deploy user full sudo with no password
deploy ALL=(ALL) NOPASSWD: ALL

# Allow ops team to run docker commands only
%ops ALL=(ALL) NOPASSWD: /usr/bin/docker, /usr/bin/docker-compose

# Allow a user to run commands as a specific service account
jsmith ALL=(myapp) NOPASSWD: /opt/myapp/bin/*

# Restrict to specific hosts (useful with centralized sudoers)
jsmith dbservers=(root) /usr/bin/systemctl restart postgresql

# Log all sudo commands to a dedicated file
Defaults log_output
Defaults!/usr/bin/sudoreplay !log_output
Defaults logfile="/var/log/sudo.log"

# Require password re-entry every 5 minutes (default is 15)
Defaults timestamp_timeout=5

# Require password for sudo even if user has NOPASSWD elsewhere
Defaults:jsmith !authenticate

…
Câu hỏi thường gặp

“sudo” là gì?

Sudo là lệnh cho phép người dùng chạy một lệnh dưới danh nghĩa người dùng khác (thường là superuser “root”) với đặc quyền nâng cao. Đây là cách an toàn để cấp quyền quản trị giới hạn.

Làm sao để khóa tài khoản người dùng?

Bạn có thể dùng lệnh 'usermod -L username' để khóa tài khoản, ngăn người dùng đăng nhập mà không xóa tài khoản.

Tôi có thể quản lý quyền cho thư mục không?

Có, bạn có thể dùng các lệnh như 'chmod' và 'setfacl' để kiểm soát ai có thể đọc, ghi hoặc thực thi file và truy cập thư mục.

Chi tiết

Mô tả gốc của tác giả

Manage users, groups, and permissions on Linux systems. Configure sudo and access controls. Use when managing system access.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#6077
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự