LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2007, 07:37 AM   #1
khairilthegreat
LQ Newbie
 
Registered: Oct 2006
Distribution: Kubuntu
Posts: 25

Rep: Reputation: 15
change "who" command output


Hi all

Is it possible to change the who command otput.

The output of who command in my box is:

khairil@serverwarkom:~$ who
khairil :0 2002-01-03 01:01
root pts/1 2007-07-24 19:32 (152.118.99.49)

It says that there is 2 user online. Khairil and root. We can also conclude that khairil connect locally and root connect remotely from IP 152.118.99.49.

Is it possible to change the output of the command. For example the output will be

khairil@serverwarkom:~$ who
khairil :0 2002-01-03 01:01
root :0 2007-07-24 19:32

or something similar thet do not tell any user where is the root connect from.
 
Old 07-24-2007, 08:28 AM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 159

Rep: Reputation: 74
As a quick and dirty fix, you could alias "who" to "who -q".

Code:
alias who='who -q'
This will list just the names of the users logged in without listing any ip's or hostnames.

You'll have to apply this globally to affect your users.

Last edited by rocket357; 07-24-2007 at 08:32 AM.
 
Old 07-25-2007, 12:45 AM   #3
khairilthegreat
LQ Newbie
 
Registered: Oct 2006
Distribution: Kubuntu
Posts: 25

Original Poster
Rep: Reputation: 15
alisaisng who

Thanks rocket 357.

It'sa good solution. Is there enaything else that will work?
 
Old 07-25-2007, 12:55 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Good solution, except that if anybody checks what "who" actually does, it's revealed that it's an alias and then if anybody just used
Code:
which who
and started 'who' from that directory, for example with (I'm not sure at all it's in /bin/, not on Linux atm)
Code:
/bin/who
the output would be again the default one (with ip addresses).

A slightly more complex option would be to wrap the actual 'who' into a script so that regular users could not start 'who', but could start the script that started 'who -q' - the original 'who' would of course be moved to another place, and this script put into it's place, so people would run the script by typing 'who' and not the actual 'who'. Shortly: script in place of real 'who', that runs 'who -q' from someplace else - with users forbidden to use the original executable from where ever it is.

Last edited by b0uncer; 07-25-2007 at 12:57 AM.
 
Old 07-25-2007, 01:03 AM   #5
binary_pearl
Member
 
Registered: Jul 2007
Location: Chicago Illinois
Distribution: SLES 10 SP2/SP3, SLES 11 SP1, OpenSUSE, Sabayon, Gentoo, Fedora 14, RHEL 3/4/5/6
Posts: 98
Blog Entries: 3

Rep: Reputation: 23
You could try doing something like this:

who | sed -e 's/pts\/[0-9]\{1,\}/:0/'

This should replace pts/* with :0.

You may also want to check out the commands "w" and "finger" and "last". These commands may also contain the terminal information that you are trying to hide.

--Shaun

Last edited by binary_pearl; 07-26-2007 at 06:18 AM.
 
Old 07-26-2007, 02:36 AM   #6
khairilthegreat
LQ Newbie
 
Registered: Oct 2006
Distribution: Kubuntu
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks

Thank you all. I'll combine b0uncer and binary_pearl tips.

I think that's the solution i need.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unknown entry in the output of "df -h " command Balakrishna Linux - Newbie 1 12-19-2006 12:17 AM
How can you change the default setting for the "Run Command" program? whited Linux - General 6 02-28-2005 11:34 PM
how do i remove unwanted charaters at "script" command output? linuxzouk Linux - Newbie 4 05-15-2004 07:58 AM
Is it possible to make a "file" that can change its output when accessed? oot Linux - General 5 05-11-2003 08:30 PM
qmail: strange output of "file" command slowleak Linux - Security 1 08-10-2001 10:40 PM


All times are GMT -5. The time now is 03:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration