Linux and Command-Line Basics

After "chmod 754 run.sh" is run on the file run.sh, which of the following is the permission notation shown at the start of the line from "ls -l run.sh"?

  1. A-rwxr-xr--
  2. B-r--r-xrwx
  3. C-rwxrw-r--
Show answer and explanation

Answer: A. -rwxr-xr--

Octal permissions are ordered, from the left, owner (user), group and others, and each digit is the sum of read r = 4, write w = 2 and execute x = 1. 7 = 4 + 2 + 1 is rwx, 5 = 4 + 1 is r-x and 4 is r--, so 754 becomes rwxr-xr--. The leading "-" means a regular file; a directory would show "d". With this setting the owner can read, write and execute, the group can read and execute, and other users can only read.

  • A. Correct. 7 is rwx, 5 is r-x and 4 is r--.
  • B. This reads the three digits in reverse order and corresponds to chmod 457. The octal digits are owner, group and others from the left.
  • C. 5 is 4 + 1, that is r-x. rw- corresponds to 4 + 2 = 6.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. touch creates a new file from 666, and mkdir a new directory from 777, with the umask bits removed. Which of the following is the correct pair of permissions when a new file and a new directory are created in a shell whose umask is 027?
  2. The directory d has permissions rwx--x--x (711), and the file f.txt in it has rw-r--r-- (644). A user who is neither the owner nor the superuser runs "ls d" and "cat d/f.txt". Which of the following is the result?
  3. Which of the following correctly describes the sudo command on Linux?
  4. On many Linux systems, "ls -l /usr/bin/passwd" shows "-rwsr-xr-x 1 root root ...". Which of the following is the meaning of the "s" in the owner's execute position?
  5. When the commands above are run in order, which of the following is the content shown by the last cat?