Skip to content

Instantly share code, notes, and snippets.

@it-can
Last active August 21, 2023 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save it-can/a433274c91ac6e0dfee2cc1ddbe40999 to your computer and use it in GitHub Desktop.
Save it-can/a433274c91ac6e0dfee2cc1ddbe40999 to your computer and use it in GitHub Desktop.
never type a sudo password again on mac. Uses gsed, install with: brew install gnu-sed
#!/bin/bash
file="/etc/pam.d/sudo"
line_to_add="auth sufficient pam_tid.so"
# Check if the line already exists in the file
if grep -q "$line_to_add" "$file"; then
echo "Line already exists in $file."
else
# Add the line after the comment lines
gsed -i "/^#.*$/a $line_to_add" "$file"
echo "Line added to $file."
fi
@it-can
Copy link
Author

it-can commented Aug 21, 2023

@it-can
Copy link
Author

it-can commented Aug 21, 2023

uses gsed, install with: brew install gnu-sed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment