Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9256823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:03:33+00:00 2026-06-18T12:03:33+00:00

If I use a login shell to login as root then ‘who’ or ‘users’

  • 0

If I use a login shell to login as root
then ‘who’ or ‘users’ commands
will show an entry for the root user.
However If I login with user1 and then use:

'su - root'

Then the ‘who’ and ‘users’ command will not show an entry for root.

Is there a way to find out whether there is a logged-in user in my system that has currently switched to root (or to any other account)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:03:35+00:00Added an answer on June 18, 2026 at 12:03 pm

    Thanx to Davide Berra’s answer, I think I have found what I was looking for.

    > who | sort -k2 > /tmp/whoresult
    > pgrep -x su | xargs -i ps hu -p{} | awk '{printf $7 " ";for (i=11; i<=NF; i++) printf $i " "; printf "\n"}' | sort -k1 | join -1 2 -2 1 /tmp/whoresult -
    

    The output is something like:

    pts/3 user1 2013-02-06 16:35 (:0.0) su - root    #logged in as user1 and executed 'su - root'
    pts/5 user1 2013-02-06 16:51 (:0.0) su           #logged in as user1 executed 'su'
    tty2 root 2013-02-06 17:07 su - user1            #logged in as root and executed 'su - user1'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use asp:Login control, user can login properly, but while checking user Profile information
I want to use the Login Tool from the VS Toolbox to login users
Why do i have to use some persistent-login module to make my users login
I am currently writing a site that will require a login to use. I
I am going to use a single LOGIN database (Sql forms authenication) to hold
How to use forms authentication without login control.I don't want to use asp.net login
I am using CodeIgniter with version 2.1.0. I want to use Hooks for login
I want to use the following code to login to a website which returns
I use the following URL setting to authorize Facebook login. But the page for
I'm going to use Codeigniter's session data for my login system, but first I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.