From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078724211807.tru64-unix-managers.marc@archive.invalid> From: Gerhard Nolte Date: Tue, 13 Oct 1998 08:34:54 +0000 To: tru64-unix-managers Subject: [SUMMARY] Get the userid that su'ed to root X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078724211807 Dear Gurus, I asked: > how can I find out the userid, that > executed the "su -" command. Thanks to all who answered my question, too many to list the names. As usual, I learned a lot :) /var/adm/sialog (touch that file if it does not exist) /var/adm/syslog.dated/*/auth.log | most recent date here (probably) Bruce Hines : ps -o user -p $PPID -if you are using ksh Jim Smart sent me an example of how to find it out with ps commands: 8< ---------------- JS -------------------- >8 The first one gets the tty associated # ps -ef | grep s_up root 14459 24343 0.0 19:57:54 ttya1 0:00.01 grep s_up root 30751 6881 0.0 Oct 10 ttypG 0:00.25 sh This one gets everything associated with the device, most of the time. # ps -ft ttypG UID PID PPID C STIME TTY TIME CMD jim 3730 819 0.0 Oct 06 ttypG 0:00.07 -sh (sh) root 6881 18103 0.0 Oct 06 ttypG 0:05.49 bash jim 16159 3730 0.0 Oct 06 ttypG 0:00.10 bash root 18103 16159 0.0 Oct 06 ttypG 0:00.03 -sh (sh) root 18195 30751 0.0 19:15:28 ttypG 0:00.01 sleep 3600 root 30751 6881 0.0 Oct 10 ttypG 0:00.25 sh /usr/local/bin/jims # So in this case , it was me ! You can trace what is happening by using the PID fields. In order ... So I logged in as jim, bash'ed, su'ed to root, bash'ed, ran a script and the script is currently sleeping for 3600 seconds 8< ---------------- JS -------------------- >8 I decided to write a small c-program that did what I want: 8< ---------------- cut here -------------------- >8 #include #include main() { printf( "%s\n", getlogin()); } 8< ---------------- cut here -------------------- >8 Thanks once more to all who respondet. Gerhard -- Gerhard Nolte Email: gnolte@gwdg.de Voice: +49-551-5176-716 Fax: +49-551-5176-704 MPI fuer Stroemungsforschung, Bunsenstr. 10, 37073 Goettingen, Germany