0Pricing
Linux Command Line Mastery · Lekcja

Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`

Nauczą się Państwo tworzyć, modyfikować i usuwać konta użytkowników oraz grupy na komputerze z systemem Linux.

Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd` to bezpłatna lekcja Linux Command Line Mastery na CoddyKit. To lekcja 1 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Linux Command Line Mastery, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Linux Command Line Mastery zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Welcome to User Management

In Linux, managing users and groups is crucial for security and organization. Every file and process has an owner, and permissions are often set based on user and group affiliations.

This lesson will teach you how to create, modify, and remove user accounts and groups.

Creating New Users: `useradd`

The useradd command creates a new user account. By default, it creates a new primary group with the same name as the user and assigns a unique User ID (UID).

You'll often need sudo (superuser do) privileges to run this command.

sudo useradd newuser

Customizing Users: Home & Shell

When you create a user, you might want to specify their home directory and default shell. The -m option creates the user's home directory if it doesn't exist, and -s sets their login shell.

Without -m, no home directory is created, which can cause issues.

sudo useradd -m -s /bin/bash devuser

Verifying User Details: `id`

After creating a user, you can verify their existence and check their User ID (UID) and Group IDs (GIDs) using the id command. This helps confirm the account was set up correctly.

id devuser

Understanding Linux Groups

Groups are collections of users. They simplify permission management, allowing multiple users to share access to files and resources without individually setting permissions for each user.

Each user has a primary group (often named after the user) and can belong to multiple supplementary groups.

Creating New Groups: `groupadd`

To create a new group, you use the groupadd command. This is useful for organizing users into functional teams, like 'developers' or 'admins', and then assigning file permissions to that group.

sudo groupadd project_team

Adding Users to Groups: `usermod`

The usermod command modifies an existing user account. To add a user to a supplementary group, use the -aG (append to Group) option.

Remember, -a must be used with -G to append, otherwise -G alone would overwrite existing supplementary groups!

sudo usermod -aG project_team devuser

Modifying User Accounts: `usermod`

Beyond adding to groups, usermod can change various user properties. For example, you can change a user's primary group using -g or update their full name/comment using -c.

Always be careful when modifying user accounts, especially sensitive information.

sudo usermod -c "Developer for Project X" devuser

Removing Users and Groups

To remove a user account, use userdel. The -r option is commonly used to remove the user's home directory and mail spool along with the account.

To remove a group, use groupdel. A group cannot be removed if it's the primary group for any existing user.

sudo userdel -r olduser
sudo groupdel oldgroup

Quick Check: User & Group Commands

Which of the following commands would you use to add an existing user named analyst1 to a new supplementary group named data_team?

Recap: User & Group Management

Congratulations! You've learned the essentials of user and group management in Linux.

  • useradd creates new user accounts.
  • groupadd creates new groups.
  • usermod modifies existing user accounts and can add users to supplementary groups using -aG.
  • userdel and groupdel remove users and groups, respectively.

These commands are fundamental for system administration and maintaining a secure Linux environment.

Często zadawane pytania

Czy lekcja „Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`” jest bezpłatna?

Tak — pełny tekst „Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Linux Command Line Mastery, przejdź na CoddyKit PRO. Kurs Linux Command Line Mastery zawiera 4 lekcji w sumie.

Co nauczysz się w „Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`”?

Nauczą się Państwo tworzyć, modyfikować i usuwać konta użytkowników oraz grupy na komputerze z systemem Linux. Ćwiczysz Linux Command Line Mastery z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Linux Command Line Mastery?

Nie wymagamy żadnego doświadczenia. Linux Command Line Mastery w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 1 z 4.

Ile czasu zajmuje lekcja „Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Linux Command Line Mastery?

Tak. Każda lekcja Linux Command Line Mastery zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Zarządzanie użytkownikami i grupami: `useradd`, `usermod`, `groupadd`
  2. Wprowadzenie do poleceń sieciowych: `ping`, `ip`, `netstat`
  3. Bezpieczny zdalny dostęp: `ssh` i `scp`
  4. Uprawnienia i własność plików za pomocą chmod i chown
← Powrót do Linux Command Line Mastery