Questions tagged [last]

`last` is a command that shows a listing of the last logged in users.

Filter by
Sorted by
Tagged with
1 vote
1 answer
116 views

Get total time system has been used today - in minutes

I want to set a daily limit as to how long my computer can be on in a single day. In order to do so, I'm writing a cron script that will take appropriate action when certain milestones are reached (...
macwirb's user avatar
  • 11
0 votes
1 answer
44 views

Write a script to obtain the date of the last month [closed]

I would like to obtain the date of the previous month as output and store it in a variable using a bash script. For example, if today's date is 07/04/2023, I would like the output to be 06/04/2023.
Ganesh Hite's user avatar
0 votes
1 answer
57 views

How to loop trough wtmp and extract certain data?

I am using the following command to save wtmp (last command) to a logfile: last -F | grep -i -e pv -e nv -e pp > last.log Result: I want to extract the username (first block) and the time of ...
Niek Jonkman's user avatar
0 votes
0 answers
34 views

Last login command, alias in csh

In the C shell, how can we display the login history of a particular user using an alias in such a way that the user only enters the alias name and the number of lines to be displayed without typing ...
learner's user avatar
0 votes
2 answers
138 views

Last logins during last hour

OK, so basically I'm trying to give a specific date and time and I want to see all the logins that were made during the hour range, e.g. last hour or two last hours from the time and date given. I ...
kuska's user avatar
  • 1
0 votes
0 answers
53 views

What service/job is starting these reboots according to the output from `last`

Have a few questions regarding the output below. One question is, what is causing these reboots? Like what systemd service or cron job? I've looked at the cronjobs and none of them had to do with ...
bennettnw2's user avatar
0 votes
0 answers
27 views

How can I list multiple logins?

Last command is very useful to show the logins. How can I use it (or any other command) to show which logins overlap (each other) in time? This seems to be difficult.
user545624's user avatar
0 votes
1 answer
92 views

Missing shutdown entries in wtmp despite graceful reboots

Linux system with kernel 4.14.76 and last from util-linux 2.35.1. I am using last -x reboot shutdown to detect abrupt shutdowns and power loss. To my understanding, a clean reboot should show as a ...
Neal Eastwood's user avatar
-1 votes
1 answer
118 views

how to understand the each column of output of last

I was using the command last to find out what or who reboot our server but got confused with the output. I've looked the documentation and man page of last https://man7.org/linux/man-pages/man1/last.1....
xiaojueguan's user avatar
1 vote
0 answers
127 views

Use `last` command to show non-interactive sessions

We use the command last to show if other users connected to an embedded system. For interactive ssh-sessions this works fine. But we use MATLAB GPU coder which provides build code to embedded system. ...
MaKaNu's user avatar
  • 131
1 vote
0 answers
298 views

How to monitor /dev/pts/X sessions?

I was trying to monitor some pts sessions I spawned using the Python pty module. Its a simple code like the following: import pty pty.spawn("/bin/bash") I can see in the /dev/pts/ directory ...
Harsh's user avatar
  • 121
3 votes
1 answer
2k views

What causes wtmp to be cleared?

I noticed that on one of my machines the last command returned nothing. I determined the cause of this to be an empty /var/log/wtmp file. What would cause this to be empty? I assume the "tmp"...
qq4's user avatar
  • 509
2 votes
0 answers
144 views

last reboot command shows strange behavior (or maybe im wrong)

In last reboot command normally if im not wrong it shows the last reboot time and n-2 reboot time but as you can see in below image it is showing same time for last 4 reboots reboot system boot 3....
OmiPenguin's user avatar
  • 4,178
0 votes
1 answer
404 views

last: command not found after upgrading CentOS

I upgrade CentOS from 7 to 8. There is no last command. $ which last /usr/bin/which: no last in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) I fail to install last with dnf install. $...
SparkAndShine's user avatar
-1 votes
1 answer
842 views

last: invalid option -- 's'

I learned from several posts that we can use the -s (since) option to show login events that took place since a specific date. However, it encountered the error invalid option. root@VM-0-6-centos ~ $ ...
SparkAndShine's user avatar
1 vote
0 answers
85 views

machine uptime is not consistent with last command

we have 3 rhel servers version 7.6 ( part of cluster with 8 machines ) on rhel server 1 machine uptime is uptime 10:25:51 up 23:48, 1 user, load average: 0.02, 0.09, 0.13 on rhel server 2 machine ...
yael's user avatar
  • 12.7k
1 vote
0 answers
171 views

Script to add hours and minutes of an individual user, then display on one line

New to Linux, lots to learn! I am attempting to write a bash shell script in vi that will output the number of hours and minutes a user has been logged in over the last 7 days. I am working through ...
Primera's user avatar
  • 11
1 vote
3 answers
1k views

How to get last boot times?

I have a raspberry pi. I have a crontab running and telling it to reboot at mid-day every day (sudo reboot now). Here is the result of last reboot -F: myuser@mypiname:~ $ last -F reboot reboot ...
vvvvv's user avatar
  • 123
0 votes
1 answer
783 views

View users who logged in during a specific time period using last

What I'm looking to do is get a sorted list of all users that have logged in during a specific time frame (say, for example, since the start of September). How would I specify a time frame (like my ...
larn's user avatar
  • 101
1 vote
0 answers
89 views

Negative number in the last column of the "last" command

Why do I have a negative number for system boot in the last (duration) column of the "last" command?
J. Doe's user avatar
  • 81
0 votes
0 answers
148 views

Need help deciphering `last reboot -F` output

I have a system where this is the output of last reboot -F reboot system boot 3.10.0-1127.13.1 Tue Aug 18 14:14:16 2020 - Wed Aug 19 07:14:44 2020 (17:00) reboot system boot 3.10.0-1127.10.1 ...
NevDull's user avatar
  • 31
1 vote
0 answers
117 views

`Last` command not working or am I not logged in?

Last command does not show me as logged in. What should I do? I want to run the last command to see all users logged in on a specific date, but the output of last is wtmp begins followed by a date.
M.Ionut's user avatar
  • 21
1 vote
0 answers
360 views

Ubuntu last reboot - repeating end time

I'm seeing the following events and I'm not sure why and how. reboot system boot Tue Dec 31 13:31:03 2019 still running reboot system boot Mon Dec 30 14:15:35 2019 - Tue Dec 31 13:30:46 2019 ...
lalatnayak's user avatar
0 votes
1 answer
104 views

What causes multiple simultaneous shut down times in 'last' command output?

I am troubleshooting some outage issues on a server, with the suspicion that the server is restarting intermittently. When I run the last command, I see the following output (I added line numbers for ...
ninapavlich's user avatar
0 votes
0 answers
364 views

User Lastlog login datetime did not update

I use lastlog to check latest login datetime. Here are steps I use to update my latest login datetime. 1) Try to Login to that user sudo su userA 2) Exit that user and login to root then check ...
Binh Nguyen's user avatar
0 votes
2 answers
2k views

Get time of the last session in seconds

I'm getting the time of the last session of an specific user using the last command like below: last -aiF -n 1 fakeuser The output of this command is something like: fakeuser pts/0 Tue Nov 27 11:...
James's user avatar
  • 113
0 votes
1 answer
270 views

How can I write a shell script to filter the last command?

I want to write a script for login statistics. I want to count how many times a user logged in, and then display them in ascending, or descending order, given by the end user. The problme being, i don'...
Bakos Dominik's user avatar
0 votes
2 answers
55 views

how can i make 'last -n' return just the n lines of users?

I wrote this simple awk program: last -n 10 | awk'{print "username: " $1}' I was surprised when i got the following output: > username: someUsername1 > username: someUsername2 > username: ...
Z E Nir's user avatar
  • 241
1 vote
2 answers
3k views

MacOS: What file does the command `last` get its information from?

Can't seem to find where this last command gets its information from. Does anyone know what file it uses (specifically for Unix macOS) ? Tried cat /var/log/wtmp, cat /var/run/utmp, cat /var/log/...
AymenTM's user avatar
  • 277
3 votes
3 answers
14k views

how to find lastlog details in solaris

I need the equivalent command of linux lastlog in solaris, need to write a script to find the the users last login date and time in solaris servers. Linux its very easy to fetch using lastlog command. ...
judi's user avatar
  • 71
2 votes
2 answers
506 views

Does a shortcut exist to auto scroll to the top of a command response in terminal?

Is there a shortcut (keyboard) to automatically scroll back to the beginning of a response to a command? Example: I open the terminal and type the 'last' command and press enter. A long lost of ...
MarkMark's user avatar
  • 563
1 vote
1 answer
1k views

Grep regex not working [duplicate]

So I'm creating a simple grep command that gets only the last logged in people who's username starts with 161 and has 3 digits next to it: last | grep "^161[0-9]{3}" However it doesn't print ...
David Mathers's user avatar
7 votes
1 answer
2k views

How to make `last` shows also suspend/resume times?

I have notebook and want to store information for every day, when computer is running or not (with precise to minutes). Here is output from last command: dima tty1 :0 Sat ...
diralik's user avatar
  • 227
2 votes
0 answers
2k views

Any difference between a reboot vs. shutdown/restart on AIX?

Is a reboot functionally different than performing a shutdown/restart on AIX servers? If they are the same, why are the timestamps different between the 'last system boot' and 'last reboot'? $ who -...
Jack E.'s user avatar
  • 21
0 votes
1 answer
457 views

Using if/else statement in awk

Normally I can detect user's last logon time if last return anything via below function. My question is : if last doesn't return anything then I want to look in the user's home directory date and ...
Cell-o's user avatar
  • 505
1 vote
0 answers
208 views

Ignore certain hosts in last log

I have an ansible job that uses ssh to perform tasks on many servers. It uses an authorized key to gain entry. When I run the last command it just shows a long list of root logins from the ansible ...
paxamus's user avatar
  • 94
1 vote
1 answer
3k views

What is the meaning of "crash" from the output of the last command?

What is the meaning of "crash" from the output of the last command? root pts/0 mastrt03 Wed Jan 24 11:54 - crash (07:12) We have couple of lines with "crash" on our mastrt03 machine.
yael's user avatar
  • 12.7k
10 votes
1 answer
14k views

Debian - two entries in `last reboot` in `still running`

What can be a reason for last -x reboot showing two last entries as still running? Besides, I'm pretty sure I did not reboot this server December, 16, though it could be something with power on ...
Cthulhu's user avatar
  • 205
5 votes
1 answer
1k views

What is the purpose of the 10th column of the `last` command's output?

I see a suspicious pattern in a last command output on RHEL: $ last reboot reboot system boot 3.10.0-514.21.1. Wed Dec 13 10:25 - 11:53 (01:28) reboot system boot 3.10.0-514.21.1. Mon Oct ...
boardrider's user avatar
1 vote
0 answers
31 views

Command ‘last’ - problems [duplicate]

I have this problem using the command ‘last’. My task is to find names of people, that have been logged in at night hours (22:00 - 5:00). So I’ve tried to save the first number (22) to a variable and ...
Tamara123's user avatar
7 votes
1 answer
4k views

Understanding the output of last reboot shutdown

When I use the command last -x reboot shutdown I get an output like this: reboot system boot 2.6.32-279.14.1. Tue Jul 18 22:03 - 03:20 (05:17) shutdown system down 2.6.32-279.14.1. Tue Jul 18 ...
Karim's user avatar
  • 171
3 votes
0 answers
1k views

What could 'unknown' user in the output of the `last` command mean?

Occasionally I will see an odd entry like this one in my last ouput: (unknown :0 :0 Tues Jul 4 06:51 - 06:51 (00:00) Afaik, this should not happen ever, and I cannot find ...
Chev_603's user avatar
  • 296
2 votes
1 answer
195 views

LinuxMint - `who`, `w` and `last` don't report terminal-emulators anylonger

I'm running an up-to-date version of LinuxMint (an Ubuntu-fork), and I've noticed that who, w and last have all stopped registering activity on terminal-emulators (like xterm) - eg. if you open a ...
Baard Kopperud's user avatar
6 votes
1 answer
3k views

utmp, wtmp and btmp: what is the 'tmp'

From the earlier question: why are utmp, wtmp and btmp called as they are? I would like to now what the 'tmp' part is. Is it 'temp/temporary'. As you can see from the earlier question, that part ...
bitofagoob's user avatar
  • 1,355
1 vote
1 answer
524 views

Why do I get this at the end of a `last` command?

When I run the last command on one of my Raspberry Pi's running Raspbian I get this at the end: wtmp begins Thu Jan 1 01:00:01 1970 When I run the last command on a proper operating system, such as ...
bitofagoob's user avatar
  • 1,355
0 votes
0 answers
152 views

Last users logged in the past 30 minutes

I used this command in ubuntu to find the last ussers logged in the past 30 minutes: last -s -30m --fullnames |head -n -1|awk '{print $1}' | sort -u I need the equivalent for Centos 7. For CentOS ...
user228102's user avatar
2 votes
0 answers
96 views

How to view users logged in since last 5 minutes in linux command line? [duplicate]

I am fairly new to linux and trying to learn the terminal commands. I want to see the list of users who logged in since last 5 minutes. I searched the internet but almost every place solution uses a ...
Bhavik's user avatar
  • 181
3 votes
1 answer
887 views

last reboot -F shows overlapping timespans

I just found some odd behaviour on one of our servers that I can't explain myself. It is about both middle lines. I would assume that the timespans for the boot user must not overlap, however, they do:...
Thomas Fankhauser's user avatar
1 vote
0 answers
1k views

Why is there a difference between the last and lastlog command records, and why is there no recent login record for user in lastlog records?

While testing the last command on my system I got the following result and could not make sense of the lines with down and crash at their ends, as all seem to be connected to a tty7 login: george ...
George Udosen's user avatar
1 vote
2 answers
2k views

last - user reboot - logged-in period

I have the following lines extracted from the output of last. It shows two reboots, and that userA was logged in right up to the reboot. So far, I am able to interpret the data. However, what I do ...
Dohn Joe's user avatar
  • 215