# How to get columns TIME and TTY of commands ps -A?

**URL:** <https://community.unix.com/t/how-to-get-columns-time-and-tty-of-commands-ps-a/313622>\
**Category:** Ubuntu\
**Created:** [July 16, 2012, 12:20pm UTC](https://community.unix.com/t/how-to-get-columns-time-and-tty-of-commands-ps-a/313622 "2012-07-16T12:20:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie\_member](https://community.unix.com/letter_avatar/newbie_member/32/5_5575768a8748004e209b776fc1b2916d.png) [@newbie\_member](https://community.unix.com/u/newbie_member)\
**Post date:** [July 16, 2012, 12:20pm UTC](https://community.unix.com/t/how-to-get-columns-time-and-tty-of-commands-ps-a/313622/1 "2012-07-16T12:20:18Z")

</div>

Hi,  
Commands ps -A include four parameters are PID, TTY, TIME and CMD. I can not found pathnames of TTY and TIME which I can read from file in C language to get information display on screen. Thank you!

Ex:  
PID TTY TIME CMD  
1 ? 00:00:01 init

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/5_5575768a8748004e209b776fc1b2916d.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [July 16, 2012, 1:14pm UTC](https://community.unix.com/t/how-to-get-columns-time-and-tty-of-commands-ps-a/313622/2 "2012-07-16T13:14:37Z")

</div>

Do you mean the /proc directories? /proc/pid, from your example /proc/1  
is the path.

However TIME comes from /var/adm/utmpx - you will have to use a structure defined in utmpx.h to read the file.

example code here:  
[loginacct/utmpx\_login.c (from "The Linux Programming Interface")](http://man7.org/tlpi/code/online/dist/loginacct/utmpx_login.c.html)

As to the TTY, what are you trying to do?

/proc/pid/fd/0 is the tty for the process, if one exists. A ? in ps -A output means the process does not have a controlling terminal.

---

<div class="post-metadata">

**Author:** ![newbie\_member](https://community.unix.com/letter_avatar/newbie_member/32/5_5575768a8748004e209b776fc1b2916d.png) [@newbie\_member](https://community.unix.com/u/newbie_member)\
**Post date:** [July 18, 2012, 10:09am UTC](https://community.unix.com/t/how-to-get-columns-time-and-tty-of-commands-ps-a/313622/3 "2012-07-18T10:09:37Z")

</div>

Thank you, but I see /proc/pid/fd/0 a socket, I cannot read it by C language cause I need read "TTY" to display the screen.
