Linux Users, Groups and Permissions

Learn how Linux decides who may do what. Tell root, regular and system accounts apart, read the account files, and run administrative commands safely with sudo. Create and manage users and groups, read and change ownership and permissions with chown and chmod, set sensible defaults with umask, and use the SUID, SGID and sticky bits. Finish by tracing a "Permission denied" error to its cause and fixing it with the smallest safe change.

BeginnerLesson 5 of 7 in Linux Basics Course

What you will learn

  1. Explain how Linux identifies every user and group by number, tell root, regular and system accounts apart, and read the files that store accounts, groups and password data.
    • Tell root, regular and system accounts apart
      Describe the three kinds of accounts, the user ID that identifies each one, and the commands that show who you are and who is logged in.
    • Explain primary and supplementary groups
      Explain how groups give several users the same access, the difference between a user's primary group and supplementary groups, and which groups carry special rights.
    • Read the passwd, shadow and group files
      Read every field of /etc/passwd, /etc/shadow and /etc/group, explain why password hashes are kept apart, and work out password dates from the shadow file.
  2. Work as a regular user, raise privileges with sudo or su only for the commands that need them, and give other users exactly the administrative rights they need.
    • Use sudo and su to act as root
      Compare su and sudo, run single commands with elevated rights, and avoid the usual sudo pitfalls such as root-owned files and redirection that fails.
    • Grant sudo rights with the sudoers policy
      Read and write sudoers rules with visudo, make a user an administrator through the right group, and limit other users to the few commands they need.
  3. Add users and groups from the command line, set and control passwords, change and remove accounts, and manage who belongs to which group.
    • Create user accounts with useradd and adduser
      Create regular and system accounts with useradd or adduser, know which files and defaults each one uses, and check the result.
    • Manage passwords and change or remove accounts
      Set, lock and expire passwords, apply password aging, change account details with usermod, and remove accounts without leaving problems behind.
    • Create groups and manage membership
      Create, rename and delete groups, add and remove members, and set up a folder that a team can share.
  4. Read the owner, group and permission bits of any file or directory, explain what each permission allows, and change them with chmod, chown and chgrp.
    • Read ownership and permissions in a listing
      Read every part of an ls -l line and work out which permission class applies to a given user.
    • Explain what read, write and execute allow
      Explain what r, w and x allow on a regular file and on a directory, and predict whether an operation such as reading, running, creating or deleting succeeds.
    • Change permissions with chmod
      Set and change permissions with symbolic and octal modes, convert between the two forms, and change whole directory trees safely.
    • Change ownership with chown and chgrp
      Change the owning user and group of files and directory trees, know who is allowed to do so, and predict who owns newly created, copied and moved files.
  5. Choose the permissions new files receive, use the SUID, SGID and sticky bits where they help, and trace a permission error to its cause and fix it with the smallest safe change.
    • Set default permissions with umask
      Work out the permissions of new files and directories from the umask, and set a umask for a session or permanently.
    • Use SUID, SGID and the sticky bit
      Explain the three special permission bits, recognize them in listings, set them with chmod and use them safely for programs, team folders and shared directories.
    • Diagnose permission problems and apply least privilege
      Trace a "Permission denied" error step by step, choose the smallest safe fix, and keep sensitive files and administrator rights tightly restricted.

Linux Users, Groups and Permissions study guide

5 chapters

1

Understand users, groups and the account files

Linux assigns an identity to every person and running service. That identity connects a user ID and group memberships to the files the process may access. Reading your current identity, the active login sessions and the account records makes access decisions easier to explain. The public account file describes who an account is, while protected password records control how password login and aging work.

1.1 Tell root, regular and system accounts apart

Every command runs with an identity. Linux uses that identity to decide which files the command may open and which settings it may change. A user account can represent a person or a service running in the background.

The number behind the name

The kernel identifies an account by its user ID (UID). Names such as alice make the number easier to recognize, but permissions follow the number. The root account has UID 0 and its home directory is /root. An account with another name and UID 0 has the same superuser power.

A regular user is a person's everyday account. On most distributions regular UIDs start at 1000; UID_MIN in /etc/login.defs sets that boundary. A regular user can change their own files and any other files the permissions allow. Changing protected system settings needs elevated rights.

A system account gives a service its own limited identity. Most have UIDs below 1000 and a shell such as /usr/sbin/nologin. The special account nobody commonly has UID 65534, so the range alone does not identify every service account. Debian and Ubuntu use www-data for web services; an SSH service may use sshd.

Read your current identity

Run whoami for your user name or id for the numbers and groups. For example:

uid=1001(alice) gid=1001(alice) groups=1001(alice),27(sudo),1005(developers)

Read the output in three parts. Alice's UID is 1001. Her primary group is alice, GID 1001. Her group list also includes sudo and developers. She is a regular user, not root: the sudo group can authorize elevated commands, but her current shell still runs as Alice.

Many shells display # for root and $ for a regular user. A prompt can be customized, so inspect id when the identity matters. The first account created during installation is often a regular account with sudo access, including on Ubuntu; being created first does not make it root.

Check login sessions
CommandWhat it shows
whoCurrent login sessions, terminals and login times
wCurrent sessions, activity, uptime and load
lastRecorded past logins and reboots, newest first
wtmpdb lastLogin history on systems using wtmpdb

These commands answer a different question from whoami: they report sessions, not just the identity of your shell. Debian 13 is one system that uses wtmpdb for its history.

Separate identities support least privilege, accountability and isolation. A web service can read the files it serves without getting every user's private documents. Logs can show which account acted. If the service is compromised, the attack begins with that service account's rights. Root can bypass ordinary file read and write restrictions, so a second UID 0 account is a serious security concern.

Key Takeaways

  • Linux tracks user identities by UID; UID 0 has root power.
  • Regular accounts serve people; system accounts give services limited identities.
  • id shows your identity and active groups; membership in sudo does not make your shell root.
  • who and w show current sessions; last or wtmpdb last shows recorded history.

1.2 Explain primary and supplementary groups

Sharing a file with a team is easier when the team has a group. Assign the file to that group, give the group the needed permissions, and manage membership as people join or leave.

One primary group, extra memberships

A group has a name and a numeric group ID (GID). Each user has one primary group, stored as a GID in /etc/passwd. A new file normally takes the creating process's primary group. Later, an SGID directory will provide another rule for assigning a new file's group.

Users can also have several supplementary groups. Those memberships add group identities to their processes; the user does not need to switch primary groups each time they open a different team's file. Both primary and supplementary groups count when Linux checks whether the user belongs to a file's group.

Most distributions create a user private group alongside each regular user. Alice may have user name alice, UID 1001, primary group alice and GID 1001. These are still separate user and group identities even when their names and numbers match. A file assigned to Alice's private group is not shared with the whole team.

Inspect a membership

Use groups for your own group names. groups bob and id bob query Bob's memberships; id -Gn prints the current process's group names without numbers. A group lookup might show:

getent group developers
developers:x:1005:alice,bob

The group is named developers, its GID is 1005, and Alice and Bob are listed as supplementary members. An account whose primary GID is 1005 belongs to the group too, even if its name is absent from that final list. To check a person's full membership, use id with their name instead of relying on that list alone.

Apply a group's permissions

Suppose plan.txt belongs to bob:developers and has mode rw-r-----. Alice is not Bob, but she belongs to developers. She therefore uses the middle permission triplet, r--: she can read the plan but cannot change its contents. Chen belongs to neither the owning user nor the group, so he uses the final triplet, ---.

Changing the group name attached to a file does not create permissions by itself. If its group triplet is ---, members still receive no access through that class. Group ownership identifies the team; the permission bits specify what the team can do.

Recognize powerful groups

Some memberships grant much more than access to a project folder. Debian and Ubuntu commonly authorize the sudo group for administrative commands; Fedora and Red Hat Enterprise Linux commonly use wheel. On Debian and Ubuntu, adm allows access to many system logs. The docker group controls the Docker service and effectively provides root-level control.

Before adding someone to a group, identify what it can reach. A project group can be a narrow way to share work, while an administrative group can grant control over the whole machine.

Key Takeaways

  • Every user has one primary group and can have several supplementary groups.
  • New files normally take the creating process's primary group.
  • A user private group usually contains only its matching user.
  • Check a user's full groups with id username; /etc/group need not list primary members.
  • Group ownership and group permission bits work together.
  • Treat memberships such as sudo, wheel and docker as powerful access grants.

1.3 Read the passwd, shadow and group files

Linux keeps public account details separate from password data. Reading the field order helps you explain an account's identity, login setup and password policy without changing the files by hand.

Read an account record

/etc/passwd has seven colon-separated fields:

name:password:UID:GID:comment:home:shell
alice:x:1001:1001:Alice Moreau:/home/alice:/bin/bash

Alice's UID and primary GID are both 1001. The comment, also called the GECOS field, gives her full name. Her home is /home/alice, and her login shell is Bash. The x points to password data in /etc/shadow; it does not mean that her password is empty.

Ordinary users can read /etc/passwd, normally mode 644. Programs need its public details to turn stored UIDs into names. Keeping password hashes in a separate protected file prevents every local user from reading them.

Read password data

/etc/shadow has nine fields: name, password hash, last-change day, minimum age, maximum age, warning days, inactivity days, account-expiration day and a reserved field. Root can read it; some systems also grant access to the shadow group.

A password hash is a one-way result, not reversible encryption. At login the system applies the stored method and salt to the submitted password, then compares the result with the stored hash. A random salt makes the hashes differ even when two users choose the same password. SHA-512 crypt records use $6$salt$hash, optionally with a rounds=N field; yescrypt uses $y$parameters$salt$hash.

A leading ! locks the password while retaining the hash. A field containing only !, !! or * has no usable password. Other login methods, such as SSH keys, may still work with a locked password.

Work out the dates

Consider this shortened hash record:

alice:$y$j9T$...:20514:0:90:7:::

Dates count days since January 1, 1970, UTC. Day 20514 is March 2, 2026. A minimum age of 0 allows an immediate password change; a maximum of 90 means expiration on May 31, 2026. The seven-day warning begins May 24. Empty inactivity and account-expiration fields set neither limit. A last-change value of 0 forces a change at next login; a maximum of 99999 is effectively a very long password lifetime. Password expiration and account expiration are separate fields.

Read group records safely

/etc/group uses name:password:GID:members. In developers:x:1005:alice,bob, the final field lists supplementary members. Primary members are found through the GID in their passwd records. Protected /etc/gshadow stores group password and administrator data.

Use getent passwd alice or getent group developers for lookups. getent consults configured account sources as well as local files. cut -d: -f1,3 /etc/passwd displays local names and UIDs. Change records with account commands such as usermod and passwd; if direct editing is unavoidable, vipw and vigr lock the files during the edit.

Key Takeaways

  • /etc/passwd stores public identity and login details; x points to /etc/shadow.
  • /etc/shadow separates password hashes, password aging and account expiration.
  • A salt makes equal passwords produce different stored hashes.
  • A locked password can leave other login methods available.
  • Shadow dates are day counts from January 1, 1970, UTC.
  • /etc/group lists supplementary members; primary membership comes from /etc/passwd.
  • Use account-management commands to change records and getent to look them up.
2

Run administrative commands safely

Administrative commands can change the whole system, so the identity running them matters. Sudo lets an authorized user run a specific command with elevated rights and records the attempt; su opens another user's shell. A useful policy can grant a team one maintenance action without a general root shell. Reading the rule, editing it safely and checking its effective result are all parts of granting that access.

2.1 Use sudo and su to act as root

Administrative tasks need more access than everyday work. Keep your usual shell under your own account, and raise privileges for the action that needs them. Files created by an elevated command can belong to root even when they are inside your home directory.

Choose sudo or su
CommandWhat startsUsual password requested
suA shell as rootRoot's password
su - bobA login shell as BobBob's password
sudo commandOne command as rootYour own password
sudo -u postgres psqlOne command as postgresYour own password

A login shell loads the target user's login environment, including the home directory and startup files. Use exit to leave a shell started by su. sudo -i opens a root login shell; sudo -s opens a root shell. These are useful for a series of related administrative tasks, but every command in that shell has elevated power until you exit.

Sudo checks its policy before running the command and records the attempt. Logs may go to the system journal, /var/log/auth.log on Debian-family systems, or /var/log/secure on Red Hat-family systems. sudo -l shows the commands your account may run. Permission to use sudo is a policy decision, not a result of knowing somebody else's password.

Understand authentication

By default, sudo asks for the invoking user's password, not root's. Policy can change that behavior. Upstream sudo's authentication timestamp lasts five minutes by default; distribution settings can use another value, such as 15 minutes. The timestamp normally applies within that terminal. Run sudo -k to invalidate it when you finish.

Ubuntu normally starts with no usable root password and puts the installation user in sudo. Fedora and Red Hat-family systems commonly use wheel. A denied attempt can report that the user is not in the sudoers file; the attempt is logged.

Put the write operation under sudo

This command fails when your ordinary account cannot write /etc/hosts:

sudo echo "192.0.2.10 test.local" >> /etc/hosts

Your current shell opens the file for >> before sudo runs. Only echo receives root rights, and echo is not the program opening the destination. Give the writing job to an elevated process:

echo "192.0.2.10 test.local" | sudo tee -a /etc/hosts

Here tee opens the protected file as root. Its -a option appends; leaving that option out would replace the file's contents. For an interactive edit, sudoedit /etc/hosts, also written sudo -e /etc/hosts, runs your editor as you and handles the protected-file update.

Notice root-owned work

After sudo mkdir ~/project, inspect the result with ls -ld ~/project. The directory is in your home, but it was created by root. Its owner permissions therefore apply to root, while your account may have only read and execute access. Restore the intended owner with sudo chown alice: ~/project when Alice owns the project. The trailing colon also selects Alice's login group. Ordinary editing and file creation can then run under Alice's account.

Key Takeaways

  • su normally asks for the target user's password; sudo normally asks for yours.
  • Use sudo -l to inspect allowed commands and sudo -k to invalidate cached authentication.
  • Shell redirection happens before sudo; elevate the program that opens the protected file.
  • sudoedit lets your own editor work on a protected-file copy.
  • An elevated command can create root-owned files inside your home directory.

2.2 Grant sudo rights with the sudoers policy

A sudo rule decides who may run an action, on which host, and under which identity. Giving a team one administrative action can meet its needs without granting unrestricted control over the machine.

Read the parts of a rule

The basic pattern is who where = (as_whom) what. For example:

alice ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL

The first rule lets Alice run any command on any host as any user and group. The second grants the same rights to the sudo group; % marks a group name. A common Red Hat-family rule is %wheel ALL=(ALL) ALL.

To make Alice a full administrator through an existing distribution rule, run sudo usermod -aG sudo alice on Debian or Ubuntu, or use wheel on Fedora and related systems. Alice needs a new login for the membership to reach her session. The -a matters: without it, -G replaces her other supplementary groups.

Edit and check the policy

The main file is /etc/sudoers; additional rules can live in /etc/sudoers.d/. Use sudo visudo or a focused file:

sudo visudo -f /etc/sudoers.d/webteam

visudo locks the policy file during editing and checks its syntax before saving. A broken policy can leave administrators unable to use sudo. Name the file webteam, not webteam.conf: sudo's included-directory handling skips names containing a dot or ending in ~.

Files in the included directory are read in name order. When several rules match, the last matching rule controls the result; the most specific-looking rule does not necessarily win. The include is normally near the end of the main policy, so an extra file can affect a rule written earlier.

Grant one exact action

A team that maintains a web service might receive:

%webteam ALL=(root) /usr/bin/systemctl restart nginx

A member can run sudo systemctl restart nginx. The rule specifies the full command path and its arguments. It does not authorize systemctl stop nginx or bash. Check effective permissions with sudo -l; an administrator can inspect Bob's policy with sudo -l -U bob.

The allowed program also matters. A root shell can do anything. Editors and pagers may start shells, and unrestricted cp or tee can overwrite protected configuration. An apparently short command list can therefore grant full control.

Decide whether a password is needed

NOPASSWD: removes the authentication prompt for a matching command:

backup ALL=(root) NOPASSWD: /usr/local/bin/backup.sh

This can support an automated job. The script must be controlled by root: if backup can rewrite it, the account can replace its contents with any root command. Keep the permitted action narrow as well as protecting the script.

Defaults lines change policy settings. Defaults timestamp_timeout=10 sets a ten-minute authentication timestamp; Defaults logfile=/var/log/sudo.log selects an additional log file. These settings control sudo's behavior, while command rules control the actions it authorizes.

Key Takeaways

  • A sudoers rule specifies who, host, target identity and permitted command.
  • Edit policy with visudo so locking and syntax checking protect the file.
  • An exact command with arguments can authorize one action without authorizing a shell.
  • Protect scripts used by NOPASSWD rules from changes by the invoking account.
  • Names containing a dot are skipped in /etc/sudoers.d/.
  • When multiple rules match, their order matters.
3

Create and manage user and group accounts

An account setup includes more than a login name: it needs a user ID, groups, a home, a shell and an authentication setup. Those details also change as people move between roles or leave. Group management makes team access easier, but running sessions keep the identities they already loaded. Work through creation, later changes and removal while checking both the account records and the files those records identify.

3.1 Create user accounts with useradd and adduser

Creating an account sets up an identity, a login environment and often a home directory. Choosing the options explicitly makes the result predictable across distributions.

Build a regular account

Suppose the group developers already exists. Create Priya's account and set her password in two commands:

sudo useradd -m -s /bin/bash -c "Priya Shah" -G developers priya
sudo passwd priya

-m creates /home/priya and copies the initial files from /etc/skel. -s /bin/bash selects Bash as the login shell, and -c supplies the comment. -G developers adds a supplementary membership; several group names form a comma-separated list without spaces. The account normally also receives a private primary group.

The first command adds account records to /etc/passwd and /etc/shadow, and group records as needed to /etc/group and /etc/gshadow. Its initial password field is locked, often ! or !!. The account exists before it has a usable password. passwd priya sets that password; its prompt keeps the password out of the command line.

Understand distribution defaults

useradd is the low-level account creation command used across Linux distributions. Debian and Ubuntu also provide an interactive adduser script that asks for details and creates a home. On Red Hat-family systems, adduser is another name for useradd, so it does not provide the same interactive workflow.

Without explicit options, useradd depends on local defaults. Red Hat-family defaults commonly create a home; Debian and Ubuntu defaults do not unless -m is supplied. The default shell may also differ. Inspect useradd -D for defaults such as the home base and shell. /etc/default/useradd and /etc/login.defs provide settings including UID ranges, private groups and password aging.

Supply a different home or identity

Useful options describe separate parts of the account:

OptionPurpose
-u 1500Choose a UID
-g staffSelect an existing primary group
-d /data/priyaSet the home path
-e 2026-12-31Set an account-expiration date
-rCreate a system account

A home path in the record does not itself create the directory. Combine -d with -m when the new home must be created. On Debian, omitting -m can leave an otherwise valid account with no home directory to use at login.

For a service identity, sudo useradd -r -s /usr/sbin/nologin backupsvc requests a system UID and a noninteractive shell. System accounts have no home by default. The nologin shell prevents an ordinary interactive shell login under that identity.

Verify the setup

Run getent passwd priya, id priya and ls -la /home/priya. Check the home path, shell, primary group, extra groups and copied hidden files. /etc/skel is a template: adding .bash_aliases there affects later home creation, not homes that already exist. Use simple lowercase account names with digits, hyphens or underscores after the initial letter; spaces and unusual names are rejected or mishandled by many tools.

Key Takeaways

  • Use useradd -m to create a home and copy /etc/skel.
  • Set the initial password separately with passwd.
  • -g chooses a primary group; -G chooses supplementary groups.
  • Debian's interactive adduser differs from the Red Hat-family command of that name.
  • useradd -r creates a system account; a nologin shell prevents an interactive shell login.
  • Verify the account record, groups and home directory after creation.

3.2 Manage passwords and change or remove accounts

An account can need a new password, a different home, a temporary access block or permanent removal. These operations change different parts of the account, so identify the intended result before choosing a command.

Change or age a password

Run passwd to change your own password, normally after entering the current one. An administrator uses sudo passwd priya to set Priya's password without knowing the old one. Password-quality checks may reject short or simple choices.

sudo passwd -S priya reports password status. sudo passwd -l priya locks the password by placing ! before its hash, and sudo passwd -u priya unlocks it. sudo passwd -e priya expires the password so the user must choose another at the next login. Expiring a password is useful when issuing a temporary one.

Use sudo chage -l priya to inspect aging dates. For example:

sudo chage -M 90 -m 1 -W 7 priya

The maximum age is 90 days, the minimum between changes is one day, and warnings begin seven days before expiration. These values go into /etc/shadow. sudo chage -E 2026-12-31 priya sets the expiration date of the whole account, separately from its password lifetime.

Block access without deleting records

A password lock blocks password authentication. It does not remove SSH keys or stop every other authentication method. To disable a departing user's future account logins, lock the password and set a past account-expiration date, such as sudo usermod -e 1 priya. The value 1 is a day count in January 1970, so that date is already past. This does not terminate processes that are already running; those need separate attention.

Modify an existing account

usermod can change the comment with -c, the shell with -s, and the home path with -d. Combine -d and -m to move home contents, as in sudo usermod -d /data/priya -m priya. -l newname changes the login name, but the home and private group keep their existing names unless changed too. -L and -U lock and unlock the password.

To add a supplementary membership, run sudo usermod -aG developers priya. The -a means append. Without it, usermod -G developers priya replaces Priya's entire supplementary list; a previous sudo membership can disappear. Her primary group is a separate setting controlled by -g.

Remove the account and handle its files

sudo userdel priya deletes the account records but leaves the home. sudo userdel -r priya also removes the home and mail spool. The normal command refuses removal while the user still has running processes.

Files elsewhere retain their numeric owner UID. After account deletion, a listing may show 1003 as owner because no name maps to it. Reusing that UID for a new account gives that account ownership of the old files. Use sudo find / -nouser to locate files with no matching user, then archive or reassign them. For a departure, block future logins first, handle running activity and preserve needed files, then delete the account when those tasks are complete.

Key Takeaways

  • Password locking, password expiration and account expiration serve different purposes.
  • Use chage to inspect or change password-aging and account-expiration dates.
  • Keep -a with usermod -G when adding groups without removing existing memberships.
  • Changing a login name does not rename the home directory or private group.
  • userdel -r removes the home and mail spool, but files elsewhere retain the old UID.
  • Archive or reassign remaining files before that UID can be reused.
  • Account expiration does not end processes that are already running.

3.3 Create groups and manage membership

A shared folder needs a group, members, and directory permissions that let those members work. The account database and the groups held by an already running shell can temporarily disagree after a membership change.

Create and maintain the group

sudo groupadd developers assigns the next available GID. Add -g 1500 to choose a specific GID or -r for a system group. Check with getent group developers; an empty final field means no supplementary members are listed yet.

Add a member with either command:

sudo usermod -aG developers priya
sudo gpasswd -a priya developers

sudo gpasswd -d priya developers removes that supplementary membership. sudo gpasswd -M alice,bob developers sets the entire member list, replacing what was there. Choose append, remove or replace according to the intended change.

Refresh a session's groups

After adding Priya, id priya queries the account database and shows the new membership immediately. Plain id in her existing shell reports the groups that shell is actually using. Those were established when the session began.

A new login loads the new list. newgrp developers offers another route: it starts a new shell with developers as the primary group. Use exit to leave that shell. When diagnosing a denied operation, inspect the identity in the session attempting the operation, not just the database entry.

Rename or delete a group

sudo groupmod -n devteam developers changes the name but keeps the GID. Existing files continue to refer to the same numeric group. In contrast, sudo groupmod -g 1600 developers changes the group's number. Files still carrying the old GID 1005 need attention; locate them with sudo find / -gid 1005, then use chgrp to assign the intended group.

sudo groupdel developers refuses if an existing user still has it as their primary group. Set another primary group with usermod -g before deleting it. Deleting a group name does not erase files carrying its former GID.

Set up a team folder

For Priya and Kenji's web team:

sudo groupadd webteam
sudo usermod -aG webteam priya
sudo usermod -aG webteam kenji
sudo mkdir /srv/web
sudo chgrp webteam /srv/web
sudo chmod 2770 /srv/web

After fresh logins, both users can create files in /srv/web. Mode 2770 gives owner and group rwx, others ---, and sets directory SGID. A new file takes group webteam, even when its creator's primary group is their private group. New subdirectories also inherit SGID.

The directory makes team membership useful and keeps others from entering, but each file still has its own mode. With a usual file request of 666, a creator's umask of 002 gives group write, while 022 leaves the group read-only. If team members need to edit each other's files, check these creation defaults as well as the folder.

Key Takeaways

  • Use groupadd to create groups and gpasswd or usermod -aG to add members.
  • Database membership changes reach an existing session after a fresh login or a suitable new shell.
  • Renaming a group keeps its GID; changing its GID leaves existing file GIDs to fix.
  • A group cannot be deleted while an account still uses it as its primary group.
  • A shared SGID directory assigns its group to new files; each file's mode still controls editing.
4

Read and change ownership and permissions

Access depends on two linked questions: which user or group owns an object, and what its permission bits allow. A long listing supplies the evidence, but a file and a directory give the same bits different jobs. Reading a document, entering a folder and deleting a name therefore need different checks. Use chmod to set the allowed actions and chown or chgrp to assign the identities to which those actions apply.

4.1 Read ownership and permissions in a listing

A long listing places the information needed for an access decision on one line. Read the owner and group together with the nine permission bits; the bits alone do not tell you which rights a particular person receives.

Decode a long listing
-rw-r----- 1 priya developers 2048 Oct 22 09:15 report.txt

The first field is the file type plus permissions. The following fields give the hard-link count, owning user, owning group, size in bytes, modification time and name. This regular file belongs to Priya and the developers group. The size is 2048 bytes; the displayed time records the last content modification.

The first character is - for a regular file, d for a directory or l for a symbolic link. You may also meet c and b for character and block devices, p for a named pipe, and s for a socket.

Split the next nine positions into three triplets:

ClassBits hereOrdinary file access
Ownerrw-Read and change contents
Groupr--Read contents
Others---No access through this class

Within every triplet, the positions mean read, write and execute, in that order. A dash marks a missing permission, not an empty slot to skip when counting.

Choose exactly one class

For an ordinary permission check, Linux asks:

  1. Does the process's user match the file owner? Use the owner triplet.
  2. Otherwise, does one of its groups match the file's group? Use the group triplet.
  3. Otherwise, use the others triplet.

The classes do not add together. Suppose Priya owns a file whose full type-and-mode string is ----rw-rw-. Her owner triplet is ---, so she cannot read it through the ordinary bits, even though group and others have rw-. As owner she can change the mode. A less restrictive group or others triplet does not override the selected owner's triplet.

Root can bypass ordinary read and write permission checks. To execute a regular program file, even root needs at least one execute bit on it. A mode check therefore needs both the user's identity and the operation being attempted.

Inspect directories and numbers

ls -ld /srv/web lists the directory itself. Without -d, ls -l /srv/web normally lists entries inside it, which can distract you from a restriction on the directory. ls -a includes hidden names, while ls -n displays numeric owners and groups. Files store UIDs and GIDs; if an account or group has been deleted, an ordinary listing can show the remaining number too.

For a compact report, run:

stat -c '%A %a %U %G %n' report.txt

It can show -rw-r----- 640 priya developers report.txt, placing letters and octal digits side by side. A + after the letters signals extra access-control-list entries. A symbolic link commonly displays lrwxrwxrwx; Linux uses the target's permissions for access, not those displayed link bits.

Key Takeaways

  • Read the file type first, then owner, group and others triplets.
  • The first matching class supplies the ordinary permissions; classes do not combine.
  • Files store numeric UIDs and GIDs even when a listing shows names.
  • ls -ld inspects the directory itself, and stat can show both letter and octal modes.

4.2 Explain what read, write and execute allow

Read, write and execute describe different actions on files and directories. A directory stores names leading to files, so changing a file's contents and removing its name are different permission checks.

Match the bit to the object
BitRegular fileDirectory
rRead or copy contentsList entry names
wChange, overwrite or append contentsCreate, delete or rename entries, with x
xRun as a programEnter and reach named entries

A file with write permission but no read permission can be appended to without being read. For example, a shell can open a writable log for echo text >> log.txt even when cat log.txt fails. An editor often needs both read and write because it first loads the existing contents.

A script run as ./backup.sh needs execute permission and must be readable by its interpreter. If the script is readable but lacks execute, bash backup.sh can still read and run it: Bash is the executable program in that command.

Separate listing from searching

Directory read permission lets you see names. Directory execute, also called search permission, lets you reach an entry by name. With read but no execute, ls can show names, while ls -l cannot obtain their details and may display errors and question marks. You cannot open the named files through that directory.

With execute but no read, the reverse is possible: you can reach notes.txt if you already know its exact name, but cannot list the directory to discover the names. The file's own mode must still allow the requested access.

Trace the whole path

To read /home/priya/notes/public.txt, Kenji needs execute permission on every directory in the path and read permission on the file. If /home/priya is mode 700, its others triplet is ---; Kenji stops there even if public.txt is mode 644. Adding more read permission to the file cannot repair a missing directory search bit above it.

Use ls -ld /home/priya /home/priya/notes to inspect the directories themselves. At each level, choose the class that applies to Kenji and check its execute bit. The relevant class can change from one directory to the next because their owners and groups can differ.

Predict deletion and renaming

Deleting a file removes a directory entry. Kenji needs write and execute on the containing directory, not write on the file. In an ordinary writable directory without the sticky bit, he can remove Priya's read-only file. Conversely, owning a file does not let him delete it from a directory where he lacks write permission.

Removing file write is therefore useful for protecting contents from edits, but it does not protect the name from removal. A directory's sticky bit adds an ownership restriction on deletion and renaming in shared writable folders. File access and directory-entry access answer separate questions.

Key Takeaways

  • File r, w and x control reading, changing and running the file.
  • Directory r lists names; x reaches entries; w with x changes entries.
  • Reaching a file requires execute on every directory in its path.
  • A readable script can be passed to its interpreter even without its own execute bit.
  • Deleting a file depends on its directory's permissions, with an additional restriction in sticky directories.

4.3 Change permissions with chmod

Use chmod to change the permissions of a file or directory you own. Root can change them too. Having write access through a group lets you change file contents, but does not make you the owner or let you set its mode.

Make a focused symbolic change

A symbolic mode has a class, an operator and bits. The classes are u for owner, g for group, o for others and a for all three. + adds permissions, - removes them and = sets that class exactly.

chmod u+x deploy.sh
chmod go-w notes.txt
chmod u=rw,g=r,o= report.txt

The first command adds only the owner's execute bit. The second removes group and others write while retaining their other bits. The third gives the owner read/write, the group read, and others no permissions: rw-r-----.

Specify the class when you want a precise change. If you omit it, as in chmod +w notes.txt, the umask restricts which class bits are affected. With umask 022, that command adds write for the owner only; chmod a+w notes.txt explicitly includes all three classes.

Convert each triplet to an octal digit

Read has value 4, write 2 and execute 1. Add the values present in each class:

DigitBitsCalculation
7rwx4 + 2 + 1
6rw-4 + 2
5r-x4 + 1
4r--4
0---None

For rw-r-----, split into rw-, r--, ---: the digits are 6, 4, 0. chmod 640 report.txt sets those nine ordinary bits, regardless of the previous ordinary mode. Reverse the process for 750: 7 gives rwx, 5 gives r-x, and 0 gives ---, forming rwxr-x---.

Choose a useful final mode

Mode 600 keeps a file private to its owner. Mode 644 lets other users read an ordinary file. Mode 664 also lets the group edit. Private directories commonly use 700, group-readable directories 750, and group-writable directories 770. Programs or public directories commonly use 755.

The same digits mean different useful actions on different objects. Applying 644 to a directory removes execute from every class. Even its owner can no longer enter it or open files through it. Use a directory mode with search permission for the people who need access.

Apply changes through a tree

chmod -R 755 site/ also makes every ordinary file executable. For a tree containing directories and ordinary documents, use conditional execute:

chmod -R u=rwX,go=rX site/

Capital X adds execute to directories and to files that already have an execute bit. Non-executable files become 644; directories become 755. Existing executable files retain execute access. This keeps traversal possible without marking every document as a program. Special bits are separate: GNU chmod preserves directory SUID and SGID unless you explicitly clear them, such as with chmod g-s site/.

Key Takeaways

  • Only the owner or root can change a file's mode.
  • Symbolic + and - change selected bits; = sets a class exactly.
  • Octal modes add read 4, write 2 and execute 1 for each class.
  • An omitted class in symbolic mode makes the umask relevant.
  • Directories need search permission for users who must reach their entries.
  • Capital X supports recursive changes without making every ordinary file executable.

4.4 Change ownership with chown and chgrp

Ownership identifies the user and group whose permission triplets will be checked. Correct ownership can fix a working folder that was accidentally created with sudo, without granting broader access to everybody else.

Read the chown forms

chown can change a user, a group or both:

CommandResult
sudo chown kenji report.txtChange owner; keep the group
sudo chown kenji:webteam report.txtChange owner and group
sudo chown :webteam report.txtChange only the group
sudo chown kenji: report.txtSet owner and Kenji's login group
chgrp webteam report.txtChange only the group

Numeric IDs work too, as in sudo chown 1002:1005 report.txt. The names are resolved to numbers; the file stores those numbers.

Only root can transfer a file to another owning user. An owner can change their own file's group to a group they belong to. Thus Priya can use chgrp webteam plan.txt if she owns the file and belongs to webteam. Membership in finance would also be required to assign it to that group. Another member's ability to edit the file does not grant the ability to change its owner or mode.

Repair an accidental root-owned folder

Kenji ran a creation command with sudo. The listing is:

drwxr-xr-x 2 root root 4096 Oct 22 10:02 /home/kenji/app

He is not the owner and is not using the owning group, so he receives others' r-x. He can inspect and enter the folder, but cannot create entries because write is missing. Making the folder writable by everyone would grant more access than his project needs.

If the project belongs to Kenji, sudo chown -R kenji: ~/app restores his ownership and login group throughout it. His owner triplet is now rwx, so he can create files. Inspect the target path before any recursive ownership command: applying it to /etc or /usr can break system operation. -R means the directory and everything beneath it.

Predict ownership after file operations

A newly created file belongs to the creating process's user. Its group normally comes from that process's primary group, or from an SGID parent directory. Creating an ordinary new copy with cp therefore makes the caller its owner. A same-file-system mv changes the location of an existing file and keeps its owner and group. Copy options that preserve ownership are a separate behavior from an ordinary new copy.

This distinction explains why moving an old file into a shared folder does not apply that folder's group-inheritance rule to it. SGID applies at creation; use chgrp when an existing file's group needs changing.

Combine identity with access

Assigning webteam with chgrp selects who the group class represents. It does not add group read or write. Use chmod to grant the required bits after choosing the group. Changing ownership of an executable can also clear SUID or SGID privileges; inspect its resulting mode when those bits matter.

Key Takeaways

  • chown assigns the owning user or group; chgrp changes only the group.
  • Only root can change the owning user.
  • Owners may assign their files to groups they belong to.
  • A new copy normally belongs to its creator; a same-file-system move keeps ownership.
  • SGID inheritance applies to newly created files, not an existing file moved into the directory.
5

Control default and special permissions and solve access problems

New files inherit creation settings, while special permission bits change how programs or shared directories behave. A team folder works only when its group, inherited group ownership and new file modes agree. When access fails, follow the actual user and path to the first missing right. That diagnosis lets you repair the needed permission while keeping private data and administrator powers restricted.

5.1 Set default permissions with umask

The permissions on a new file come from two inputs: the mode its creating program requests and the process's umask. The mask removes requested bits; it never adds permissions the program did not ask for.

Start with the creation request

Editors and shell redirection usually request 666, or rw-rw-rw-, for ordinary new files. Directory creation usually requests 777, or rwxrwxrwx. A umask is a set of bits to clear from that request. A bit survives only when the request includes it and the mask does not.

For umask 022, keep all requested owner bits, remove group write, and remove others write. A file becomes 644; a directory becomes 755. Read each digit as bits, not as an ordinary decimal amount.

MaskFile requested as 666Directory requested as 777
022644755
027640750
077600700
002664775
033644744

With 027, the group loses write while others lose all three bits. It is useful when a team should read new files but users outside the team should have no access. With 002, group write remains available; the file's owning group still determines who receives it.

Why subtraction fails

Take the file request 666 and mask 033. Each 3 means write plus execute. But each requested file triplet is rw-: execute is already absent. Clearing write and execute leaves r-- for group and others, so the result is 644. Subtracting digits would produce 633, which wrongly suggests execute bits can appear.

For a directory request of 777, clearing those same bits gives 744. That directory lacks group and others execute, so those classes cannot reach its entries even though they can list names. A mask that gives the desired file mode may have an inconvenient directory result.

Inspect and set your mask

Run umask to see the current setting, often displayed with a leading zero, such as 0022. The leading zero is formatting; Linux uses the nine ordinary permission bits. umask -S prints allowed bits, such as u=rwx,g=rx,o=rx for 022; a program can request a subset of those bits.

umask 027 changes the current shell and is inherited by programs it starts. Existing files keep their modes. Use chmod when an already created file needs different rights.

Choose a persistent default

A line such as umask 027 in ~/.profile or ~/.bashrc can set the value for the shells that read that startup file. System defaults can come from /etc/profile or UMASK in /etc/login.defs. Distribution and account setup determine which files are read and when.

Many systems use 022, while private-group setups often use 002 for regular users. A compiler can request executable output with mode 777; under 022 it becomes 755. A text editor's request of 666 has no execute bits, so writing a script does not itself make that script executable.

Key Takeaways

  • A new mode keeps bits requested by the program unless the umask removes them.
  • Ordinary file requests usually start at 666; directory requests usually start at 777.
  • Apply the mask bit by bit; decimal-style subtraction can give the wrong result.
  • Changing the mask affects later creations, not existing files.
  • An inherited shell mask and a program's requested mode are separate inputs.
  • Check both the file and directory results when selecting a default.

5.2 Use SUID, SGID and the sticky bit

Three special bits add behavior beyond the ordinary owner, group and others permissions. Their meaning depends on whether the object is a program or a directory.

Recognize the extra digit

A leading octal digit combines SUID 4, SGID 2 and sticky 1. Mode 4755 is SUID plus ordinary mode 755. Mode 2770 is SGID plus 770. Mode 3770 combines SGID and sticky because 2 plus 1 is 3.

In a long listing, the bits share execute positions. Lowercase s in the owner slot means SUID and owner execute; lowercase s in the group slot means SGID and group execute. A lowercase t in the others slot means sticky and others execute. Uppercase S or T means the special bit is present but execute in that position is absent.

SUID and SGID on programs

SUID lets an executable run with its file owner's effective identity. /usr/bin/passwd commonly appears as -rwsr-xr-x root root: the program can update protected password data while enforcing which user's password the caller may change. Starting it does not give the caller a root shell. Linux ignores SUID on scripts and directories.

SGID on an executable similarly uses the file's group identity. These bits grant program-controlled access, so the program's behavior matters. Never add SUID to a shell, editor or script. An administrator can inventory SUID regular files with sudo find / -perm -4000 -type f 2>/dev/null; use -perm -2000 for SGID files and compare results with the expected system setup.

SGID on a team directory

On a directory, SGID makes new entries take the directory's group, and new subdirectories inherit SGID. Suppose /srv/web belongs to root:webteam, mode 2770, displayed as drwxrws---. Priya has a private primary group but belongs to webteam. When she creates index.html inside this directory, its group becomes webteam.

Its ordinary mode still depends on creation. With a file request of 666 and umask 002, it becomes 664 and Kenji, another team member, can edit it. With 022 it becomes 644, so Kenji has read access only. SGID supplies the group, not an extra write bit.

Sticky directories and deletion

The sticky bit restricts deletion and renaming: with the needed directory access, an entry can be removed by its file owner, the directory owner or root. This makes shared writable directories useful without letting users remove each other's entries. /tmp and /var/tmp commonly use 1777, displayed as drwxrwxrwt. Sticky does not prevent edits to file contents when the file mode permits them. Linux ignores it on regular files.

Set bits with chmod u+s prog, chmod g+s /srv/web or chmod o+t /srv/drop. Clear them with u-s, g-s or o-t. With GNU chmod, chmod 755 /srv/web preserves an existing directory SGID bit; use chmod g-s /srv/web to clear it explicitly.

Key Takeaways

  • SUID uses a program file's owner identity; executable SGID uses its group identity.
  • Directory SGID gives new files its group and passes SGID to new subdirectories.
  • A sticky directory restricts deletion and renaming by ownership.
  • Lowercase s or t includes execute; uppercase S or T lacks execute in that position.
  • SGID group inheritance and the new file's write permission are separate.
  • GNU chmod preserves directory SGID when a three-digit mode is used.
  • Sticky protects entries from removal, not writable contents from editing.

5.3 Diagnose permission problems and apply least privilege

A "Permission denied" error identifies a failed operation, not necessarily a bad file mode. The block may be your session's groups, a parent directory, the file itself or ownership left by an elevated command.

Trace identity, path, class and operation

Start with plain id in the affected session. If a group was recently added, compare the active list with id username, which queries the database. A fresh login can load the new membership.

Next inspect the entire path:

namei -l /srv/reports/q3.txt

namei -l reports owners, groups and modes along the path. You can also inspect each directory with ls -ld. At every object, select the first matching class: owner, otherwise group, otherwise others. Then ask what the attempted operation needs. Reading needs file r and search permission on all parent directories. Creating, removing or renaming an entry needs w and x on its directory, with sticky restrictions where present.

Find the first blocked operation

Kenji belongs to finance and tries cat /srv/reports/q3.txt. The relevant objects are:

drwxr-xr-x root  root     /srv
drwxr-x--- root  finance  /srv/reports
-rw------- maria finance  /srv/reports/q3.txt

Kenji can pass through /srv using others execute. In /srv/reports, his finance membership selects group r-x, so he can pass through there too. On q3.txt, he is not Maria, and the finance triplet is ---. The missing permission is file group read.

If finance members should read the report, Maria or root can run chmod g+r /srv/reports/q3.txt. The resulting mode is 640. It supplies the missing right without giving the group write or opening the report to others. An administrator can test with sudo -u kenji cat /srv/reports/q3.txt, running the command as Kenji rather than testing it as root.

Choose the smallest repair

A correct fix may be adding a team membership, setting group read, restoring a project's owner or adding directory search for the intended class. chmod -R 777 hands every local account write access throughout the tree and makes ordinary files executable. It also cannot solve every cause of an access failure.

Check common causes before editing a large tree: inactive new membership, missing parent x, root-owned work created with sudo, and new files whose umask removed needed team access. FAT32 and exFAT drives do not store native Linux UIDs, GIDs and modes; mount options supply those values, so per-file chmod or chown can fail or have no effect.

Keep private data private

An SSH private key such as ~/.ssh/id_ed25519 should normally be mode 600; its .ssh directory is usually 700. SSH checks private-key protection and can reject an overly accessible key. /etc/shadow remains inaccessible to ordinary users. Full sudo administrators can bypass ordinary file privacy, so keep that group small and grant specific actions when full administration is unnecessary.

Key Takeaways

  • Check the affected session's identity and active groups before changing file modes.
  • Inspect every parent directory as well as the target file.
  • Match the permission to the operation and use the smallest necessary change.
  • Test the result as the affected user; a root test can hide a missing ordinary permission.
  • Creation defaults and non-Linux file systems can explain surprising modes.

Linux Users, Groups and Permissions examples

5 Walkthroughs

1

Read an identity and its account records

13 steps
Connect the user running a command to groups, login details and protected password data.
  1. 1
    IntroductionStart with the identity doing the work

    A file request comes from a running process, and that process carries a user identity and groups. You will read Alice's identity, connect it to account records and distinguish current sessions from stored account details. These are the clues you need before deciding what access her commands receive.

  2. 2
    ExplanationA number gives root its power

    Linux uses a UID, not the spelling of a name, to identify a user. UID 0 is root; regular accounts commonly begin at 1000. Services usually run under limited system accounts with a nologin shell. A service therefore does not need a person's login or full root rights to do its own work.

  3. 3
    ExampleRead Alice's id output

    Alice runs id and sees:

    uid=1001(alice) gid=1001(alice) groups=1001(alice),27(sudo),1005(developers)
    

    The UID identifies Alice. The GID is her primary group. The final list includes her primary group plus sudo and developers. UID 1001 is not root, even though the sudo group may authorize selected elevated commands.

  4. 4
    ChallengeA powerful name or a powerful UID?

    An account named maintainer has UID 0. Another named root-helper has UID 1030. Which identity has root power without using sudo, and why?

    ---reveal---

    Maintainer has root power because its UID is 0. The root-helper name does not change UID 1030 into the superuser identity. Inspect the number, not a suggestive name or a customized prompt.

  5. 5
    ConnectionIdentity and login history answer different questions

    whoami identifies the current user; id adds IDs and groups. who lists current login sessions, and w adds activity, uptime and load. last reports recorded past logins and reboots. On systems using wtmpdb, such as Debian 13, use wtmpdb last for that history. A history entry is not the group list of your current shell.

  6. 6
    ExplanationShare through an extra group

    Alice's primary group is her private group, also named alice. Developers is an extra supplementary group. A process can use both primary and supplementary memberships for group access. Giving a report to developers can therefore share it with Alice and Bob, while assigning it to Alice's private group normally does not share it with coworkers.

  7. 7
    ExampleConnect a report to developers

    The report belongs to bob:developers, mode rw-r-----. Alice is not its owner, but her developers membership selects group r--: she may read, not edit. Chen is outside developers and receives others ---. Setting the owning group identifies the team; the middle triplet determines the team's allowed actions.

  8. 8
    ChallengeAn empty list with a real member

    An account record gives Robin primary GID 1440. The group lookup returns review:x:1440:. Is Robin a review member despite the empty final field?

    ---reveal---

    Yes. Robin's primary GID matches review. The final group field lists supplementary members, so it need not include primary members. A full user lookup with id robin checks both membership kinds.

  9. 9
    ExampleSplit the public account line

    Read alice:x:1001:1001:Alice Moreau:/home/alice:/bin/bash as seven colon-separated fields. Alice is the name, x points to protected password data, 1001 is the UID, and the next 1001 is the primary GID. The remaining fields give a comment, home and login shell. The public passwd record does not contain Alice's readable password.

  10. 10
    ExplanationA hash is checked, not decrypted

    The shadow file stores password hashes and aging fields with restricted access. At login, the password is hashed with the stored method and salt, then compared with the saved result. Different salts let equal passwords have different hashes. A leading ! locks password authentication, but it does not remove every other login method.

  11. 11
    ExampleRead the aging fields

    In alice:$y$j9T$...:20514:0:90:7:::, day 20514 is March 2, 2026. Minimum age 0 allows another change immediately. Maximum age 90 puts expiration on May 31, and warning 7 begins May 24. The empty inactivity and account-expiration fields set neither of those limits. All date values use days since January 1, 1970, UTC.

  12. 12
    ChallengeSeparate password failure from identity

    A lookup shows an account with UID 1090, primary group 1090 and a shadow hash prefixed by !. A teammate says, "The account is gone, so its group no longer matters." What is wrong?

    ---reveal---

    The account still exists with its UID and group. The prefix locks its password; it does not delete its identity. Its files and group memberships still have meaning, and a non-password login method may still be available.

  13. 13
    RecapChoose the right evidence

    Use the active process identity to understand who is acting. Group membership connects that identity to shared rights. Passwd and group records describe public account relationships; shadow holds protected password and aging data. Query with getent, and use account-management commands when records need changing.

2

Elevate one action and read its policy

13 steps
Work through sudo authentication, shell redirection and a narrowly scoped maintenance rule.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionKeep the administrative action in view
  2. 2
    ExplanationSwitch a shell or run one command
  3. 3
    TipCheck rights and temporary authentication
  4. 4
    ChallengeWhose password for another target?
  5. 5
    ExampleFollow the failed append
  6. 6
    ExampleGive the writer elevated rights
  7. 7
    ChallengePreserve the old contents
  8. 8
    ExplanationRead a complete authorization
  9. 9
    TipEdit a rule with syntax protection
  10. 10
    ChallengeA restart grant is not a stop grant
  11. 11
    Key InsightA script can widen a narrow rule
  12. 12
    ChallengeCheck both the policy and the process
  13. 13
    RecapKeep the scope as narrow as the task
3

Create an account and make team access work

15 steps
Build a user environment, refresh group access and handle later account changes.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSet up a usable working identity
  2. 2
    ExampleCreate the account explicitly
  3. 3
    ExplanationComplete the password and home setup
  4. 4
    TipCheck the result in three places
  5. 5
    ChallengeA home path without a home
  6. 6
    ExplanationChoose a password or account change
  7. 7
    ExampleSet aging without confusing dates
  8. 8
    ChallengeKeep existing team memberships
  9. 9
    ExplanationAdd and remove group members
  10. 10
    ExampleCompare database and session
  11. 11
    ChallengeFix the session before the files
  12. 12
    ConnectionGive the team a shared creation point
  13. 13
    Key InsightDeletion leaves numeric ownership behind
  14. 14
    ChallengeA departure has several separate effects
  15. 15
    RecapVerify the records and the working session
4

Read a mode and predict an operation

17 steps
Select the correct permission class, check directories and choose chmod or ownership changes.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionAsk what the user is trying to do
  2. 2
    ExampleBreak the listing into fields
  3. 3
    ExplanationSelect the first matching triplet
  4. 4
    ChallengeThe group does not override the owner
  5. 5
    ExplanationUse each object's meaning of x
  6. 6
    ExampleWalk through a blocked path
  7. 7
    ChallengeA read-only file in a writable folder
  8. 8
    Key InsightAn interpreter reads a script
  9. 9
    ExplanationAdd, remove or set a class
  10. 10
    ExampleConvert 750 one class at a time
  11. 11
    TipKeep directories searchable in a tree
  12. 12
    ChallengeAdd one right without replacing the rest
  13. 13
    ExplanationAssign the right identities
  14. 14
    ExampleRepair the owner of a working folder
  15. 15
    ChallengeMove or create a new copy?
  16. 16
    ChallengeChoose a mode fix or an owner fix
  17. 17
    RecapConnect the identity, object and action
5

Control new modes and trace a denied request

19 steps
Work through umask, team inheritance, sticky directories and the smallest useful repair.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionExplain the mode before changing it
  2. 2
    ExplanationStart from what the program requests
  3. 3
    ExampleApply mask 027 to a file
  4. 4
    ExampleTest the subtraction shortcut
  5. 5
    ChallengePredict two creation results
  6. 6
    TipSeparate future defaults from existing files
  7. 7
    ExplanationRecognize special bits in the display
  8. 8
    ExampleA program gets controlled extra power
  9. 9
    ExampleFollow a new file into the team folder
  10. 10
    ExplanationProtect names in a shared writable directory
  11. 11
    ChallengeEdit without permission to delete
  12. 12
    TipClear a special bit explicitly
  13. 13
    ExplanationAsk four diagnostic questions
  14. 14
    ExampleCheck Kenji's path first
  15. 15
    ExampleLocate the missing right
  16. 16
    ChallengeStop at the blocked parent
  17. 17
    ConnectionCheck the cause behind surprising results
  18. 18
    ChallengeA new default and an existing file need different fixes
  19. 19
    RecapKeep each permission mechanism distinct

Linux Users, Groups and Permissions practice questions

50 Practice Questions in 5 sets

Set 1: Manage accounts and shared files10 Practice Questions

Question 1 of 10

What octal mode represents rwxr-----?
  1. 750
  2. 740
  3. 640
  4. 704
Show answerHide answer
Answer: B
The owner has read, write and execute, totaling 7. The group has read only, totaling 4, and others have no bits, giving 740. Mode 750 is close but adds group execute, which is absent from the supplied triplet.

Question 2 of 10

A program requests mode 666 for a new file under umask 026. What mode results?
  1. 650
  2. 620
  3. 660
  4. 640
Show answerHide answer
Answer: D
The 666 request keeps owner read/write. Mask 026 removes group write and others read/write, so the result is 640. Mode 660 is tempting if only the others mask is applied, but the group mask digit 2 also removes group write; the two classes must be processed separately.

Question 3 of 10

Asha owns brief.txt and belongs to writers, but not sales. What group change may she make without sudo?
  1. chgrp writers brief.txt
  2. chgrp sales brief.txt
  3. chown ben brief.txt
  4. chown ben:sales brief.txt
Show answerHide answer
Answer: A
A file's owner can change its group to one of their own groups, so Asha can assign writers. Changing it to sales exceeds that ordinary-owner rule because she is not a member. Transferring the owning user to Ben requires root even though Asha currently owns the file.

Question 4 of 10

Under the default sudo authentication policy, whose password does sudo -u postgres psql request?
  1. The postgres account's password.
  2. The root account's password.
  3. The invoking user's password.
  4. The owner of psql's password.
Show answerHide answer
Answer: C
Sudo normally authenticates the invoking user, then checks whether policy permits the requested target identity and command. Selecting postgres with -u changes the command's target user, not whose password is checked. Asking for postgres's password describes the usual su behavior instead.

Question 5 of 10

Mei belongs to supplementary groups sudo and editors. An administrator runs usermod -G reviewers mei. What is her supplementary list in a fresh login?
  1. reviewers only.
  2. sudo, editors and reviewers.
  3. sudo and reviewers only.
  4. editors and reviewers only.
Show answerHide answer
Answer: A
Without -a, usermod treats the supplied -G list as the complete supplementary list. Mei therefore loses both previous supplementary memberships. Keeping the old groups would require append mode, -aG; the command does not give sudo membership special protection.

Question 6 of 10

A new account needs home /data/zoe, created now, and Bash as its shell. What command requests all three?
  1. sudo useradd -d /data/zoe -s /bin/bash zoe
  2. sudo useradd -m -c /data/zoe -s /bin/bash zoe
  3. sudo useradd -m -d /data/zoe -c /bin/bash zoe
  4. sudo useradd -m -d /data/zoe -s /bin/bash zoe
Show answerHide answer
Answer: D
-d selects the home path, -m creates it, and -s sets the login shell. A command with only -d records a path but does not explicitly request directory creation. The comment option -c cannot replace either a home-path option or a shell option.

Question 7 of 10

An administrator renames group audit to records without changing its GID. What happens to files assigned to that GID?
  1. They become assigned to each creator's group.
  2. They remain assigned to that same group.
  3. They lose their stored group ownership.
  4. They become assigned to group root.
Show answerHide answer
Answer: B
Files record group ownership as a numeric GID, so changing its name leaves their identity link intact. A listing can resolve the same number to records after the rename. Losing group ownership is the concern when the numeric GID changes without updating the files, not when only the label changes.

Question 8 of 10

/srv/art is root:artists mode 2770. Inez belongs to artists, has primary group inez and umask 027. She creates a file requesting 666. What group and ordinary mode result?
  1. inez, mode 640.
  2. artists, mode 660.
  3. artists, mode 640.
  4. inez, mode 660.
Show answerHide answer
Answer: C
Directory SGID assigns artists as the new file's group. Umask 027 removes group write and all others access from the 666 request, leaving 640. Mode 660 is a tempting result if SGID is mistaken for a grant of group write; SGID supplies ownership, not that permission.

Question 9 of 10

A rule permits %ops ALL=(root) /usr/bin/systemctl reload nginx. What action does it authorize?
  1. Running /usr/bin/systemctl reload nginx as root.
  2. Running /usr/bin/systemctl restart nginx as root.
  3. Running /usr/bin/systemctl reload ssh as root.
  4. Running /usr/bin/systemctl stop nginx as root.
Show answerHide answer
Answer: A
The rule names both the executable path and the exact permitted arguments. Reloading nginx matches that action; restarting nginx does not, even though it manages the same service. An allowed program name does not make all of that program's subcommands available through this rule.

Question 10 of 10

Niko is in lab. /srv is 755, /srv/lab is root:lab mode 740, and its file is ana:lab mode 640. All earlier parents are searchable. What smallest class change lets Niko read the file?
  1. Add group write to the file.
  2. Add others read to the file.
  3. Add group write to /srv/lab.
  4. Add group execute to /srv/lab.
Show answerHide answer
Answer: D
Niko already has group read on the file, but the group triplet on /srv/lab is r--, so he cannot search that directory. Adding group execute supplies the missing path right. Adding file read for others would not help because the directory still blocks the path and Niko uses the group class.
Set 2: Identify accounts and control access10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An account named rescue has UID 0. What administrative power does that identity have?
  1. Regular-user power, UID aside.
  2. Root power, despite its name.
  3. Service-account power, by name.
  4. Sudo-only power, until renamed.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

An account has primary GID 1420. The group record is design:x:1420:. Does the empty final field mean the account is outside design?
  1. Yes; members must be listed in that field.
  2. Yes; design must also be supplementary.
  3. No; empty groups include every account.
  4. No; its primary GID makes it a member.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

In nora:x:1042:1042:Nora:/home/nora:/bin/bash, what does x mean?
  1. Password data is stored in /etc/shadow.
  2. The account has no usable login shell.
  3. The account has an empty password.
  4. Password data is stored in /etc/group.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A shadow record has last-change day 21000, maximum age 60 and warning 5. On which day does its warning period begin?
  1. Day 21005.
  2. Day 21060.
  3. Day 21055.
  4. Day 21065.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Why can sudo echo "ready" >> /etc/team-status fail when the file is root-writable only?
  1. Sudo runs echo without changing its identity.
  2. Echo cannot write text through redirection.
  3. The ordinary shell opens the destination.
  4. The destination needs execute permission.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

On Debian with home creation disabled by default, what useradd option creates the new user's home?
  1. -s
  2. -m
  3. -c
  4. -G
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Omar must replace an issued password at his next login, but the account should stay available. What command applies that change?
  1. sudo passwd -e omar
  2. sudo passwd -l omar
  3. sudo usermod -e 1 omar
  4. sudo userdel omar
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

After a group addition, id lena includes media, but plain id in Lena's old shell does not. What should Lena do before retrying group access?
  1. Change the group's numeric GID.
  2. Create the group a second time.
  3. Give files her private group.
  4. Start a fresh login session.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Ravi owns a regular file with mode 004 and belongs to its owning group. What ordinary permission class controls his read attempt?
  1. The owner class, so reading is denied.
  2. The group class, so reading is denied.
  3. The others class, so reading is allowed.
  4. The combined classes, so reading is allowed.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Tariq is in docs. /srv is root:root mode 755, /srv/notes is root:docs mode 750, and a.txt inside it is maya:docs mode 440. Can Tariq read and delete it using ordinary permissions?
  1. Read no; delete yes.
  2. Read yes; delete no.
  3. Read yes; delete yes.
  4. Read no; delete no.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Predict modes and directory access10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Which symbolic change adds execute only for the owner of check.sh while keeping other bits?
  1. chmod a+x check.sh
  2. chmod u=x check.sh
  3. chmod g+x check.sh
  4. chmod u+x check.sh
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Luz has directory execute but no directory read on /srv/box. She knows a file's exact name, and that file gives her read. What can she do?
  1. List the directory names but not read the file.
  2. Read that file but not list the directory names.
  3. List the directory names and read the file.
  4. Neither list the names nor read the file.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A program requests a new regular file at 666 under umask 013. What ordinary mode results?
  1. 664
  2. 653
  3. 654
  4. 665
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

What happens to an existing mode-644 file when its owner runs umask 077?
  1. It becomes mode 600.
  2. It becomes mode 700.
  3. It stays mode 644.
  4. It is 600 after login.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What does drwxr-S--- say about the group's SGID and execute bits?
  1. SGID is set; group execute is absent.
  2. SGID is absent; group execute is set.
  3. SGID and group execute are both set.
  4. SGID and group execute are both absent.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

An existing file owned by ben:ben is moved into an SGID team folder on the same file system. What ownership does it retain?
  1. ben:team
  2. root:team
  3. root:ben
  4. ben:ben
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

/srv/drop is root:shared mode 3770. Dev and Eva are active members of shared. Eva creates a file requesting 666 with umask 002. Can Dev edit and delete her file under ordinary permissions?
  1. Edit no; delete yes.
  2. Edit yes; delete no.
  3. Edit yes; delete yes.
  4. Edit no; delete no.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A tree has no special bits: its directories are 700, its documents 600 and its executable tools 700. What does chmod -R u=rwX,g=rX,o= tree/ produce?
  1. Directories 740; documents 640; tools 740.
  2. Directories 750; documents 650; tools 750.
  3. Directories 750; documents 640; tools 750.
  4. Directories 755; documents 644; tools 755.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

The directory is root:review mode 705. Sam belongs to review and is not root. What directory rights does Sam receive from the ordinary classes?
  1. Read and execute.
  2. No directory permissions.
  3. Write and execute.
  4. Read only.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Oli can read x.txt but cannot rename it inside root:team mode 1750; Oli is in team and owns x.txt. Which smallest permission change enables the rename while retaining sticky?
  1. Add owner write to the file.
  2. Remove sticky from the directory.
  3. Add group write to the directory.
  4. Add others write to the directory.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Choose safe administrative changes10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

What tool locks and syntax-checks a sudoers policy file during editing?
  1. visudo
  2. usermod
  3. sudoedit
  4. gpasswd
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A site includes /etc/sudoers.d/, but the valid rule in release.conf is not applied. What filename change allows that rule file to be read?
  1. Rename it to release.conf~.
  2. Rename it to .release.
  3. Rename it to release.
  4. Rename it to release.rules.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A user's password is locked, but their SSH-key login still works. What account change addresses future account logins without deleting their files?
  1. Expire only the user's password.
  2. Set a longer minimum password age.
  3. Remove the home path from the account record.
  4. Set an account-expiration date in the past.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Which command changes only the group of draft.txt to authors?
  1. chown authors draft.txt
  2. chgrp authors draft.txt
  3. chmod authors draft.txt
  4. usermod -g authors draft.txt
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A helper may run a root-owned backup script through NOPASSWD sudo, but the helper can write that script. Why does this rule give wider power than one fixed backup?
  1. The helper can bypass only the script's password prompt.
  2. The helper can replace its contents with root commands.
  3. The helper can change only the backup's output as root.
  4. The helper can run only its original commands as root.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

User pat with UID 1088 is deleted, leaving /data/archive owned by 1088. A new account receives UID 1088. What explains its access to that archive as owner?
  1. The archive remembers the deleted login name.
  2. Deleting a user makes their files public.
  3. Ownership follows the reused numeric UID.
  4. New accounts inherit old files' group rights.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Rae can read but not edit memo in /srv/review. The directory is root:review 2750 and memo is jo:review 640; Rae is in review. Rae only needs in-place content changes. What smallest fix meets that need?
  1. Add group write to memo.
  2. Add directory group write.
  3. Set the directory to 2777.
  4. Make Rae own the directory.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Two accounts choose the same password but their stored hashes differ. How can salts explain this?
  1. A salt encrypts each password for later decryption.
  2. A salt changes each account's UID at every login.
  3. Different salts remove the need to check passwords.
  4. Different salts make the hash computations differ.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

On GNU/Linux, a team directory starts at 2770. An administrator runs chmod 750 team/, then creates a subdirectory inside it. What special-bit behavior should they expect?
  1. The parent loses SGID, and the new subdirectory lacks it.
  2. The parent keeps SGID, but the new subdirectory lacks it.
  3. The parent keeps SGID, and the new subdirectory inherits it.
  4. The parent loses SGID, but the new subdirectory gains SUID.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Group research is still Kim's primary group. Why does ordinary groupdel research refuse, even after Kim is removed from its supplementary member list?
  1. Kim's primary GID still refers to research.
  2. The group must first receive a new name.
  3. The empty member list locks the group.
  4. Every group must retain a supplementary member.
Show answerHide answer

Save this lesson to see this answer.

Set 5: Trace access across users and paths10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

You need the UID and active groups of the shell attempting a file operation. What command should run in that shell?
  1. who
  2. last
  3. id
  4. getent group
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Uma is in group qa. /srv is 755; /srv/qa is root:qa mode 2710, and result inside is lee:qa mode 640. All earlier parents are searchable. Can Uma list names, read the known file and create a new file?
  1. List yes; read yes; create no.
  2. List no; read yes; create no.
  3. List no; read no; create no.
  4. List no; read yes; create yes.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A team needs ordinary new files at 660 and new directories at 770. Programs request 666 and 777 respectively. What umask supplies both?
  1. 007
  2. 006
  3. 017
  4. 027
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An allowed sudo action must append the line "complete" to protected /var/log/team-run. What command elevates the writing process and preserves prior contents?
  1. sudo echo "complete" >> /var/log/team-run
  2. echo "complete" | sudo tee /var/log/team-run
  3. sudo echo "complete" > /var/log/team-run
  4. echo "complete" | sudo tee -a /var/log/team-run
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A non-root user creates a new ordinary copy of a colleague's file with plain cp. Who owns the new destination file?
  1. The source file owner.
  2. The user running cp.
  3. The directory's owner.
  4. The file's group admin.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Noor is in edit. /srv/edit is root:edit 2770. Noor can create files there, but an existing kai:edit file is 640 and she cannot append. Creators use programs requesting mode 666. What change to future ordinary file creation lets teammates append without opening files to others?
  1. Set the directory's mode to 3770.
  2. Set the creators' umask to 027.
  3. Clear the directory's SGID bit.
  4. Set the creators' umask to 007.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Group editors changes GID from 1620 to 1720. Existing project files still show numeric group 1620. What explains that result?
  1. The group record changed, but those stored file GIDs did not.
  2. The rename changed the files' owners instead of groups.
  3. The files received the creators' current primary groups.
  4. The membership list reset the files' group permission bits.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A directory listing gives mode drwxrwx---, owner teo, group build. Teo is also in build. What class is used for Teo's ordinary access?
  1. Group, because Teo belongs to build.
  2. Both classes, because Teo matches both.
  3. Owner, because that match is checked first.
  4. Others, because it is a directory.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A writable directory is mira:team mode 1770. Ren is in team; Sol owns an entry there. Who among Mira and Ren may delete Sol's entry under the ordinary bits and sticky rule?
  1. Both Mira and Ren may.
  2. Ren may; Mira may not.
  3. Neither Mira nor Ren may.
  4. Mira may; Ren may not.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An active ops member has no other sudo rules. The policy first grants NOPASSWD: /usr/bin/systemctl restart nginx to ops, then a later matching rule uses PASSWD: for that same command. With no valid timestamp, what happens on that permitted action?
  1. Sudo requires authentication.
  2. Sudo skips authentication.
  3. Sudo refuses the action because the tags differ.
  4. Sudo requires the target user's password.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

77 Key Terms, each with its definition

A

Account expiration
Account expiration is a date after which future logins through an account are disabled, separately from the password's lifetime.
Setting account expiration to a past day blocks future logins without deleting the home directory.
Accountability
Accountability is the ability to connect an action to the account that performed it, using records such as command and login logs.
Separate named administrator accounts improve accountability when reviewing recorded sudo actions.
ACL marker
An ACL marker is a plus sign after the permission string in a listing, indicating additional access-control-list entries.
A listing ending in -rw-r-----+ has an ACL marker beyond the nine ordinary permission positions.
Active groups
Active groups are the group identities currently held by a running process, which can lag behind updated account-database memberships.
Plain id shows the active groups in a user's old shell before they start a new login session.
Adduser
Adduser is an interactive account-creation script on Debian-family systems, while Red Hat-family systems use it as another name for useradd.
On Debian, adduser asks for account details and creates the new user's home during setup.
Authentication timestamp
An authentication timestamp is sudo's temporary record that a user has recently authenticated, allowing later permitted calls without another prompt.
After finishing maintenance, an administrator invalidates their authentication timestamp with sudo -k.

B

Bit removal
Bit removal means clearing selected permission flags independently, including leaving an already absent flag absent.
Bit removal with mask 033 changes a file request of 666 to 644, not the subtraction result 633.

C

Chage
Chage is the account-management command for inspecting and changing password-aging fields and the account-expiration date.
An administrator uses chage -l lea to inspect the dates before changing the account's aging settings.
Chgrp
Chgrp is the command that changes only group ownership; an ordinary owner can select a group they belong to.
A user runs chgrp editors draft.txt on their own file after joining the editors group.
Chmod
Chmod is the command that changes permission bits on a file or directory when run by its owner or an appropriately privileged user.
A user runs chmod g+w draft.txt to let the owning group of their file change the document's contents.
Chown
Chown is the command that changes an object's owning user, group or both, with user transfers requiring administrative privilege.
An administrator uses chown lea:editors draft.txt to assign both the file's owner and its group.
Conditional execute
Conditional execute is chmod's capital X, which selects execute for directories and files that already have an execute bit.
Conditional execute keeps a recursive change from making every ordinary document into an executable file.
Creation request
A creation request is the initial permission mode a program supplies when it asks the file system to create a file or directory.
A text editor's creation request usually lacks execute bits, so a mask cannot make its new text executable.

D

Defaults entry
A Defaults entry is a sudoers setting that changes policy behavior, such as the authentication timestamp duration or extra logging.
A Defaults entry with timestamp_timeout=10 sets a ten-minute authentication interval.
Directory entry
A directory entry is a name stored in a directory that refers to a file or another object in the file system.
Deleting a directory entry needs rights on the containing directory, not write on the file's contents.

E

Effective user ID
An effective user ID is the user identity used for a process's access checks, which a SUID executable can receive from its file owner.
A root-owned SUID program can use effective user ID 0 while controlling the actions its caller may request.
Execute permission
Execute permission allows a regular file to run as a program; on a directory it allows searching and entering the directory.
Missing execute permission on a parent directory can block access to an otherwise readable report.

G

GECOS field
The GECOS field is the comment field in a passwd record, commonly used for a person's full name or other account description.
In the passwd record for priya, the GECOS field contains "Priya Shah" while the login name stays the shorter priya.
Gpasswd
Gpasswd is a group-management command that can add or remove supplementary members or replace a group's listed members.
gpasswd -a lea editors adds Lea without replacing the editors group's other supplementary members.
Group
A group is a named access identity with a numeric GID that lets an administrator share file rights with several accounts.
Assigning a report to the group editors makes its group permission triplet useful to that team.
Group class
The group class is the ordinary permission set selected for a non-owner whose active groups include an object's owning GID.
A team member receives the group class on a report owned by another user but assigned to their team.
Group file
The group file at /etc/group stores group names, password placeholders, GIDs and lists of supplementary member names.
An empty member list in the group file can coexist with accounts that use that group as primary.
Group ID
A group ID, or GID, is the number stored for a group in account records and file metadata, even when tools display a group name.
Changing a group ID requires checking files that still carry the old numeric group assignment.
Group inheritance
Group inheritance is an SGID directory's assignment of its group to newly created files, regardless of the creator's primary group.
In an SGID directory of group editors, group inheritance makes a new report belong to editors, but its own mode decides whether editors may write.
Groupadd
Groupadd is the command that creates a group record with a chosen or automatically allocated GID for later memberships and file ownership.
After running groupadd, the administrator confirms the new team group with getent group.
Groupmod
Groupmod is the command for changing a group's name or GID, two operations with different effects on existing file ownership.
A groupmod name change keeps the GID, so files continue to resolve to the renamed group.

H

Home directory
A home directory is an account's personal working directory, whose path is stored in its passwd record and often begins with /home.
A home directory recorded as /data/lea still needs to be created if it does not already exist.

I

Inherited mask
An inherited mask is a umask setting received by a child process from its parent, affecting the child's later file creations.
An inherited mask from the shell can determine the default permissions of a file created by its editor.
Interpreter
An interpreter is a program that reads and runs a script's instructions, such as Bash when given a shell script.
An interpreter can read task.sh through bash task.sh even when the script has no execute bit.

L

Least privilege
Least privilege means granting an account only the access needed for its work, including narrow file rights and administrative commands.
Granting group read on one report follows least privilege more closely than making a whole tree writable.
Login shell
A login shell is a shell started with login setup, loading the target account's environment and applicable startup files.
sudo -i starts a root login shell, so later commands in that shell run under root's identity.

M

Mount options
Mount options are file-system settings that can determine the ownership and modes presented for media without native Linux permission fields.
On an exFAT drive, mount options can control displayed access while per-file chmod has no useful effect.

N

Namei
Namei is a path-inspection command whose -l output shows ownership and permission information for components along a file path.
An administrator uses namei -l to find a parent directory that blocks access to a readable file.
Newgrp
Newgrp is a command that starts a shell using a selected group as its primary group, allowing work with that group identity.
After a membership update, a user runs newgrp editors and checks the new shell's identity with id.
Nologin shell
A nologin shell is a program set as an account's shell to refuse an ordinary interactive shell login under that identity.
A backup service uses a nologin shell because it needs a service identity, not a person's shell session.
NOPASSWD tag
A NOPASSWD tag is a sudoers setting that removes the password-authentication requirement for matching permitted commands.
A NOPASSWD tag can let an automated backup run, but its root script must stay protected from edits.
Numeric ownership
Numeric ownership is the storage of an object's owning user and group as UID and GID numbers instead of account-name text.
Numeric ownership explains why a listing can show a bare number after an account is removed.

O

Octal mode
An octal mode represents permission bits with digits, adding read 4, write 2 and execute 1 separately for each class.
Octal mode 750 means the owner gets rwx, the group gets r-x and others get no permissions.
Orphaned file
An orphaned file is a file whose stored owning UID no longer resolves to an existing user account on the system.
Reusing a deleted user's UID can give another account owner rights over an orphaned file.
Others class
The others class is the ordinary permission set selected when a process matches neither the owning user nor the owning group.
A visitor outside the team receives the others class, which is --- on a mode-640 report.
Owner class
The owner class is the ordinary permission set selected when a process's user identity matches an object's owning UID.
An owner's access uses the owner class even when the others triplet grants more permissions.

P

Passwd file
The passwd file is the public account database at /etc/passwd, storing names, IDs, home paths, comments and login shells.
A passwd file record can show that an account uses Bash and has its home under /home.
Password expiration
Password expiration is the point when a password must be replaced, either because its maximum age is reached or a change is forced.
passwd -e triggers password expiration so a user must replace an issued temporary password.
Password hash
A password hash is a one-way result used to check a submitted password without storing the original password as readable text.
At login, a password hash is computed using the stored method and salt, then compared with the record.
Password inactivity period
A password inactivity period is the allowed interval after password expiration before the account becomes inactive under that policy.
An empty password inactivity period leaves that particular post-expiration limit unset.
Password lock
A password lock is a change that makes the stored password unusable for authentication, commonly by prefixing its hash with !.
A password lock alone may leave a user's SSH-key login available because that method skips the password.
Permission triplet
A permission triplet is one ordered set of read, write and execute positions belonging to the owner, group or others class.
In mode 640, the group's permission triplet is r--, so its members can read but not edit the file.
Primary group
A primary group is the account's single main group, recorded by GID in passwd and normally used for its new files.
For a user whose primary group is mina, a new file normally starts with that group outside an SGID folder.
Process
A process is a running instance of a program that carries a user identity and group identities used in access decisions.
Two processes can run the same program while having different access because their users differ.

R

Read permission
Read permission allows file contents to be read, while on a directory it allows entry names to be listed.
Read permission on a directory alone can reveal names without allowing the files to be opened.
Recursive change
A recursive change applies an operation to a directory and its descendants, commonly requested with the command's -R option.
A recursive change of 755 would add execute to ordinary documents as well as directory search.
Redirection
Redirection is the shell's handling of command input or output through a file, such as opening an append destination with >>.
Redirection can fail before sudo echo starts because the ordinary shell opens the protected file.
Root
Root is the superuser identity with UID 0, able to administer accounts and bypass ordinary file read and write restrictions.
A command running as root can modify protected account records that an ordinary user cannot change.
Runas specification
A runas specification is the parenthesized part of a sudoers rule that names the user or group identities a command may use.
The runas specification (root) restricts a maintenance action to running under the root identity.

S

Salt
A salt is a random value included in password hashing so equal passwords can produce different stored hash results.
Two users can choose the same password yet have different stored hashes because each uses a different salt.
Same-file-system move
A same-file-system move relocates an existing file without creating a new file, retaining its stored owner and group.
A same-file-system move into an SGID directory leaves an existing file's old group unchanged.
Search permission
Search permission is the directory meaning of execute, allowing a process to look up a known entry name inside that directory.
With search permission but no directory read, a user can open a known readable file without listing its neighbors.
SGID
SGID, or set group ID, gives an executable its file group identity or makes new entries in a directory inherit that directory's group.
SGID on a team folder keeps new files assigned to the team even when creators have private primary groups.
Shadow file
The shadow file is the protected database at /etc/shadow that stores local password hashes and account-aging fields.
An administrator reads the shadow file's aging fields to investigate when a password will expire.
Skeleton directory
A skeleton directory is a template of initial files copied into a new home directory, normally located at /etc/skel.
An administrator adds .bash_aliases to the skeleton directory for accounts created afterward.
Special-mode digit
A special-mode digit is the leading octal digit combining SUID 4, SGID 2 and sticky 1 before the nine ordinary permission bits.
The special-mode digit 3 in 3770 sets both SGID and sticky on a shared directory.
Sticky bit
The sticky bit restricts deletion and renaming in a directory to a file's owner, the directory owner or root, with normal access still needed.
The sticky bit in /tmp lets users create temporary files without letting them remove each other's entries.
Su
Su is a command that starts a shell as another user, normally asking for that target account's password before switching identity.
A user runs su - bob to start Bob's login environment, then types exit to return to their own shell.
Sudo
Sudo is a command that checks policy and runs an authorized action as another user, normally root, with a record of the attempt.
A user runs sudo for a service restart, then edits their own project files without elevated rights.
Sudoers policy
A sudoers policy is the set of rules specifying which callers may run which commands on which hosts under which target identities.
The sudoers policy lets a team reload one service without authorizing an unrestricted root shell.
SUID
SUID, or set user ID, is a special bit on an executable that makes it run with the file owner's effective user identity.
SUID on the passwd program lets its controlled password update reach protected data without a root shell.
Supplementary group
A supplementary group is an additional group membership that a process can use for access alongside its primary group.
Membership in the supplementary group design lets a user use design's rights on shared files.
Symbolic mode
A symbolic mode is a chmod expression naming permission classes, an operator and bits, such as g+w to add group write.
The symbolic mode go-w removes group and others write while keeping their remaining permissions.
System account
A system account is an account used to run a service with its own limited rights, commonly with a noninteractive login shell.
The system account www-data lets a web service run without using a person's regular account.

U

Umask
A umask is a per-process mask that removes selected ordinary permission bits from the mode requested for a newly created object.
A umask of 027 turns a usual 666 file request into mode 640 and a 777 directory request into 750.
User account
A user account is an identity assigned to a person or service so Linux can decide what its processes may access.
A web service uses a user account with access to its site files and limited access elsewhere.
User ID
A user ID, or UID, is the number Linux uses to identify an account when checking process and file ownership.
The user ID in uid=1051(ava) identifies Ava even if her account name is later changed.
User private group
A user private group is a primary group created for one matching user, normally with that user as its only member.
Assigning a file to a user's private group does not share it with the rest of that user's team.
Useradd
Useradd is the low-level command that creates account records, using options and system defaults to choose the account's setup.
An administrator runs useradd with -m and -s to create a home and select a login shell.
Usermod
Usermod is the command for changing an existing account's details, including its login shell, home path and group memberships.
Adding -a to usermod -G preserves earlier supplementary memberships while appending a new one.

V

Visudo
Visudo is the sudoers editing tool that locks a policy file and checks its syntax before accepting the edited version.
An administrator runs visudo on a team policy file so a typo is detected before it is saved.

W

Write permission
Write permission allows file contents to be changed; on a directory it allows entry changes when search permission is also present.
A file's write permission can allow appending while its missing read bit prevents viewing the old contents.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started