LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 04-16-2015, 11:49 AM   #1
carlos4nyc
LQ Newbie
 
Registered: Feb 2015
Location: New Jersey
Distribution: Ubuntu 14.04
Posts: 11

Rep: Reputation: Disabled
List of one user command


Every time I use the LAST command all users come to my screen, and if I try Date command, only the day, month and time come out. I'm just trying to list my last logins, where can I find a website that helps me with "how to see the day, month and time for a single user?
 
Old 04-16-2015, 12:02 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
See the manpage on last:

Code:
 --time-format format
              Define the output timestamp format to be one of  notime,  short,
              full,  or iso.  The notime variant will not print any timestamps
              at all, short is the default,  and  full  is  the  same  as  the
              --fulltimes  option.  The iso variant will display the timestamp
              in ISO-8601 format.  The ISO format contains  timezone  informa
              tion, making it preferrable when printouts are investigated out
              side of the system.
 
Old 04-16-2015, 12:04 PM   #3
JeremyBoden
Member
 
Registered: Nov 2011
Posts: 938

Rep: Reputation: 174Reputation: 174
I'd never heard of the last command but
Code:
man last
indicates that
Quote:
LAST,LASTB(1) Linux System Administrator's Manual LAST,LASTB(1)

NAME
last, lastb - show listing of last logged in users

SYNOPSIS
last [-R] [-num] [ -n num ] [-adFiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...]
lastb [-R] [-num] [ -n num ] [ -f file ] [-adFiowx] [name...] [tty...]

DESCRIPTION
Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all
users logged in (and out) since that file was created. Names of users and tty's can be given, in which case last will
show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

When last catches a SIGINT signal (generated by the interrupt key, usually control-C) or a SIGQUIT signal (generated by
the quit key, usually control-\), last will show how far it has searched through the file; in the case of the SIGINT sig‐
nal last will then terminate.

The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since
the log file was created.

Lastb is the same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad
login attempts.
....
Code:
man date
will show you the options for date. But something like
Code:
date -R
might be suitable?
 
Old 04-16-2015, 12:07 PM   #4
carlos4nyc
LQ Newbie
 
Registered: Feb 2015
Location: New Jersey
Distribution: Ubuntu 14.04
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks for the reply, but I want to have a screen that give me following:
Thu Apr 16 12:06
I'm using UBUNTU and to be honest, I cannot figure it out how to list the day, the month, the year, and the time for my own name.
 
Old 04-16-2015, 12:10 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
????
did you look at the manpage for the last command?
 
Old 04-16-2015, 12:12 PM   #6
carlos4nyc
LQ Newbie
 
Registered: Feb 2015
Location: New Jersey
Distribution: Ubuntu 14.04
Posts: 11

Original Poster
Rep: Reputation: Disabled
Every time I type : date
I get:
thu Apr 16 12:10:08 EDT 2015

But, how do you filter a list of your numbers of logins?
 
Old 04-16-2015, 12:19 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
last <username>
 
1 members found this post helpful.
Old 04-16-2015, 12:19 PM   #8
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
For date output:

Code:
date '+a %b %e %H:%M'
 
Old 04-16-2015, 01:29 PM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
Quote:
Originally Posted by carlos4nyc View Post
But, how do you filter a list of your numbers of logins?
Using exactly this command:
Quote:
Originally Posted by jpollard View Post
last <username>
 
Old 04-16-2015, 03:53 PM   #10
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 810

Rep: Reputation: 264Reputation: 264Reputation: 264
Quote:
Originally Posted by carlos4nyc View Post
Every time I type : date
I get:
thu Apr 16 12:10:08 EDT 2015

But, how do you filter a list of your numbers of logins?
What are you trying to do?

To filter the output, you'd probably just want to use grep
Code:
last | grep <string to search for>
If the string has spaces, it needs to be in quotes.

If you want to filter the logins for today's date, try:
Code:
last | grep "$(date '+%b %e')"
 
  


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
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 02:14 PM
[SOLVED] Partial list with ls-l in bash script run in cron but full list run from command line redgshost Linux - General 29 01-16-2011 01:14 PM
Finger command to list all the user names narainhere Programming 3 09-03-2007 04:56 AM
List of All user accounts from command line sniff Linux - General 4 07-09-2006 12:02 PM
What command can list the userids in various user groups? davidas Linux - Newbie 1 04-16-2004 10:01 PM


All times are GMT -5. The time now is 02:15 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