LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 12-25-2015, 03:09 AM   #1
learnlinuxvn
LQ Newbie
 
Registered: Dec 2015
Posts: 6

Rep: Reputation: Disabled
Help me with command in linux


Let me ask you use who command if I only want to show only the username and login now how I have
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	47
Size:	7.7 KB
ID:	20368  
 
Old 12-25-2015, 03:18 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
The login name is displayed on the very left side.
If $ is displayed, you are logged in as user.
If # is displayed, you are logged in as root.
 
Old 12-25-2015, 03:24 AM   #3
learnlinuxvn
LQ Newbie
 
Registered: Dec 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
I want to filter condition show who command to display only the login names and hours logged
 
Old 12-25-2015, 04:18 AM   #4
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by learnlinuxvn View Post
I want to filter condition show who command to display only the login names and hours logged
Well... A little bit of English improvement would be a GREAT help for the rest of your work... As docs are written in english and to get proper help, it's better to be understood... I'm not sure we understand what you want...

I guess... That you want to display some info exclusively... So:
1. man man.... USE MAN... man who => Why ? Because OFTEN an argument does what you want.
2. then: "man whatever-you-need"...
3. finally LEARN: grep, sed, awk, Bash (or eq).... Grep/sed helps you to filter text... awk kinda-parse records..

Good luck.

Garry.

PS/ $ who -s ??

Last edited by NoStressHQ; 12-25-2015 at 04:59 AM. Reason: Reduced mess... a bit :)
 
Old 12-25-2015, 08:30 AM   #5
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Code:
man who
...
 
Old 12-25-2015, 08:32 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,597

Rep: Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690
Expand the question

Agree with above, your meaning is unclear.

Do you mean you want the logon name and time for the users currently logged in?

That can be pulled in several ways, and filtered in several ways to avoid displaying what you do NOT want.

I have a snip that may be useful:
Code:
#!/bin/bash
# awkc - print out one or more columns

p=\$$( echo $1 | sed 's/,/,\$/g' )
shift
eval "awk '{ print $p }'" $*

#eof
I place this in a script names acol and drop it in /usr/local/bin with permissions 755.

Using that I might try
Quote:
who|acol 1,3,4
to see if that is what was wanted.

Please let us know is that helps. If not, please provide more detail about your question and need.
 
1 members found this post helpful.
Old 12-25-2015, 03:14 PM   #7
Greg321
LQ Newbie
 
Registered: Dec 2015
Posts: 8

Rep: Reputation: Disabled
Quote:
Originally Posted by learnlinuxvn View Post
Let me ask you use who command if I only want to show only the username and login now how I have
Since you only want the username and login time, here it is. The first line is the code and below it is the output of the code:

Code:
who | awk '{ print $1, $4 }'

greg 14:57
greg 14:57
greg 15:25
greg 15:36
To add a title for each field
Code:
who | awk 'BEGIN { printf "%-19s" "%-9s\n", "User", "Login Time" } { printf "%-19s" "%-7s\n", $1, $4 }'
User              Login Time
greg              14:57  
greg              14:57  
greg              15:25  
greg              15:36
There is also the w command which is similar to who with gives additional info.

Code:
w

16:04:23 up  1:08,  4 users,  load average: 0.18, 0.15, 0.14
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
greg     :0        14:57   ?xdm?  11:41   0.04s /bin/sh /usr/bin/startkde
greg     pts/0     14:57    1:07m  0.00s  0.72s kdeinit4: kded4 [kdeinit]
greg     pts/1     15:25   29:05   0.06s  0.06s /bin/bash
greg     pts/2     15:36    1.00s  0.16s  0.00s w

Another command is last. You can use this command to see current and passed logins.

There you have it. who, w, and last.

Enjoy!

Last edited by Greg321; 12-25-2015 at 03:54 PM.
 
Old 12-26-2015, 02:09 AM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
I think he want who am i with hours logged

OK
 
Old 12-26-2015, 04:12 AM   #9
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by AnanthaP View Post
I think he want who am i with hours logged

OK
I think that's something "in the way"... But WHERE does he want that ? I suspect it is for the prompt, but maybe I'm wrong...
 
Old 12-26-2015, 08:46 AM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,597

Rep: Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690
waiting ...

I think that at this point we need to wait for the OP to fill us in on what he really needs. We have offered a couple of possible answers to the question he almost asked, and without clarification we are just spinning our wheels. We need direction, and the OP can provide that.
 
Old 12-26-2015, 02:27 PM   #11
Greg321
LQ Newbie
 
Registered: Dec 2015
Posts: 8

Rep: Reputation: Disabled
Quote:
Originally Posted by AnanthaP View Post
I think he want who am i with hours logged

OK
I'm just going with what the OP supplied us. As wpeckham said, we need feedback from the OP if our suggestions had help or not or we're just spinning our wheels on guesses.

As mentioned earlier, Op can try w and last to get additional information on logins.

There is another approach called process accounting. It logs users logins and length of time and what they did, etc. The package name is call psacct

the command is ac

Last edited by Greg321; 12-26-2015 at 02:36 PM.
 
Old 12-26-2015, 02:43 PM   #12
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Well in fact looking at his other posts, it seems he's a lamer... Asking here for us doing his homework for free...

Of course as he can't speak minimal English, don't expect any gratitude .
 
Old 12-26-2015, 04:07 PM   #13
Greg321
LQ Newbie
 
Registered: Dec 2015
Posts: 8

Rep: Reputation: Disabled
Quote:
Originally Posted by NoStressHQ View Post
Well in fact looking at his other posts, it seems he's a lamer... Asking here for us doing his homework for free...

Of course as he can't speak minimal English, don't expect any gratitude .
Yep, we're not mind readers
 
  


Reply



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
Any Linux command output to delimited format. Script should work for any command. torrelm@hotmail.com Linux - Newbie 9 09-04-2014 08:54 AM
LXer: How to access Linux command cheat sheets from the command line LXer Syndicated Linux News 0 07-28-2014 08:30 AM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 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
Open Source Consulting | Domain Registration