I am confused as to why I'm having problems executing a history command as another user to return all that user's history - I need to loop though all users and get their history
cat /etc/passwd | awk -F: '{print $1}' > ${system}.users.txt
while read username; do
echo $username
sudo -u $username bash -c 'export HISTTIMEFORMAT="%F %T "; history' >../log/${username}.hist
#sudo -u $username bash -c 'export HISTTIMEFORMAT="%F %T "; history'
done < ./${system}.users.txt
I get no history output when I run:
sudo -u anotheruser history
to troubleshoot I tried:
sudo -u anotheruser bash -c 'which history'
Also I ran :
sudo find / -name 'history' -type f
and I get no returned executable.
Can anybody tell me why a sudo command can't be executed by another user?