Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to find out if the current user is logged in via a local console on a Debian Linux machine (ttyS0 in my case)? I have a script where I want to restrict some options which would break a network connection. The who commands lists current users and their connections, but potentially the user could be logged in via multiple connections simultaneously and I don't known which one is me.

share|improve this question
up vote 0 down vote accepted

If you want to get informations about the current connexion, you can use who -m, which will restrict whooutput to the current shell.

Or you can simply type who am i in a shell, it's an alias for who -m. ;-)

share|improve this answer
Nice! The description in the man page was too subtle for me! – Bruce Alport Jul 25 '13 at 12:39

Well you can use the w command:

w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:

Name of the user
User’s machine number or tty number
Remote machine address
User’s Login time
Idle time (not usable time)
Time used by all processes attached to the tty (JCPU time)
Time used by the current process (PCPU time)
Command currently getting executed by the users

Or if you just want to see who's logged in use who

For more info regarding the commands check the man page like this:

man w and man who

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .