Which of the following commands makes /bin/foo executable by everyone but writable only by its owner?
Click on the arrows to vote for the correct answer
A. B. C. D.A
The correct answer to the question is A: chmod u=rwx,go=rx /bin/foo
.
Here's why:
chmod
is a command used to change the permissions of a file or directory. The syntax for chmod
is:
bashchmod [options] mode file
In this case, the file we want to modify is /bin/foo
. The mode we want to set is executable by everyone but writable only by its owner.
There are a few different ways to specify permissions with chmod
, but one of the most common is to use a three-digit octal number. Each digit corresponds to a different set of permissions:
Each digit can have a value between 0 and 7, representing different combinations of read, write, and execute permissions. Here's a breakdown:
So, for example, a mode of 755
means that the owner has read, write, and execute permissions, while the group and everyone else only have execute permissions.
Now let's look at the answer choices:
A. chmod u=rwx,go=rx /bin/foo
This sets the owner's permissions to read, write, and execute, and the group and everyone else's permissions to read and execute. This is the correct answer, as it sets the permissions as required by the question.
B. chmod o+rwx,a+rx /bin/foo
This sets the permissions for "other" (i.e. everyone else) to read, write, and execute, and sets the permissions for all users (owner, group, and other) to read and execute. This is not what the question is asking for, as it allows everyone to write to the file.
C. chmod 577 /bin/foo
This sets the owner's permissions to read, write, and execute, the group's permissions to read only, and everyone else's permissions to execute only. This is not what the question is asking for, as it allows the owner to write to the file.
D. chmod 775 /bin/foo
This sets the owner's permissions to read, write, and execute, the group's permissions to read, write, and execute, and everyone else's permissions to read and execute. This is not what the question is asking for, as it allows everyone to write to the file.
So the correct answer is A: chmod u=rwx,go=rx /bin/foo
.