Linux Administration
medium

Pregunta de Linux Administration #019e3987

Enunciado de la Pregunta
Linux Administration
#chmod
#symbolic-mode
#file-permissions
#owner-permissions
#group-permissions
Medio

Which of the following commands makes /bin/foo executable by everyone but writable only by its owner?

A

chmod u=rwx,go=rx /bin/foo

Correcto
B

chmod o+rwx,a+rx /bin/foo

C

chmod 577 /bin/foo

D

chmod 775 /bin/foo

Explicación Oficial / Explicaciones de la Comunidad

The command chmod u=rwx,go=rx /bin/foo sets the file permissions so that the owner has read, write, and execute permissions (rwx), while the group and others have only read and execute permissions (rx). This matches the requirement: executable by everyone but writable only by its owner.

How it Works

  • chmod changes file permissions. In symbolic mode, u stands for owner, g for group, o for others, and a for all. The = operator sets exact permissions.
  • u=rwx gives the owner read, write, and execute.
  • go=rx gives group and others read and execute, removing any write permission.

Why the Correct Value is Right

The command chmod u=rwx,go=rx /bin/foo directly implements the requirement: owner has full access, group and others have only read and execute. This is the standard way to set such permissions.

Why the Incorrect Values are Wrong

  • chmod o+rwx,a+rx /bin/foo: This adds write and execute to others (o+rwx) and adds read and execute to all (a+rx). The result is that others get write permission (undesired) and the owner's permissions are not explicitly set, potentially leaving unintended permissions.
  • chmod 577 /bin/foo: Numeric mode 577 sets owner permissions to 5 (read+execute), group to 7 (read+write+execute), and others to 7 (read+write+execute). This gives group and others write permission, which is incorrect.
  • chmod 775 /bin/foo: Numeric mode 775 sets owner to 7 (rwx), group to 7 (rwx), and others to 5 (rx). This gives group write permission, which is not allowed.