Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to see if there is a way to tell what user used sudo to do work on the server. I need to know if there is a log file that has the userid of the person who invoked sudo to make changes in the system.
It is hard to know but you can search keyword sudo in .bash_history of all users, it will give you the list.
As well as you can save their history in separate files(make a cron job for it) so if they delete their history even you can know who has used sudo.
/var/log/auth.log will still show the name of the user who logged in as root user, or who used sudo.
Yep, auth.log shows when root logged in or sudo...
Code:
root@desktop:/home/user# cat /var/log/auth.log
May 28 08:12:20 desktop sudo: user : TTY=pts/1 ; PWD=/home/user ; USER=root ; COMMAND=/bin/cat /var/log/auth.log
May 28 08:12:25 desktop su[6137]: Successful su for root by user
May 28 08:12:25 desktop su[6137]: + /dev/pts/1 user:root
May 28 08:12:25 desktop su[6137]: pam_unix(su:session): session opened for user root by root(uid=1001)
Lookee what I can do...
Code:
root@desktop:/home/user# vi /var/log/auth.log
Guess what auth.log contains now that I've edited it...
Code:
root@desktop:/home/user# cat /var/log/auth.log
At this point I wonder what the original requesting person's intentions were. To spy, to monitor, or to administer in some fashion. I mean, there's a lot more to system/network security other than determining who has performed a sudo command to reconfigure something.
Guess what auth.log contains now that I've edited it...
But you are logged in as a root and here we are talking about user updates the file or not.
You have taken example of command line using vi, that is really good to explain my point.
If you are a user, you need to use sudo again to remove contents of the file and once you use sudo, it makes an entry in auth.log so next time when you open the file, you see user has edited the file auth.log, something like this.
Code:
May 28 18:05:23 user-desktop sudo: user : TTY=pts/1 ; PWD=/home/user ; USER=root ; COMMAND=/usr/bin/nano /var/log/auth.log
If you edit this line, next time when you open the file and it shows about your previous editing using sudo.
It means you can't remove your last activity (especially if you have edited auth.log).
It means admin can know about user's act that user has done something inappropriate that's why he/she has removed the entry from auth.log
At this point I wonder what the original requesting person's intentions were. To spy, to monitor, or to administer in some fashion. I mean, there's a lot more to system/network security other than determining who has performed a sudo command to reconfigure something.
That's why in large and professional organizations, they never give sudo facility to users.
If user tries to use sudo, it says
Code:
username is not in the sudoers file. This incident will be reported.
You have to request by mail to perform your task. Then admin does it for you.
They prefer delay than the damage.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.