nerdexam
CompTIA

XK0-004 · Question #458

An end user is trying to execute a file within a different directory The end user executes the following command: Which of the following commands should the Linux administrator use to run the shell sc

The correct answer is C. chmod 0755. chmod 0755 sets the execute bit for owner, group, and others, which is required before a shell script can be run.

Security

Question

An end user is trying to execute a file within a different directory The end user executes the following command:

Which of the following commands should the Linux administrator use to run the shell scnpt within that folder?

Options

  • Achmod 0644
  • Bchmod g-x myabc.sh
  • Cchmod 0755
  • Dchmod u-x myabc,sh

How the community answered

(37 responses)
  • A
    5% (2)
  • B
    3% (1)
  • C
    89% (33)
  • D
    3% (1)

Why each option

chmod 0755 sets the execute bit for owner, group, and others, which is required before a shell script can be run.

Achmod 0644

chmod 0644 (rw-r--r--) sets no execute bits for any user category, leaving the script non-executable for everyone including the owner.

Bchmod g-x myabc.sh

chmod g-x removes the execute bit from the group class, which reduces permissions rather than enabling execution for the end user.

Cchmod 0755Correct

The octal mode 0755 translates to rwxr-xr-x - giving the owner full read, write, and execute permissions while granting group and others read and execute. Without an execute bit set, the kernel returns a 'Permission denied' error regardless of the script's content or the user's identity. This is the standard permission set applied to executable shell scripts on Linux systems.

Dchmod u-x myabc,sh

chmod u-x removes the execute bit from the file owner, which would prevent even the owner from running the script.

Concept tested: Linux file execute permission assignment with chmod

Source: https://man7.org/linux/man-pages/man1/chmod.1.html

Topics

#chmod#execute permissions#file permissions#shell scripts

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice