# Ensure sudo Log File Exists

- Source: https://support.icompaas.com/support/solutions/articles/62000235538-ensure-sudo-log-file-exists
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Amazon Linux 2 Benchmark v3.0.0](https://support.icompaas.com/support/solutions/62000112696) › [CIS Amazon Linux 2 Benchmarks](https://support.icompaas.com/support/solutions/folders/62000169265)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Profile Applicability:  
 • Level 1

Description:  
 The sudo log file captures all commands executed with elevated privileges, providing critical audit information. Ensuring the log file exists supports monitoring and forensic analysis of privileged actions.

Rationale:  
 Maintaining a dedicated sudo log file improves accountability, aids in security incident investigations, and helps meet compliance requirements

Impact:  
 Pros:

-   Provides comprehensive audit trails for sudo commands.  
      
    
-   Supports detection of unauthorized privilege use.  
      
    

Cons:

-   Requires proper log management and protection to prevent tampering.  
      
    

Default Value:  
 Depending on system configuration, sudo logs may be directed to syslog or a specific log file.

Pre-requisites:

-   Root or sudo privileges to verify and configure sudo logging.  
      
    

Remediation:

### Test Plan:

Using Linux command line:

Check sudoers configuration for logging directives:  

sudo grep -i logfile /etc/sudoers /etc/sudoers.d/\*

  

1.  Identify the configured log file path or logging facility.  
      
    

Verify the log file exists and has appropriate permissions:  

ls -l /var/log/sudo.log

2.   (Adjust path if different.)
    

### Implementation Plan:

Using Linux command line:

If the log file does not exist, create it and set ownership and permissions:

touch /var/log/sudo.log  
chown root:root /var/log/sudo.log  
chmod 600 /var/log/sudo.log

Ensure sudoers file contains the logging directive, for example:  

Defaults logfile="/var/log/sudo.log"

1.  Restart syslog or rsyslog service if necessary to apply changes.
    

### Backout Plan:

Using Linux command line:

1.  Remove or comment out the logging directive in sudoers if required.  
      
    
2.  Delete the sudo log file if no longer needed.  
      
    
3.  Restart syslog or rsyslog service.  
    

References:

-   [NIST SP 800-53 Revision 5 - AU-2  
      
    ](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final#au-2)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
