Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > [SOLVED] Last active tty

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 04-09-2006   #1 (permalink)
Just Joined!
 
Join Date: Apr 2006
Posts: 1
Post [SOLVED] Last active tty

Hello,

My name is Marcelo and I am a student in computer science facing a project that is getting difficult to implement.

In order to solve some of my problems I would like to get some information.

I would like to know if it is possible in Linux to know from user space which is the last active tty attached to an user i choose(the last tty which had some activity in it). I will be root or some other user which will have the proper privileges. I am willing to do any combination of system calls and tricks.

If it is not possible to do from user space then I would like to do it myself inside the kernel. I need to know where should I start reading to have the knowledge required to do the changes in the kernel (in my local copy of course).

I have some knowledge of the kernel and some little experience in programming inside the kernel (mainly i played with the scheduler and the virtual memory).

Thank you in advance,

Marcelo Taube
ekymk is offline  


Old 04-22-2006   #2 (permalink)
Linux User
 
Krendoshazin's Avatar
 
Join Date: Feb 2005
Location: London, England
Posts: 327
This falls close to being a homework question, but I can give you a start and let you do the rest.
This command will show the tty's and their access date and time, this is what will show you the last active tty, to grab the right user it's a simple grep.

ls -lu /dev | grep tty | grep username

You may find there are several tty's listed, as a user could be using quite a few tty's at that point, so you'll need to find a way to grep the latest out of the list.
__________________
"The search for the MOT JUSTE is not a pedantic fad but a vital necessity. Words are our precision tools. Imprecision engenders ambiguity and hours are wasted in removing verbal misunderstandings before the argument of substance can begin."

Do the things you use not respect you, the user? Then it's defective by design, so make your voice heard.
Krendoshazin is offline  
Old 09-22-2009   #3 (permalink)
Just Joined!
 
Join Date: Sep 2009
Location: UK
Posts: 2
tty

hi, i did what you suggested but go this error, can you advice please?

[root@laptop ~]# ls -lu/dev |grep tty|grep root
ls: invalid option -- '/'
Try `ls --help' for more information.

thanks in advance

smithyd
smithyd is offline  
Old 09-22-2009   #4 (permalink)
Super Moderator
 
devils casper's Avatar
 
Join Date: Jun 2006
Location: Chandigarh, India
Posts: 21,081
Send a message via Yahoo to devils casper
There is a space between -lu and /dev
Code:
ls -lu /dev | grep tty | grep username
__________________
It takes a lot of time to be a genius, you have to sit around so much doing nothing, really doing nothing. - Gertrude Stein
New Users: Read This First
devils casper is offline  
Old 09-28-2009   #5 (permalink)
Just Joined!
 
Join Date: Sep 2009
Location: UK
Posts: 2
tty

Thanks devils casper, that worked fine..Cheers
smithyd is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 02:05 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2