Comments on: 10 Useful Sudoers Configurations for Setting ‘sudo’ in Linux https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 13 Jul 2023 12:11:10 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/comment-page-1/#comment-1961775 Fri, 10 Feb 2023 06:58:13 +0000 http://www.tecmint.com/?p=24128#comment-1961775 In reply to Alajjana.

@Aljjana,

Thanks, corrected the command in the script…

]]>
By: Alajjana https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/comment-page-1/#comment-1961556 Thu, 09 Feb 2023 20:07:48 +0000 http://www.tecmint.com/?p=24128#comment-1961556 In reply to Ravi Saive.

This is a minor typo.

$(who am i | awk '{print $1}';exit)

should be:

$(whoami | awk '{print $1}';exit)

Fantastic. Thank you for this script.

]]>
By: Ravi Saive https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/comment-page-1/#comment-1589808 Thu, 16 Sep 2021 06:01:39 +0000 http://www.tecmint.com/?p=24128#comment-1589808 In reply to Ashok B.

@Ashok,

I think you can add those lines to /etc/profile and see if it is working or not…

]]>
By: Ashok B https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/comment-page-1/#comment-1589639 Wed, 15 Sep 2021 22:48:34 +0000 http://www.tecmint.com/?p=24128#comment-1589639 In reply to Ravi Saive.

Hi Ravi,

Thank you so much for the quick response. Does the same procedure apply on AIX 7.2 servers since it uses Korn shell by default? I see that the /etc/profile.d directory does not exist on AIX servers and I have implemented step 1 by adding those lines in /etc/profile to set up secondary logging for root which looks good as the file was created, not sure if I should add commands to the same /etc/profile file to setup secondary logging for other users except root. Thank you.

]]>
By: Ravi Saive https://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/comment-page-1/#comment-1589161 Wed, 15 Sep 2021 05:10:55 +0000 http://www.tecmint.com/?p=24128#comment-1589161 In reply to Ashok.

@Ashok,

First, create a log directory and set the sticky bit on it.

# mkdir -p /var/log/users_historylogs/
# chmod +t  /var/log/users_historylogs/ 

Next, create a new script file under /etc/profile.d/ directory.

# vi /etc/profile.d/history_log.sh

And add the below content at the bottom, save, and exit.

_who_am_i=$(whoami|awk '{print $1}')
_ID=$(id -u $_who_am_i)
 
if [ "$_ID" > 0 ]
then
export HISTSIZE=10000
export HISTTIMEFORMAT='%F %T '
export HISTFILE=/var/log/users_historylogs/history-users-$(whoami | awk '{print $1}';exit)-$(date +%F)
export PROMPT_COMMAND='history -a'
fi

Set the permission and enable the script.

# chmod 770 /etc/profile.d/history_log.sh
# source /etc/profile.d/history_log.sh

Now all user executed commands history saved to log file…

]]>