CmdKeys LogoCommand Quiz
Practice Tracks/Permissions

Permissions Command Practice

chmod sets who can read, write, or execute a path; chown sets which user and group own it. This track drills octal modes (755, 644), symbolic edits (u+x, go=), and chown user:group forms as separate answers — an octal is wrong on a symbolic prompt. The same commands show up on SSH keys, web roots, and shared project directories.

Command Reference

numeric

CommandDescription
chmod 600 <file>Set octal mode 600 so only the owner can read and write.
chmod 700 <file>Set octal mode 700 so only the owner has read, write, and execute.
chmod 755 <file>Set octal mode 755 so the owner has rwx and group and others have rx only.
chmod 644 <file>Set octal mode 644 so the owner can read and write while group and others can only read.
chmod 777 <file>Set octal mode 777 so every class can read, write, and execute.
chmod 664 <file>Set octal mode 664 so owner and group can read and write, and others can only read.
chmod 660 <file>Set octal mode 660 so owner and group can read and write, and others have no access.
chmod 400 <file>Set octal mode 400 so only the owner can read the file.
chmod 775 <file>Set octal mode 775 so owner and group have rwx and others have rx.
chmod -R 755 <dir>Recursively set octal mode 755 on a directory and everything under it.
chmod -R 644 <dir>Recursively set octal mode 644 on a directory tree (typical files-only web layout).
chmod 500 <file>Set octal mode 500 so only the owner can read and execute, with no write bit.
chmod 754 <file>Set octal mode 754 so the owner has rwx, the group has rx, and others have read only.
find <dir> -type f -exec chmod 644 {} \;Find all files within a path and set their permissions to octal 644.
find <dir> -type d -exec chmod 755 {} \;Find all directories within a path and set their permissions to octal 755.

symbolic

CommandDescription
chmod +x <file>Add the execute bit with no class letter (umask may still block some classes).
chmod u+x <file>Add the execute bit for the owner only, using symbolic notation.
chmod u-x <file>Remove the execute bit from the owner using symbolic notation.
chmod a-x <file>Remove the execute bit from every class using symbolic notation.
chmod a+r <file>Add the read bit for every class using symbolic notation.
chmod a+x <file>Add the execute bit for user, group, and other, ignoring umask.
chmod go+rw <file>Add read and write for group and others, leaving the owner bits unchanged.
chmod o-rw <file>Remove read and write from others using symbolic notation.
chmod g-rx <file>Remove read and execute from the group using symbolic notation.
chmod go= <file>Clear every group and other bit (set those classes to none) using symbolic notation.
chmod o= <file>Clear every other-class bit using symbolic notation, leaving owner and group alone.
chmod a=rwx <file>Set all classes (user, group, others) to read, write, and execute using symbolic notation.
chmod g-rx,o+rx <file>Remove read and execute from the group and add them to others, in one symbolic chmod.
chmod o=g <file>Copy the group's current bits onto others using symbolic notation.
chmod u=rwx,g=rx,o=r <file>Assign an exact symbolic mask equivalent to 754: owner rwx, group rx, others read-only.
chmod u=rw,g=,o= <file>Assign an exact symbolic mask equivalent to 600: owner read/write, clear group and others.
chmod u=rw,g=rw,o=r <file>Assign an exact symbolic mask equivalent to 664: owner and group read/write, others read-only.
chmod u=rwx,g=rx,o= <file>Assign an exact symbolic mask: owner rwx, group rx, others none.
chmod -R g+w,o+w <dir>Recursively add write for group and others using symbolic notation.
chmod =rwx,g+s <file>Set rwx for every class and turn on the setgid bit, using symbolic notation.

chown

CommandDescription
chown <user> <file>Change only the owning user of a file, leaving the group unchanged.
chown <user>:<group> <file>Set both owning user and group on a file.
chown <user>: <file>Set the owner to a user and set the group to that same user name.
chown :<group> <file>Change only the owning group, leaving the user unchanged.
chown -R <user> <dir>Recursively change the owning user of a directory and its contents.
chown -R <user>:<group> <dir>Recursively set both owning user and group on a directory tree.
chown -h <user> <file>Change the owner of a symlink itself, not the target it points to.
chown --reference <file> <file>Copy user and group ownership from a reference file onto another path.

Key Use Cases

  • Set octal 755 on a script so others can run it but only the owner can write
  • Add execute for the owner with u+x without rewriting group or other bits
  • Clear all group and other access with go=
  • Recursively apply octal 644 to a directory tree
  • Give a path to another user and group with chown user:group
  • Change ownership of a symlink itself, not the target

Frequently Asked Questions

Is chmod 755 the same answer as chmod u=rwx,g=rx,o=rx?

They can produce the same bits, but this track scores notation. An octal is wrong on a symbolic prompt and a u=rwx form is wrong on an octal prompt.

Why isn't chmod +x the same as chmod a+x?

With no class letter, chmod acts like a but honors umask, so some bits may stay off. a+x sets execute for user, group, and other regardless of umask.

How do I change only the group with chown?

chown :<group> <file> leaves the owner alone. chown <user>: sets both owner and group to that user name.

What does g+s do on a file or directory?

It sets the setgid bit. New files in that directory inherit the directory's group. =rwx,g+s is a different command than plain 777.

Ready to master Permissions commands?

Test your muscle memory with our spaced-repetition quiz system. Free forever.

Start Practice Now →