diff options
| author | mo khan <mo.khan@gmail.com> | 2019-10-14 10:35:45 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-10-14 10:35:45 -0600 |
| commit | f12ef3fd3851bb69aa2fbadd713ccff3298b7fab (patch) | |
| tree | d70ad5378717ba288aea01a71fe1d32084eeecae /README.md | |
| parent | d32e87b86f6ddad2c2e427718bc9f480e0905055 (diff) | |
Create script for detecting duplicate login names
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -1171,6 +1171,7 @@ Rootly Powers and Processes ```bash #!/bin/bash + cd "$(dirname "$0")/.." FILE=${1:-'/etc/passwd'} cat "$FILE" | cut -d: -f1,3 | grep ':0' @@ -1181,9 +1182,10 @@ Rootly Powers and Processes ```bash #!/bin/bash + cd "$(dirname "$0")/.." FILE=${1:-'/etc/passwd'} - grep -E '^\w+::.*' $FILE + grep -E '^\w+::.*' "$FILE" ``` c. Find any sets of entries that have duplicate UIDs. @@ -1191,7 +1193,20 @@ Rootly Powers and Processes ```bash #!/bin/bash - cat /etc/passwd | grep -v -E '^#' | awk -F: '{ print $3 }' | sort -n | uniq -d + cd "$(dirname "$0")/.." + FILE=${1:-'/etc/passwd'} + + ids=$(grep -v -E '^#' "$FILE" | awk -F: '{ print $3 }' | sort -n | uniq -d) + + for id in $ids; do + grep -v -E '^#' "$FILE" | awk -F: '{ print $3 " " $1 }' | grep -E "^$id " + done + + if [ -z "$ids" ]; then + exit 0 + else + exit 1 + fi ``` d. Find entries that have duplicate login names. |
