Get name of users(persons, not applications) in linux system using psutil library
<p>I am trying to use psutil library to get users logged in to linux system.</p>

<p>For that i used function psutil.users()</p>

<pre><code>&gt;&gt;&gt; import psutil
&gt;&gt;&gt; psutil.users()
[suser(name='vibhcool', terminal='tty2',host='localhost',started=1473815296.0)]
</code></pre>

<p>I want to extract the username from this list, what shall i do?
Also what is suser here?</p>

<p>I got the answer, (sorry i am bad at googling)</p>

<p>psutil.users() outputs a list, so it can be traversed using for loop</p>

<pre><code>users = psutil.users()
    for user in users:
        print(user.name)
</code></pre>

<p>reference: <a href="http://www.programcreek.com/python/example/53877/psutil.users" rel="nofollow">http://www.programcreek.com/python/example/53877/psutil.users</a></p>

python linux psutil