Permissions & Users Questions with Answers

18 practice questions on Permissions & Users (Linux & Shell) with answers and step-by-step solutions. Try 10 samples below, then practise all 18 free in the AptiNest app.

Sample questions

Question 1Easy

Which command gives the owner execute permission on run.sh without changing other bits?

  1. chmod 100 run.sh
  2. chmod a=x run.sh
  3. chmod +w run.sh
  4. chmod u+x run.sh

Answer: D. chmod u+x run.sh

Explanation

Symbolic mode adds only the named bit. Octal replaces all bits at once.

Step-by-step solution

  1. u is the user (owner).
  2. +x adds execute.
  3. Other bits are untouched.

Why the other options are wrong

  • A. Octal 100 would remove all other bits.
  • B. a=x would set everyone to execute only.
  • C. +w adds write.

Question 2Easy

Which command changes the owner and group of app.log to bob and devs?

  1. chown bob:devs app.log
  2. chmod bob:devs app.log
  3. chgrp bob devs app.log
  4. own bob devs app.log

Answer: A. chown bob:devs app.log

Explanation

chown owner:group file sets both. chgrp changes only the group.

Step-by-step solution

  1. Use chown.
  2. Format is user:group.
  3. Needs root for other users.

Why the other options are wrong

  • B. chmod changes mode bits.
  • C. chgrp takes the group and then files.
  • D. No such command.

Question 3Easy

What does chmod 755 file set?

  1. rw- for the owner, r-- for group and others
  2. rwx for everyone
  3. rwx for the owner, r-x for group and others
  4. r-x for the owner, rwx for group and others

Answer: C. rwx for the owner, r-x for group and others

Explanation

7 = rwx (4+2+1), 5 = r-x (4+1).

Step-by-step solution

  1. Chmod 755 sets permissions in three parts: owner, group, others.
  2. First digit 7 means rwx for the owner (4 + 2 + 1 = 7).
  3. Second digit 5 means r-x for the group (4 + 0 + 1 = 5).
  4. Third digit 5 means r-x for others (4 + 0 + 1 = 5).
  5. So, it gives rwx for owner, r-x for group and others.
  6. Final answer: rwx for the owner, r-x for group and others.

Why the other options are wrong

  • A. The 7 means rwx for the owner, and the 5 digits mean r-x, so this is wrong.
  • B. Only the owner gets 7 (rwx); group and others get 5 (r-x).
  • D. Owner digit 7 gives rwx; the group digit 5 gives r-x, not rwx.

Tip: Remember: 7 = rwx, 5 = r-x, 4 = r--, 2 = -w-, 1 = --x.

Question 4Easy

Which command prints your user id, group id and the groups you belong to?

  1. whoami
  2. groups -a
  3. passwd
  4. id

Answer: D. id

Explanation

id shows uid, gid and supplementary groups. whoami only prints the user name.

Step-by-step solution

  1. Run id.
  2. It lists uid, gid, groups.
  3. whoami shows the name only.

Why the other options are wrong

  • A. whoami shows only the name.
  • B. Only groups, not uid.
  • C. passwd changes a password.

Question 5Medium

What does the permission string -rw-r--r-- mean?

  1. A directory with full access for everyone
  2. A file that anyone on the system can execute
  3. A regular file: owner read/write, group and others read-only
  4. A symlink owned by root

Answer: C. A regular file: owner read/write, group and others read-only

Explanation

The first character is the type (- is a regular file), then three triplets for owner, group and others.

Step-by-step solution

  1. First character - means it's a regular file.
  2. Next three characters rw- mean owner can read and write.
  3. Next three characters r-- mean group can only read.
  4. Last three characters r-- mean others can only read.
  5. So permission is: owner read/write, group and others read-only.

Why the other options are wrong

  • A. The first character is a dash, which marks a regular file, not a directory.
  • B. No x bit appears in the string, so nobody can execute it.
  • D. A symlink starts with l, not a dash, and the string does not name an owner.

Tip: Remember: -rw-r--r-- means owner can read/write, others only read.

Question 6Medium

What octal value represents rwxr-x---?

  1. 705
  2. 755
  3. 750
  4. 570

Answer: C. 750

Explanation

Owner rwx = 7, group r-x = 5, others --- = 0.

Step-by-step solution

  1. rwx = 4+2+1 = 7.
  2. r-x = 4+1 = 5.
  3. --- = 0.

Why the other options are wrong

  • A. Wrong order of digits.
  • B. Others would get r-x.
  • D. Wrong order of digits.

Question 7Medium

Which special permission makes new files inside a directory inherit the directory's group?

  1. setuid on the directory
  2. sticky bit
  3. setgid on the directory
  4. umask 000

Answer: C. setgid on the directory

Explanation

With chmod g+s dir, new items get the directory's group. It shows as s in the group execute field.

Step-by-step solution

  1. Teams share a folder.
  2. g+s sets the group inheritance.
  3. New files get the folder's group.

Why the other options are wrong

  • A. setuid on directories does not do that on Linux.
  • B. The sticky bit controls deletion.
  • D. Umask masks permissions, not groups.

Question 8Medium

What does sudo do?

  1. Runs a command with the privileges of another user, usually root
  2. Switches the default shell of the current user
  3. Installs packages
  4. Locks the user account

Answer: A. Runs a command with the privileges of another user, usually root

Explanation

sudo executes a single command as superuser if the user is allowed in sudoers.

Step-by-step solution

  1. sudo allows a user to run commands with root privileges.
  2. It checks if the user is authorized to perform the action.
  3. The command runs as the superuser (root) if allowed.
  4. This helps in performing administrative tasks safely.
  5. The final answer is A.

Why the other options are wrong

  • B. Changing the default shell is done with chsh; sudo runs a single command with other privileges.
  • C. Package installs use a package manager, which sudo may run; sudo alone installs nothing.
  • D. Locking accounts uses commands like passwd -l or usermod, not sudo.

Tip: Use sudo for admin tasks, but be careful as it gives full system control.

Question 9Hard

With umask 027, what permissions does a new directory get (default 777 before masking)?

  1. rwxr-xr-x
  2. rwxr-x---
  3. rwxrwx---
  4. rw-r-----

Answer: B. rwxr-x---

Explanation

The mask is subtracted bitwise: 777 AND NOT 027 = 750.

Step-by-step solution

  1. Start at 777 for directories.
  2. Remove the 027 bits.
  3. Result 750 = rwxr-x---.

Why the other options are wrong

  • A. That is umask 022.
  • C. Group write is removed by the 2.
  • D. Files start at 666, directories keep x.

Question 10Hard

What does the setuid bit on an executable do?

  1. Makes the file undeletable
  2. Hides the file from ls
  3. Forces the program to always run in the background
  4. Runs the program with the file owner's privileges instead of the caller's

Answer: D. Runs the program with the file owner's privileges instead of the caller's

Explanation

Setuid is shown as s in the owner's execute slot, for example passwd runs as root.

Step-by-step solution

  1. The setuid bit makes a program run with the privileges of the file's owner.
  2. It does not change deletion rights, visibility or background running.
  3. So the answer is option D.

Why the other options are wrong

  • A. Deletion is controlled by the directory permissions, not by setuid.
  • B. Ls shows setuid files normally (with an s in the owner permissions).
  • C. Background running is set by & or job control, not by setuid.

Tip: setuid = run as the file owner (for example, passwd runs as root).

Practise all 18 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Linux & Shell topics · All topics