Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
148 rodolico 1
#! /usr/bin/env perl
2
 
3
use strict;
4
use warnings;
5
 
6
use File::Slurp; # apt install -y libfile-slurp-perl
7
 
8
my @users;
9
 
10
my @passwords = read_file( '/etc/passwd' );
11
while ( my $line = pop @passwords ) {
12
   next if $line =~ m/^#/;
13
   my @columns = split( ':', $line );
14
   push @users, $columns[0] if $columns[2] >= 1000 && $columns[2] < 65534;
15
}
16
 
17
#print join( "\n", @users );
18
 
19
my $users = join( '\|', @users );
20
print qx/ps aux | cut -d' ' -f1 | sort | uniq | grep '$users'/;
21
 
22
1;
23