CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
  • Week 1
    • 1.Operating Systems and Linux: What the Kernel Does
    • 2.Free Software and Distributions: The Ecosystem Built by Licenses
    • 3.Installation and Booting: From the Moment You Power On
    • 4.Filesystem Structure and File Types: Everything Is a File
    • 5.Week 1 Comprehensive Review: Time to See Through the Concepts
  • Week 2
  • Week 3
  • Week 4
    • 1.The Four Account Files: Anatomy of the Fields in /etc/passwd · /etc/shadow · /etc/group · /etc/gshadow
    • 2.Account Management Commands and Privilege Escalation: From useradd to sudo
    • 3.The Arithmetic of Permissions: rwx · Octal chmod · Ownership · umask Calculation
    • 4.Special Permissions and ACLs: SetUID · SetGID · Sticky bit · getfacl/setfacl
    • 5.Week 4 Comprehensive Review: Tying the Account and Permission System into One Picture
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
  • Week 12
  • Week 13
  • Week 14
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 1/Week 4/Day 5

Based on the Linux Master 1 exam syllabus·Report an error

Linux Master 1· AssociateWeek 4 · Day 5~25 min read

Day 5 - Week 4 Comprehensive Review: Tying the Account and Permission System into One Picture

📌 Key Takeaways

  • All Linux access control reduces to "which field/bit of which file is what."
  • Account file field counts 7-9-4-4, permissions 644-400-644-400. UID 0 = root (decided by number, not name).
  • usermod -G alone wipes the existing secondary groups — always use -aG.
  • umask 022 → file 644, directory 755. This is because the starting points differ: 666/777.
  • Three security checks: UID 0 accounts · abnormal SetUID binaries · missing /tmp Sticky.

The Four Account Files — Review of Fields and Permissions

This week covered the skeleton of Linux security. We connect the four pieces (account files → management commands → permission arithmetic → special permissions and ACLs) into a single picture.

FilePermissionsField CountKey FieldsPartner
/etc/passwd6447UID(3) · GID(4) · home(6) · shell(7)shadow
/etc/shadow400/6409hash(2) · LastChange(3) · Min(4) · Max(5)passwd
/etc/group6444GID(3) · secondary members(4)gshadow
/etc/gshadow4004group password(2) · administrators(3)group

Points to lock into memory:

  • passwd has 7 fields, shadow 9 fields, group/gshadow 4 fields each
  • UID 0 = root (decided by number, not name)
  • shadow date fields = days since 1970-01-01
  • The primary group is in passwd (GID), secondary groups are in group (member list)

passwd↔shadow and group↔gshadow are pairs split into "public (644, identity/membership) and secret (400, hashes/policy)." Consistency is checked with pwck (passwd/shadow) and grpck (group/gshadow).

Account Management Commands — Mapping Options to Fields

CommandKey OptionsTrap to Watch
useradd-u -g -G -d -s -m -c-g (primary, one) vs -G (secondary, several)
usermod-aG (add) / -G (replace)Forgetting -a loses existing secondary groups
userdel-r (delete home too)Without the option the home remains
passwd-l (lock) -u -e (expire) -d (delete)-l (block) and -d (no password) are opposites
chage-M (Max) -m (Min) -W -EUppercase M=Max, lowercase m=Min
gpasswd-a -d -AUpdates group+gshadow at the same time

⚠️ Trap Review: usermod -G (alone) wipes the existing secondary groups and replaces them. Always -aG. You can assume this shows up on the exam every week.

su vs sudo — Two Models of Privilege Escalation

Categorysusudo
Password requiredTarget user's passwordYour own password
ScopeContinue as that person after switchingDelegates a single command only
Config fileNone/etc/sudoers (edit with visudo)
AuditDifficult (shared password)Left in the log (/var/log/secure)
Login shellsu - (fully applies environment)sudo -i

The hyphen in su - = login shell (fully applies the target's environment). sudoers specifies groups with % (Red Hat=wheel, Ubuntu=sudo). Always edit with visudo (syntax check + lock).

Permission Arithmetic — rwx·Octal·umask

ConversionRule
Weightsr=4, w=2, x=1
Orderowner→group→other, each r→w→x
644rw-r--r-- (regular file)
755rwxr-xr-x (executable/directory)
600rw------- (secret file)
umask file666 − umask
umask directory777 − umask

⚠️ Trap Review: umask 022 → file 644, directory 755. Files start from 666 and directories from 777 (files exclude x by default). The larger the umask, the more restrictive.

On a directory, x = entry (cd), and deleting a file depends not on the file but on the directory's w permission. chown (changing the owner) is possible only for root.

Special Permissions and ACLs — Beyond the 9 Bits

ItemOctalDisplayEffect
SetUID4owner x→sRuns with the owner's privileges (passwd=4755)
SetGID2group x→sGroup execution/directory group inheritance
Sticky1other x→tDeletion protection for shared directories (/tmp=1777)
ACLsetfacl -m+ in lsIndividual user/group permissions

The kernel ignores SetUID on shell scripts (for security). SetUID search = find / -perm -4000. If an ACL exists, there is a + at the end of the ls -l permissions. The mask is the upper bound of named user/group permissions.

Frequently Intertwined Scenarios — Integrated Thinking

Scenario A — Building a new collaboration directory

groupadd devteam
usermod -aG devteam alice
usermod -aG devteam bob
mkdir /shared && chgrp devteam /shared
chmod 2775 /shared          # SetGID: all new files inherit the devteam group
  • SetGID (2) + group write (the w in 7) lets team members edit each other's files. It integrates Day 2 (groups) + Day 3 (permissions) + Day 4 (SetGID).

Scenario B — New employee account + forced change at first login

useradd -m -s /bin/bash -c "New Hire" newbie
passwd newbie               # set the initial password
chage -d 0 newbie           # force a password change at next login
chage -M 90 -W 7 newbie     # change every 90 days, warn 7 days before
  • It integrates Day 1 (shadow fields) + Day 2 (useradd/passwd/chage).

Scenario C — Security check

awk -F: '$3==0{print $1}' /etc/passwd   # UID 0 accounts (only root is normal)
find / -perm -4000 -type f 2>/dev/null  # suspicious SetUID
ls -ld /tmp                              # check Sticky

The first step of real-world breach incident analysis is exactly these three — a UID 0 backdoor account, abnormal SetUID binaries, and a missing Sticky on /tmp. Since a one-line command can instantly check the key holes in system security, this week's content is the basis of real-world security beyond the exam.

📖 Glossary

  • UID 0 : The definition of root privilege. The kernel looks only at this number, not the account name.
  • passwd↔shadow / group↔gshadow : Two pairs split into a public file (identity/membership) and a secret file (hashes/policy).
  • pwck / grpck : Commands that check the consistency of the two pairs.
  • -g vs -G : The option that sets one primary group, and the option that sets several secondary groups.
  • usermod -aG : Adds while keeping existing secondary groups. Forgetting -a replaces them wholesale.
  • chage -d 0 : A technique that sets the last change date to 0 to force a password change at the next login.
  • The hyphen in su - : An indicator to fully apply the target user's login environment (PATH·HOME·profile).
  • visudo : The dedicated command that edits sudoers with syntax checking and locking.
  • wheel / sudo group : The default administrator groups of Red Hat-family and Ubuntu-family systems.
  • umask : A mask that sets the permissions to shave off for newly created files and directories. The larger, the more restrictive.
  • w on a directory : The permission to delete files in it. Unrelated to the file's own permissions.
  • SetUID / SetGID / Sticky : Runs with the owner's privileges / group execution and group inheritance / deletion protection for shared directories.
  • ACL mask : The upper bound of the permissions that named ACL entries can have.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Among the 9 fields of /etc/shadow, which field indicates "the minimum number of days after the password was last changed until it can be changed again"?

Question 2

Which correctly expresses a file with permissions rwxr-x--- in octal and correctly explains its meaning?

Question 3

You want to add user alice to the wheel group while keeping her existing secondary groups. Which is the correct command?

Question 4

When umask is 027, what are the permissions of a newly created directory?

Question 5

Which is correct about su and sudo?

Question 6

What is the most appropriate reason the /tmp directory has permissions 1777 (drwxrwxrwt)?

Question 7

What is the most accurate reason the executable file /usr/bin/passwd needs SetUID?

Question 8

For the file data.csv, the ls -l result is shown as -rw-rw-r--+. Which is correct about what the trailing + sign means and the command to confirm it?

Question 9

During a security check, running awk -F: '$3==0 {print $1}' /etc/passwd printed two names, root and backdoor. What does this result mean?

Question 10

You applied chmod 2770 /share to the directory /share and set the group to team. Which is the most accurate effect of this setting?

Question 11

You want to create a new user account while creating the home directory and copying the default configuration files from /etc/skel. Which is the correct command?

Question 12

Which is correct about the difference between passwd -l user1 and passwd -d user1?

PreviousSpecial Permissions and ACLs: SetUID · SetGID · Sticky bit · getfacl/setfaclWeek 4 · Day 4Next Filesystem Types and Structure: ext2/3/4 · xfs · btrfs · Journaling · Inodes and BlocksWeek 5 · Day 1

Official references

  • Linux Master 1 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • The Four Account Files — Review of Fields and Permissions
  • Account Management Commands — Mapping Options to Fields
  • su vs sudo — Two Models of Privilege Escalation
  • Permission Arithmetic — rwx·Octal·umask
  • Special Permissions and ACLs — Beyond the 9 Bits
  • Frequently Intertwined Scenarios — Integrated Thinking
  • Glossary
  • Practice Questions