Courseiva
System SecurityhardMultiple SelectObjective-mapped

How to Restrict Access to the su Command on Linux

Which THREE of the following are valid methods to restrict access to the su command on a Linux system?

Quick Answer

The answer is adding the user to the 'wheel' group and configuring pam_wheel.so in /etc/pam.d/su, along with using the /etc/suauth file. These are valid methods to restrict access to the su command because they enforce authentication controls at the PAM (Pluggable Authentication Modules) layer or through the shadow suite’s direct configuration, ensuring only authorized users can switch to the root account. On the LPIC-2 exam, this topic tests your understanding of Linux security mechanisms for privilege escalation, often appearing in questions about PAM module ordering and group-based restrictions. A common trap is confusing pam_wheel.so with pam_securetty.so, which controls terminal access rather than user authorization. Remember the mnemonic “Wheel for su, Securetty for tty” to keep the distinction clear.

⚠ Common exam trap

LPI often tests the misconception that /etc/login.defs or /etc/shells can restrict su, when in reality these files serve different purposes (login defaults and shell validation) and are not used for su access control.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Set the SU_WHEEL_ONLY variable in /etc/login.defs.

Options A, D, and E are all valid methods to restrict access to the su command. Option A is correct: setting SU_WHEEL_ONLY to 'yes' in /etc/login.defs restricts su to members of the wheel group. Option D is correct because /etc/suauth allows specifying allowed users or groups. Option E is correct because pam_wheel.so in /etc/pam.d/su restricts access to wheel group members. Options B and C are incorrect: /etc/shells controls allowed shells for chsh, not su, and configuring sudoers allows running su via sudo but does not restrict the su command itself.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Set the SU_WHEEL_ONLY variable in /etc/login.defs.

    Why this is correct

    Correct. Setting SU_WHEEL_ONLY=yes in /etc/login.defs restricts su to members of the wheel group.

  • Modify /etc/shells to include only approved shells.

    Why it's wrong here

    Incorrect. /etc/shells specifies valid login shells, it does not control access to su.

  • Configure sudoers to allow only specific users to run su.

    Why it's wrong here

    Incorrect. sudoers controls sudo access, not the su command directly.

  • Edit the /etc/suauth file to specify allowed users.

    Why this is correct

    Correct. /etc/suauth allows explicit control over which users can use su.

  • Add the user to the 'wheel' group and configure pam_wheel.so in /etc/pam.d/su.

    Why this is correct

    Correct. pam_wheel.so with the wheel group restricts su to group members.

About these practice questions

This LPIC-2 question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on LPIC-2

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Based on the sshd configuration, user 'charlie' attempts to log in using public key authentication. What will happen?

hard
  • A.Login is denied because the DenyUsers directive explicitly blocks charlie.
  • B.Login is allowed because PasswordAuthentication is disabled, but public key authentication is enabled.
  • C.Login is allowed because AllowUsers includes other users but does not deny charlie.
  • D.Login is denied because charlie's IP address is not in the allowed list.

Why A: The DenyUsers directive in sshd_config explicitly blocks the user 'charlie' from logging in, regardless of the authentication method. Since DenyUsers takes precedence over AllowUsers and other authentication settings, public key authentication will still be denied for charlie. The correct answer is A because the directive explicitly denies charlie, overriding any other configuration.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LPIC-2 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-2 exam.