Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
2 answers
2845 views
delete multiple users
I am the root user and I am setting up a menu for another user to use. This other user will only get this menu. There are two options that are interlinked: the first option is to search users. The code I got is: last | awk '{print $1,$4,$5,$6,$7} ' I have checked this code and it works, it shows me...
I am the root user and I am setting up a menu for another user to use. This other user will only get this menu. There are two options that are interlinked: the first option is to search users. The code I got is: last | awk '{print $1,$4,$5,$6,$7} ' I have checked this code and it works, it shows me the usernames and the day they last logged on. For the second option: I want to be able to set a date, and them delete users who haven't been active since that date, using the output of the above command. I am using Linux Mint and Vim text editor.
user93524
Dec 5, 2014, 12:26 PM • Last activity: Jun 16, 2025, 05:06 PM
3 votes
1 answers
8135 views
Difference between last and lastlog?
last | grep IPADDRESS doesn't shows any line, but: lastlog | grep IPADDRESS does. Why?
last | grep IPADDRESS doesn't shows any line, but: lastlog | grep IPADDRESS does. Why?
freaking-good-question (583 rep)
Mar 23, 2015, 08:39 PM • Last activity: May 10, 2025, 06:11 AM
1 votes
1 answers
2438 views
ssh PrintLastLog prints actual login
I connect with my server via ssh and always it shows the last log: `Last login: Sat Mar 19 14:05:17 2016 from...` but that login is my actual login. What's the utility of this info? It should print the previous connection. ---------- Gentoo 64 bits Openssh v7.2
I connect with my server via ssh and always it shows the last log: Last login: Sat Mar 19 14:05:17 2016 from... but that login is my actual login. What's the utility of this info? It should print the previous connection. ---------- Gentoo 64 bits Openssh v7.2
Juan Simón (170 rep)
Mar 19, 2016, 01:28 PM • Last activity: Apr 22, 2025, 09:06 PM
0 votes
3 answers
225 views
Why does lastlog show every user as never having logged in?
When I run `lastlog` the output shows every user on the system as `**Never logged in**` me@me-Z370-HD3P:~$ lastlog Username Port From Latest root **Never logged in** daemon **Never logged in** bin **Never logged in** sys **Never logged in** sync **Never logged in** games **Never logged in** man **Ne...
When I run lastlog the output shows every user on the system as **Never logged in** me@me-Z370-HD3P:~$ lastlog Username Port From Latest root **Never logged in** daemon **Never logged in** bin **Never logged in** sys **Never logged in** sync **Never logged in** games **Never logged in** man **Never logged in** lp **Never logged in** mail **Never logged in** news **Never logged in** uucp **Never logged in** proxy **Never logged in** www-data **Never logged in** backup **Never logged in** list **Never logged in** irc **Never logged in** gnats **Never logged in** nobody **Never logged in** systemd-network **Never logged in** systemd-resolve **Never logged in** messagebus **Never logged in** systemd-timesync **Never logged in** syslog **Never logged in** _apt **Never logged in** tss **Never logged in** rtkit **Never logged in** systemd-coredump **Never logged in** kernoops **Never logged in** uuidd **Never logged in** cups-pk-helper **Never logged in** lightdm **Never logged in** tcpdump **Never logged in** speech-dispatcher **Never logged in** avahi-autoipd **Never logged in** usbmux **Never logged in** nm-openvpn **Never logged in** geoclue **Never logged in** dnsmasq **Never logged in** pulse **Never logged in** _flatpak **Never logged in** avahi **Never logged in** saned **Never logged in** colord **Never logged in** fwupd-refresh **Never logged in** hplip **Never logged in** me **Never logged in** sssd **Never logged in** 'last' output disagrees (as do I). Why the discrepancy? me@me-Z370-HD3P:~$ last me tty7 :0 Fri Jan 10 19:15 gone - no logout reboot system boot 5.15.0-130-gener Fri Jan 10 19:15 still running me tty7 :0 Fri Jan 10 19:11 - 19:12 (00:01) reboot system boot 5.15.0-130-gener Fri Jan 10 19:10 - 19:12 (00:01) me tty7 :0 Mon Jan 6 14:50 - 15:44 (4+00:53) reboot system boot 5.15.0-130-gener Mon Jan 6 14:15 - 15:44 (4+01:28) me tty7 :0 Fri Jan 3 08:04 - 14:14 (3+06:10) reboot system boot 5.15.0-126-gener Thu Jan 2 21:04 - 14:14 (3+17:10) me tty7 :0 Thu Jan 2 08:56 - 21:03 (12:07) reboot system boot 5.15.0-126-gener Wed Jan 1 16:19 - 21:03 (1+04:44) me tty7 :0 Wed Jan 1 12:40 - 13:54 (01:14) reboot system boot 5.15.0-126-gener Wed Jan 1 12:40 - 13:54 (01:14) me tty7 :0 Mon Nov 25 16:46 - 12:39 (36+19:52) reboot system boot 5.15.0-126-gener Mon Nov 25 16:46 - 12:39 (36+19:52) me tty7 :0 Tue Nov 19 16:57 - 16:45 (5+23:47) reboot system boot 5.15.0-126-gener Tue Nov 19 16:57 - 16:45 (5+23:48) me tty7 :0 Thu Nov 14 13:37 - 16:56 (5+03:19) reboot system boot 5.15.0-125-gener Thu Nov 14 12:15 - 16:56 (5+04:41) me tty7 :0 Wed Nov 13 11:30 - 12:14 (1+00:44) reboot system boot 5.15.0-125-gener Wed Nov 13 09:19 - 12:14 (1+02:55) me tty7 :0 Tue Nov 12 17:20 - 09:14 (15:54) reboot system boot 5.15.0-125-gener Tue Nov 12 17:19 - 09:14 (15:54) reboot system boot 5.15.0-125-gener Tue Nov 12 17:16 - 09:14 (15:58) reboot system boot 5.15.0-125-gener Tue Nov 12 16:55 - 09:14 (16:19) me tty7 :0 Tue Nov 12 15:22 - 16:42 (01:19) reboot system boot 5.15.0-125-gener Tue Nov 12 15:21 - 16:42 (01:20) me tty7 :0 Tue Nov 12 09:46 - 12:09 (02:22) reboot system boot 5.15.0-125-gener Tue Nov 12 09:46 - 12:09 (02:23) me tty7 :0 Mon Nov 11 15:38 - 09:45 (18:07) reboot system boot 5.15.0-124-gener Mon Nov 11 15:38 - 09:45 (18:07) me tty7 :0 Mon Nov 11 15:10 - 15:35 (00:25) reboot system boot 5.15.0-124-gener Mon Nov 11 15:10 - 15:35 (00:25) me tty7 :0 Mon Nov 11 15:05 - 15:07 (00:02) reboot system boot 5.15.0-124-gener Mon Nov 11 15:04 - 15:07 (00:03) me tty7 :0 Mon Nov 11 10:53 - 14:59 (04:06) reboot system boot 5.15.0-124-gener Mon Nov 11 10:41 - 14:59 (04:18) me tty7 :0 Mon Nov 11 10:35 - 10:40 (00:05) reboot system boot 5.15.0-124-gener Mon Nov 11 10:34 - 10:40 (00:05) me tty7 :0 Mon Nov 11 10:26 - 10:30 (00:04) reboot system boot 5.15.0-124-gener Mon Nov 11 10:26 - 10:30 (00:04) me tty7 :0 Sat Nov 2 08:45 - 10:18 (9+02:33) reboot system boot 5.15.0-124-gener Sat Nov 2 08:44 - 10:18 (9+02:33) me tty7 :0 Tue Oct 15 08:34 - 08:44 (18+00:10) reboot system boot 5.15.0-122-gener Tue Oct 15 08:33 - 08:44 (18+00:10) me tty7 :0 Sun Sep 1 11:34 - crash (43+20:59) reboot system boot 5.15.0-119-gener Sun Sep 1 11:34 - 08:44 (61+21:10) me tty7 :0 Sat Aug 10 17:05 - 11:33 (21+18:28) reboot system boot 5.15.0-117-gener Sat Aug 10 17:05 - 11:33 (21+18:28) reboot system boot 5.15.0-117-gener Sat Aug 10 16:49 - 17:04 (00:14) reboot system boot 5.15.0-117-gener Sat Aug 10 16:46 - 16:49 (00:02) reboot system boot 5.15.0-117-gener Sat Aug 10 16:45 - 16:46 (00:00) me tty7 :0 Fri Aug 9 07:28 - 16:45 (1+09:16) me tty7 :0 Sat Aug 3 17:39 - 07:28 (5+13:48) reboot system boot 5.15.0-117-gener Sat Aug 3 17:07 - 16:45 (6+23:37) me tty7 :0 Fri Aug 2 12:10 - 17:07 (1+04:56) reboot system boot 5.15.0-117-gener Fri Aug 2 12:10 - 17:07 (1+04:56) me tty7 :0 Fri Aug 2 11:04 - 12:09 (01:05) reboot system boot 5.15.0-116-gener Fri Aug 2 11:04 - 12:09 (01:05) me tty7 :0 Fri Aug 2 10:25 - 11:03 (00:38) reboot system boot 5.15.0-116-gener Fri Aug 2 10:03 - 11:03 (01:00) me tty7 :0 Tue Jul 23 17:34 - 10:02 (9+16:27) reboot system boot 5.15.0-116-gener Tue Jul 23 17:21 - 10:02 (9+16:40) me tty7 :0 Mon Jul 15 07:51 - 17:21 (8+09:29) reboot system boot 5.15.0-113-gener Sun Jul 14 21:15 - 17:21 (8+20:05) me tty7 :0 Sun Jun 30 18:16 - crash (14+02:58) reboot system boot 5.15.0-113-gener Sun Jun 30 15:45 - 17:21 (23+01:35) me tty7 :0 Sat Jun 15 12:14 - 15:44 (15+03:30) reboot system boot 5.15.0-112-gener Sat Jun 15 12:06 - 15:44 (15+03:38) me tty7 :0 Fri Jun 7 08:12 - crash (8+03:54) reboot system boot 5.15.0-112-gener Thu Jun 6 18:25 - 15:44 (23+21:19) me tty7 :0 Thu Jun 6 17:56 - 18:25 (00:28) reboot system boot 5.15.0-112-gener Thu Jun 6 17:56 - 18:25 (00:28) me tty7 :0 Tue Jun 4 15:23 - 14:01 (1+22:37) reboot system boot 5.15.0-107-gener Tue Jun 4 15:23 - 14:01 (1+22:37) me tty7 :0 Mon May 27 08:44 - 15:22 (8+06:38) reboot system boot 5.15.0-105-gener Mon May 27 08:43 - 15:22 (8+06:38) me tty7 :0 Sat Apr 20 19:39 - 08:43 (36+13:03) reboot system boot 5.15.0-105-gener Sat Apr 20 19:38 - 08:43 (36+13:04) me tty7 :0 Sat Apr 20 19:34 - 19:38 (00:03) reboot system boot 5.15.0-102-gener Sat Apr 20 19:33 - 19:38 (00:04) me tty7 :0 Thu Apr 4 15:35 - 19:32 (16+03:57) reboot system boot 5.15.0-101-gener Thu Apr 4 15:34 - 19:32 (16+03:57) me tty7 :0 Tue Mar 19 20:11 - 15:33 (15+19:22) reboot system boot 5.15.0-101-gener Tue Mar 19 19:44 - 15:33 (15+19:48) me tty7 :0 Mon Mar 11 08:19 - 19:44 (8+11:24) reboot system boot 5.15.0-100-gener Mon Mar 11 08:19 - 19:44 (8+11:24) me tty7 :0 Fri Mar 8 13:50 - 08:19 (2+17:29) reboot system boot 5.15.0-100-gener Fri Mar 8 13:34 - 08:19 (2+17:45) me tty7 :0 Mon Mar 4 12:41 - 13:33 (4+00:52) reboot system boot 5.15.0-97-generi Mon Mar 4 12:39 - 13:33 (4+00:53) me tty7 :0 Sat Mar 2 18:57 - 12:00 (1+17:02) reboot system boot 5.15.0-97-generi Sat Mar 2 18:57 - 12:00 (1+17:03) me tty7 :0 Sat Mar 2 18:42 - 18:44 (00:01) reboot system boot 5.15.0-97-generi Sat Mar 2 18:42 - 18:44 (00:01) me tty7 :0 Wed Feb 28 12:33 - 18:41 (3+06:08) reboot system boot 5.15.0-97-generi Wed Feb 28 12:32 - 18:41 (3+06:08) me tty7 :0 Tue Feb 27 15:38 - 15:41 (00:03) reboot system boot 5.15.0-97-generi Tue Feb 27 15:38 - 15:42 (00:03) me tty7 :0 Sun Feb 25 09:24 - 15:27 (2+06:02) reboot system boot 5.15.0-97-generi Sun Feb 25 09:24 - 15:27 (2+06:02) me tty7 :0 Sun Feb 25 08:22 - 09:24 (01:01) reboot system boot 5.15.0-97-generi Sun Feb 25 08:13 - 09:24 (01:10) me tty7 :0 Sun Feb 25 08:05 - 08:12 (00:06) reboot system boot 5.15.0-97-generi Sun Feb 25 08:05 - 08:12 (00:07) me tty7 :0 Fri Feb 23 17:17 - 08:04 (1+14:47) reboot system boot 5.15.0-97-generi Fri Feb 23 17:17 - 08:04 (1+14:47) me tty7 :0 Fri Feb 23 16:57 - 17:09 (00:12) reboot system boot 5.15.0-97-generi Fri Feb 23 16:56 - 17:09 (00:12) me tty7 :0 Tue Feb 20 08:48 - 16:56 (3+08:07) reboot system boot 5.15.0-91-generi Tue Feb 20 08:48 - 16:56 (3+08:07) me tty7 :0 Fri Feb 16 19:12 - 16:34 (21:22) reboot system boot 5.15.0-91-generi Fri Feb 16 19:12 - 16:34 (21:22) me tty7 :0 Wed Feb 14 15:20 - 15:24 (00:03) reboot system boot 5.15.0-91-generi Wed Feb 14 15:20 - 15:24 (00:04) me tty7 :0 Mon Feb 12 15:53 - 16:01 (00:08) reboot system boot 5.15.0-91-generi Mon Feb 12 15:53 - 16:01 (00:08) me tty7 :0 Wed Jan 24 16:35 - 16:55 (00:19) reboot system boot 5.15.0-91-generi Wed Jan 24 16:35 - 16:55 (00:19) me tty7 :0 Sun Jan 21 17:16 - 17:26 (00:10) reboot system boot 5.15.0-91-generi Sun Jan 21 16:45 - 17:26 (00:41) wtmp begins Sun Jan 21 16:45:00 2024
Elder Geek (827 rep)
Jan 13, 2025, 08:41 PM • Last activity: Apr 21, 2025, 10:51 AM
0 votes
1 answers
2924 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 example) within the `last` command? I'm also thinking the command `uniq` would be a good way to elimin...
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 example) within the last command? I'm also thinking the command uniq would be a good way to eliminate any duplicate users who have logged in. Also, the sort command seems to be a good way to sort the list, like I'm wanting to do.
larn (101 rep)
Sep 23, 2020, 03:36 AM • Last activity: Dec 18, 2024, 06:00 PM
3 votes
4 answers
8275 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 system boot 4.19.66-v7+ Thu Jan 1 01:00:01 1970 still running reboot system boot 4.19.66-v7+ Thu Ja...
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   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970   still running
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970   still running
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970   still running
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 27 12:00:33 2020 (18562+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 27 12:00:03 2020 (18562+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 26 12:01:00 2020 (18561+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 26 12:00:31 2020 (18561+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 26 12:00:03 2020 (18561+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 26 12:00:03 2020 (18561+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 26 12:00:03 2020 (18561+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct 25 12:00:33 2020 (18560+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct 25 12:00:03 2020 (18560+11:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct 24 12:00:33 2020 (18559+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct 24 12:00:04 2020 (18559+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct 23 12:00:03 2020 (18558+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct 22 12:00:44 2020 (18557+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct 22 12:00:11 2020 (18557+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct 21 12:00:06 2020 (18556+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 20 12:00:33 2020 (18555+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 20 12:00:04 2020 (18555+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 19 12:00:33 2020 (18554+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 19 12:00:03 2020 (18554+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct 18 12:00:04 2020 (18553+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct 17 12:00:04 2020 (18552+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct 16 12:00:33 2020 (18551+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct 16 12:00:03 2020 (18551+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct 16 12:00:03 2020 (18551+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct 15 12:00:34 2020 (18550+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct 15 12:00:04 2020 (18550+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct 14 12:00:04 2020 (18549+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct 14 12:00:04 2020 (18549+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct 14 12:00:04 2020 (18549+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 13 12:00:33 2020 (18548+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct 13 12:00:03 2020 (18548+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 12 12:00:36 2020 (18547+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct 12 12:00:04 2020 (18547+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct 11 12:00:34 2020 (18546+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct 11 12:00:04 2020 (18546+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct 10 12:00:33 2020 (18545+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct 10 12:00:04 2020 (18545+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct  9 12:02:03 2020 (18544+10:02)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct  9 12:00:04 2020 (18544+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  8 12:00:34 2020 (18543+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  8 12:00:04 2020 (18543+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct  7 12:00:33 2020 (18542+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Wed Oct  7 12:00:04 2020 (18542+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Tue Oct  6 12:00:04 2020 (18541+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct  5 17:38:18 2020 (18540+15:38)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Mon Oct  5 12:00:04 2020 (18540+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct  4 12:00:33 2020 (18539+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sun Oct  4 12:00:03 2020 (18539+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Sat Oct  3 12:00:04 2020 (18538+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct  2 12:00:03 2020 (18537+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Fri Oct  2 12:00:03 2020 (18537+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 18:07:11 2020 (18536+16:07)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 18:07:11 2020 (18536+16:07)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 18:07:11 2020 (18536+16:07)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 18:07:11 2020 (18536+16:07)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 18:07:11 2020 (18536+16:07)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 12:01:00 2020 (18536+10:00)
reboot   system boot  4.19.66-v7+      Thu Jan  1 01:00:01 1970 - Thu Oct  1 12:00:31 2020 (18536+10:00)

wtmp begins Thu Oct  1 10:28:43 2020
I unplugged my Raspberry Pi around 2PM today (27/10/2020 13:55:XX) but it does not show here that it had been unplugged (maybe because it is not a reboot). How do I get last boot times instead of last reboot times? Also, I would like to have "all" the boot times, not only the last. I tried last boot -F but it does not show anything.
vvvvv (163 rep)
Oct 27, 2020, 01:26 PM • Last activity: Nov 21, 2024, 04:00 PM
0 votes
2 answers
1521 views
For some reason 'last' command is not working on my Kali
Generally, `last` command i used for accessing `/var/log/wtmp` file. But I can't use it from today. After I installed the other package to activate `last` it is asking for a wtmp.db file `open_database_ro: Cannot open database (/var/lib/wtmpdb/wtmp.db): unable to open database file`. Despite not hav...
Generally, last command i used for accessing /var/log/wtmp file. But I can't use it from today. After I installed the other package to activate last it is asking for a wtmp.db file open_database_ro: Cannot open database (/var/lib/wtmpdb/wtmp.db): unable to open database file. Despite not having added any additional repositories, for some reason I think that there are new packages that are newly added in the repo. I've recently added VSCode, but here is the thing: I had everything okay 1 week ago. This thing happened after the upgrade (apt upgrade). Now I can't use the last command as usual. What's going on?
Sohan Arafat (170 rep)
Jul 8, 2024, 04:38 AM • Last activity: Sep 28, 2024, 01:11 PM
8 votes
1 answers
3018 views
utmp, wtmp and btmp: what is the 'tmp'
From the earlier question: https://unix.stackexchange.com/questions/127211/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 wasn't answered. [1]: https://unix.stackexchange.com/questi...
From the earlier question: https://unix.stackexchange.com/questions/127211/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 wasn't answered.
bitofagoob (1505 rep)
May 30, 2017, 04:49 AM • Last activity: May 14, 2024, 03:51 PM
1 votes
1 answers
139 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?[![enter image description here][1]][1] [1]: https://i.sstatic.net/oMLH2.png
Why do I have a negative number for system boot in the last (duration) column of the "last" command?enter image description here
J. Doe (81 rep)
Sep 11, 2020, 04:47 AM • Last activity: Mar 5, 2024, 04:30 PM
1 votes
1 answers
181 views
How to get user last login datetime as an ISO 8601 compliant date or timestamp?
I'm running zsh (version 5.9 x86_64-apple-darwin22.0) on macOS (Ventura 13.6.3). I want to figure out if a given user has logged in during last X days. To accomplish this, I want to get the last login datetime of the user or null if there were no logins. I tried to use the [`last`](https://ss64.com/...
I'm running zsh (version 5.9 x86_64-apple-darwin22.0) on macOS (Ventura 13.6.3). I want to figure out if a given user has logged in during last X days. To accomplish this, I want to get the last login datetime of the user or null if there were no logins. I tried to use the [last](https://ss64.com/osx/last.html) command to do it. My problem is, when I execute
-shell
last -1 "john_smith"
I get this string:
john_smith    ttys001    Wed Dec 17 19:19    still logged in
` I can get Dec 17 out of this string using last -1 "john_smith" | awk '{print $4, $5}'. But this doesn't solve my problem as Dec 17 doesn't contain year. I don't know if it is **2023**-12-17 or **1971**-12-17. Is there any way to force last to either produce normal ISO 8601-compliant dates (or timestamps) or at least add years to its standard output so I would have Dec 17, 2023? Alternatively, is there any other command I can use instead of last to get this data for a given user? **Update** I couldn't find a way to get a full login date with last on zsh v. 5.9 and ultimately went with another command (finding all folders under /Users that were modified more than or equal to 123 days, credit goes to [this article](https://mikesolin.com/2017/03/14/resolving-a-freezing-problem-on-lab-macs/)) :
find /Users -type d -maxdepth 1 -mindepth 1 -mtime +123d
Ari Linn (111 rep)
Dec 21, 2023, 06:17 PM • Last activity: Jan 4, 2024, 06:38 AM
1 votes
1 answers
125 views
Change the last modification time of subfolders to that of the oldest file inside
Hello I would like to know how to scan and change the last modified date of all subfolders based on the oldest file in each subfolder. Example of Ubuntu folder structure: ``` home/incoming/media/Something.something.1234/ ``` or ``` /Soemthing Soemthing 1234/ ``` Which means there are folders with do...
Hello I would like to know how to scan and change the last modified date of all subfolders based on the oldest file in each subfolder. Example of Ubuntu folder structure:
home/incoming/media/Something.something.1234/
or
/Soemthing Soemthing 1234/
Which means there are folders with dots and without dots. Same goes for files some with dots and some without. Files are mostly MKV media files maybe some mp4. Also script should also skip all mkv or mp4 files in the root of media folder because they are without any subfolders.
Loop1 (21 rep)
Oct 16, 2023, 12:25 AM • Last activity: Oct 16, 2023, 12:17 PM
1 votes
1 answers
587 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 (showing an alert when time is running out; shutting down the computer when time is up). The part I'm s...
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 (showing an alert when time is running out; shutting down the computer when time is up). The part I'm struggling with is getting the total uptime in minutes for the day. I have looked at this uptime script , but I feel that using last is simplest. $ last -s today Gives me something like: user tty1 Sat Jul 22 14:09 still logged in user tty1 Sat Jul 22 11:50 - down (01:56) I am currently trying to convert the hours in parentheses to minutes, and also converting the 'still logged in' session to minutes. It can work, but I feel like all these options are a bit convoluted. Is there a simpler way to get the total uptime (excluding suspend/sleep) in minutes, or should I find a workaround for these types of outputs?
macwirb (11 rep)
Jul 22, 2023, 05:11 PM • Last activity: Jul 24, 2023, 08:49 AM
0 votes
1 answers
116 views
Write a script to obtain the date of the last month
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.
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 (1 rep)
Jul 4, 2023, 10:17 AM • Last activity: Jul 4, 2023, 12:00 PM
0 votes
1 answers
342 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 pair of **shutdown** and **reboot** entries in wtmp. This is supported by e.g. [this article]...
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 pair of **shutdown** and **reboot** entries in wtmp. This is supported by e.g. [this article](https://access.redhat.com/articles/2642741#last) . An ungraceful shutdown or powerless can be inferred thorough sequential **reboot** entries with no **shutdown** in between. However, I am finding that there isn't always a **shutdown** entry when I run systemctl reboot - I often see sequential **reboot** entries and user sessions are listed as **crash**. Sometimes however, we do get both shutdown and reboot entries logged. Example where I ran systemctl reboot 4 times:
$ last -x reboot shutdown
reboot   system boot  4.14.76-6.1.0-so Wed Aug 31 13:12   still running
shutdown system down  4.14.76-6.1.0-so Wed Aug 31 13:12 - 13:12  (00:00)
reboot   system boot  4.14.76-6.1.0-so Wed Aug 31 12:56 - 13:12  (00:15)
reboot   system boot  4.14.76-6.1.0-so Wed Aug 31 11:24 - 13:12  (01:47)
reboot   system boot  4.14.76-6.1.0-so Wed Aug 31 11:23 - 13:12  (01:48)
shutdown system down  4.14.76-6.1.0-so Wed Aug 31 11:22 - 11:23  (00:00)
I have only found one question that directly addresses this but sadly [it is locked behind RHEL subscription](https://access.redhat.com/solutions/5526311) . I am not dual-booting as per [this other SE question](https://unix.stackexchange.com/questions/465289/lubuntu-reboot-log-entries-don%c2%b4t-seem-to-be-correct) , which may itself be an instance of inconsistent **shutdown** logging in wtmp. Does anyone know why reboots via systemctl would not consistently log **shutdown** alongside **reboot**? Is there a better way to reliably tell whether the system experienced unexpected reboots/power loss?
Neal Eastwood (53 rep)
Aug 31, 2022, 01:31 PM • Last activity: Jun 21, 2023, 11:03 AM
0 votes
1 answers
110 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: [![enter image description here][1]][1] [1]: https://i.sstatic.net/43XPW.png I want to extract the username (first block) and the time of login (second block) using a bas...
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: enter image description here I want to extract the username (first block) and the time of login (second block) using a bash script. The problem I have is that I do not know how to read the results of the log. How can I retrieve specific parts of the log. It seems to me that these are rows and collumns. Can I use that to extract the data? Regards
Niek Jonkman (233 rep)
Feb 13, 2023, 12:24 PM • Last activity: Feb 13, 2023, 12:59 PM
0 votes
0 answers
49 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 his/her username?
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 his/her username?
learner (1 rep)
Jan 25, 2023, 08:28 AM • Last activity: Jan 25, 2023, 09:07 AM
0 votes
2 answers
675 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 need two ways as I don't have syslog everywhere, so basically on some systems last is somewhat working...
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 need two ways as I don't have syslog everywhere, so basically on some systems last is somewhat working while on other - cat syslog. This is what I've got so far last | grep Dec | grep 1 | grep 17:* and cat syslog | grep Dec | grep 1 | grep 17:40 | grep -E ??? But it doesn't work. I mean it works and shows logins for a specific date and hour but nothing more. I cannot figure it out e.g. what to give after the -E parameter in order to get it going. I checked similar threads but they didn't work for me either. In the ??? I tried putting many things with no success. Asterisk gave me some nice outcome, however this way you can only get full hours and if your range starts e.g. 16:40 then Houston, we've got a problem.
kuska (1 rep)
Dec 1, 2022, 09:53 PM • Last activity: Dec 25, 2022, 09:30 AM
0 votes
0 answers
79 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 reboots. I have also looked through systemctl, journalctl but could not find any details regarding what...
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 reboots. I have also looked through systemctl, journalctl but could not find any details regarding what process/setting/job started these reboots. Also, am I correct in assuming that since I see the kernel version number increasing over time, our system is updating the kernel with these reboots? The context to these questions is that after the system reboot on Nov 12, it overwrote our /etc/resolv.conf and broke our services. We want to prevent this from happening again. The bottom line is we will make our dns settings resilient to changes; but we also want to get to the root cause of these reboots and what looks to be subsequent, kernel updates. Thanks!
$ last | grep boot
reboot   system boot  4.18.0-425.3.1.e Tue Nov 15 14:49   still running
reboot   system boot  4.18.0-425.3.1.e Tue Nov 15 14:37 - 14:49  (00:11)
reboot   system boot  4.18.0-425.3.1.e Sat Nov 12 06:17 - 14:49 (3+08:31)
reboot   system boot  4.18.0-372.26.1. Sat Oct 15 06:06 - 06:16 (28+00:09)
reboot   system boot  4.18.0-372.19.1. Sat Oct  8 12:05 - 06:16 (34+18:10)
reboot   system boot  4.18.0-372.19.1. Sat Oct  1 12:05 - 12:04 (6+23:59)
reboot   system boot  4.18.0-372.19.1. Sat Sep 24 12:04 - 12:04 (7+00:00)
reboot   system boot  4.18.0-372.19.1. Sat Sep 17 12:09 - 12:03 (6+23:54)
reboot   system boot  4.18.0-372.16.1. Sat Sep 10 12:03 - 12:08 (7+00:04)
reboot   system boot  4.18.0-372.16.1. Sat Sep  3 12:04 - 12:03 (6+23:58)
reboot   system boot  4.18.0-372.16.1. Sat Aug 27 12:05 - 12:04 (6+23:59)
reboot   system boot  4.18.0-372.16.1. Sat Aug 20 12:05 - 12:04 (6+23:59)
reboot   system boot  4.18.0-372.16.1. Sat Aug 13 12:05 - 12:04 (13+23:58)
reboot   system boot  4.18.0-372.13.1. Sat Aug  6 12:05 - 12:05 (7+00:00)
reboot   system boot  4.18.0-372.13.1. Sat Jul 30 12:06 - 12:04 (6+23:58)
reboot   system boot  4.18.0-372.13.1. Fri Jul 29 14:44 - 12:04  (21:19)
reboot   system boot  4.18.0-372.13.1. Sat Jul 23 12:06 - 12:04 (6+23:57)
reboot   system boot  4.18.0-372.9.1.e Mon Jul 18 14:04 - 12:04 (11+22:00)
reboot   system boot  4.18.0-372.9.1.e Thu Jul 14 14:01 - 12:04 (15+22:03)
reboot   system boot  4.18.0-372.9.1.e Wed Jun 22 13:01 - 14:00 (22+00:58)
Commands I've ran: (if you want to see any of these outputs, let me know!)
$ last reboot
$ last -F | grep "Nov 12"
$ sudo journalctl --list-boots
$ sudo journalctl -b -3 -n
$ find /boot/vmlinuz-4.18.0-*
$ find /boot/vmli*
$ stat /boot/vmlinuz-4.18.0-425.3.1.el8.x86_64
$ sudo journalctl --boot | grep "Linux version"
$ sudo systemctl --type=service
$ sudo crontab -l
EDIT: Requested command and output
$ last -x shutdown
shutdown system down  4.18.0-425.3.1.e Tue Nov 15 14:49 - 14:49  (00:00)
shutdown system down  4.18.0-372.26.1. Sat Nov 12 06:16 - 06:17  (00:00)
shutdown system down  4.18.0-372.19.1. Sat Oct  8 12:04 - 12:05  (00:00)
shutdown system down  4.18.0-372.19.1. Sat Oct  1 12:04 - 12:05  (00:00)
shutdown system down  4.18.0-372.19.1. Sat Sep 24 12:03 - 12:04  (00:00)
shutdown system down  4.18.0-372.16.1. Sat Sep 17 12:08 - 12:09  (00:00)
shutdown system down  4.18.0-372.16.1. Sat Sep 10 12:03 - 12:03  (00:00)
shutdown system down  4.18.0-372.16.1. Sat Sep  3 12:04 - 12:04  (00:00)
shutdown system down  4.18.0-372.16.1. Sat Aug 27 12:04 - 12:05  (00:00)
shutdown system down  4.18.0-372.13.1. Sat Aug 13 12:05 - 12:05  (00:00)
shutdown system down  4.18.0-372.13.1. Sat Aug  6 12:04 - 12:05  (00:00)
shutdown system down  4.18.0-372.13.1. Sat Jul 30 12:04 - 12:06  (00:01)
shutdown system down  4.18.0-372.9.1.e Thu Jul 14 14:00 - 14:01  (00:00)
shutdown system down  4.18.0-372.9.1.e Wed Jun 22 13:01 - 13:01  (00:00)
bennettnw2 (1 rep)
Nov 15, 2022, 06:11 PM • Last activity: Nov 15, 2022, 09:15 PM
18 votes
1 answers
30186 views
Can't explain "crash" entries in output of the 'last' command
Last shows "crash" at 12:02 and 14:18, but the system didn't stop working at that time. The reboot at 15:03, on the other hand, was to recover from an actual crash - our system stopped responding at 14:46. Why does last show two "crashes" prior to the actual crash of the machine? [admin@devbox log]$...
Last shows "crash" at 12:02 and 14:18, but the system didn't stop working at that time. The reboot at 15:03, on the other hand, was to recover from an actual crash - our system stopped responding at 14:46. Why does last show two "crashes" prior to the actual crash of the machine? [admin@devbox log]$ last | head myuser pts/2 myhostname Wed Sep 28 15:12 still logged in myuser pts/2 myhostname Wed Sep 28 15:09 - 15:12 (00:02) myuser pts/2 myhostname Wed Sep 28 15:07 - 15:09 (00:01) myuser pts/1 myhostname Wed Sep 28 15:06 still logged in myuser pts/0 myhostname Wed Sep 28 15:04 still logged in reboot system boot 2.6.18-274.el5PA Wed Sep 28 15:03 (00:09) myuser pts/1 myhostname Wed Sep 28 14:18 - crash (00:44) myuser pts/0 myhostname Wed Sep 28 12:02 - crash (03:01) EDIT: The reboot at 15:03 is real enough - but the two "crash" entries at 14:18 and 12:02 I can't explain.
Kyle (333 rep)
Sep 28, 2011, 07:15 PM • Last activity: Sep 6, 2022, 01:56 PM
0 votes
1 answers
513 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.html but can not find any detailed description of what each column means. Can someone help to des...
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.html but can not find any detailed description of what each column means. Can someone help to describe what each column means? Below is an example of the output of the last:
wtmp begins Mon Apr 25 17:46:05 2022
root@robot:~# last -i
root     pts/3        10.65.111.36     Tue Aug  2 12:48   still logged in
root     pts/3        10.65.146.31     Mon Aug  1 11:00 - 11:23  (00:22)
reboot   system boot  0.0.0.0          Fri Jul 29 18:55   still running
reboot   system boot  0.0.0.0          Fri Jul 29 16:54 - 18:54  (01:59)
reboot   system boot  0.0.0.0          Tue Jul 26 18:45 - 16:53 (2+22:08)
reboot   system boot  0.0.0.0          Tue Jul 26 16:50 - 18:44  (01:53)
root     pts/2        10.65.153.180    Mon Jul 25 17:20 - 20:46  (03:25)
root     pts/1        10.65.153.180    Mon Jul 25 15:13 - 18:26  (03:12)
root     pts/0        10.65.153.180    Mon Jul 25 11:12 - 17:25  (06:12)
reboot   system boot  0.0.0.0          Sun Jul 24 03:23 - 16:49 (2+13:25)
Thanks in advance!
xiaojueguan (173 rep)
Aug 2, 2022, 05:12 AM • Last activity: Aug 2, 2022, 05:23 AM
Showing page 1 of 20 total questions