Results 1 to 10 of 10
Hey, I'm using RHEL4 and I'm trying to make it so when other engineers type "sudo su -" it does "sudo rootsh" automatically. I know I need to do something ...
- 08-25-2011 #1Just Joined!
- Join Date
- Jul 2011
- Location
- Las Vegas NV
- Posts
- 7
Rootsh instead of sudo su -
Hey, I'm using RHEL4 and I'm trying to make it so when other engineers type "sudo su -" it does "sudo rootsh" automatically. I know I need to do something in /etc/profiles.d/ but that's about all I could figure out. Anyone know how to do this?
- 08-26-2011 #2Just Joined!
- Join Date
- Feb 2008
- Posts
- 2
Hi,
I think the following will work for you:
You need to edit the bash profile of the users ~/.bash_profile
Add this to the end:
alias command here= 'what you would like it to do'
then relog, or source .bash_profile to apply changes.
HTH
- 08-26-2011 #3Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Putting the alias in the ~/.bash_profile profiles works just fine.
But you could also make a group (i.e., "engineers") and add all your engineers to it, then put something like this in /etc/profile.d/engineers.sh, which would be read by anyone logging into the system (that uses bash):
OCode:# get GUID of "engineers" group eng_guid=$(awk -F: '$1 ~ /engineers/{print $3}' /etc/group) # see if the user running this belongs to the engineers group id -G|grep -qw $eng_guid if [ $? -eq 0 ]; then alias foo='bar' fiLast edited by atreyu; 08-26-2011 at 01:16 PM. Reason: typo
- 08-26-2011 #4Just Joined!
- Join Date
- Jul 2011
- Location
- Las Vegas NV
- Posts
- 7
Thanks for the responses! I've done "Alias rootsh='su -' " but then it does it's logs as root rather than as the user, I'll try the one by atreyu now and tell you how it works out.
- 08-26-2011 #5Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Make that a lower case "a" in alias...
EDIT: What do you mean by "does it's logs as root"?
- 08-26-2011 #6Just Joined!
- Join Date
- Jul 2011
- Location
- Las Vegas NV
- Posts
- 7
That works, but I'm still getting the issue of it logging as root. When I do "sudo rootsh" it starts the log with the users name and time, and the name of the log contains the user name. When I use an alias though it logs everything as root. The goal is to have the log identified by the user name so I know who's using su -
- 08-26-2011 #7Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Sorry, I'm still confused about logging...what log are you talking about? /var/log/messages? /var/log/secure?
- 08-26-2011 #8Just Joined!
- Join Date
- Jul 2011
- Location
- Las Vegas NV
- Posts
- 7
"Rootsh is a wrapper for shells which logs all echoed keystrokes and terminal output to a file and/or to syslog. It's main purpose is the auditing of users who need a shell with root privileges. They start rootsh through the sudo mechanism." - I'd post the link but I haven't reached 15 posts yet...
- 08-26-2011 #9Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
ah, an actual program called rootsh - got it. never used it before, so i tried it out. i'm not seeing what you are seeing though (i think).
Here's what I did:
1) added a line for my regular user in /etc/sudoers to be able to run rootsh:
2) added in alias in ~/.bashrc:Code:user ALL=(root) NOPASSWD: /usr/sbin/rootsh
3) ran aliased command:Code:alias rootsh='sudo /usr/bin/rootsh'
The following log got created:Code:rootsh
and in it was:Code:/var/log/rootsh/user.20110826101922.021e5.closed
To me, that looks like it has the user information in it. Is that not what you see, or do you mean something else?Code:exit *** rootsh session ended by user rootsh session closed for user on /dev/pts/0 at Fri Aug 26 10:19:28 2011
- 08-26-2011 #10Just Joined!
- Join Date
- Jul 2011
- Location
- Las Vegas NV
- Posts
- 7
I was using alias rootsh='su -' When I used alias rootsh='sudo /usr/bin/rootsh' It works just fine now. Thank you!


Reply With Quote