-   Linux - Security (
-   -   How could I tell if Im running as ROOT? (

wardialer 03-19-2005 04:45 PM

How could I tell if Im running as ROOT?
Im running Mandrake Linux and I want to know please on how to find out if Im running as root or my regular user account (restricted user).

What is the command to find out?

samael26 03-19-2005 04:52 PM

How do you log in ?
Don't you have to type a password to get into your GUI ?
I must say I am amazed at your question ...:confused:

avarus 03-19-2005 04:53 PM


cylix 03-19-2005 04:57 PM


avarus 03-19-2005 05:35 PM

perl -l -e 'print [getpwuid($<)]->[0]'


id -un

...but a simple id is shorter and tells you more!

Better still shove the following into /root/.bashrc and you will get a nice red prompt in your root shell.

if [ "$PS1" ]; then
PS1="\[\033[1;31m\][\u@\h: \w]\\$\[\033[0m\] "


wardialer 03-19-2005 06:14 PM

Ok, I did an 'id' command and I only see my username. Which is good.

But, why am I seeing myself 3 times???

My output is this:

uid=501(myusername) gid=501 (myusername) groups=501 (myusername)

How can I resolve this to only showing one??? Why is this showing my username 3 times? Its strange. How can I avoid this?

And the 'whoami' output shows as ONLY myself.... But I do not like the fact that I am seeing myself 3 times...Is this a security issue or problem?

Hidden.Elf 03-19-2005 06:27 PM

well if you log in with root as your username you are under root... try logging out and then notice what username you use to log in

wardialer 03-19-2005 07:14 PM

When I login, it shows my username. Thats all...

Bit if I were to login as root, would it say root in the login window?

I just tried testing the Adjust Clock. It shows me that in order to Change the Time, I need to have root access and a password windows opens.

Does this mean Im not working as root???

btmiller 03-19-2005 07:28 PM

Yes. The "id" command showed you your user name 3 times because it's showing you three different things, your user account, your current primary hroup, and the list of all groups you are in. Your user id is 501, which corresponds to "myusername". Your primary group is also 501 which is called "myusername" (in Mandrake as in Red Hat, the default is to make each user a member of a group of the same name), and that is the only group you are a member of.

Hope this clears some things up.

wardialer 03-19-2005 09:47 PM

Thanks, just wanna make extra sure.

But anyhow... I guess Im not running as root. Because I tried to change the system time, and it asked me for the root password.

Btmiller -

Just noticed your setup there. Quite nice. I wish I was running OpenBSD.

All times are GMT -5. The time now is 04:32 PM.