{"id":8938,"date":"2021-10-06T18:26:00","date_gmt":"2021-10-06T18:26:00","guid":{"rendered":"https:\/\/putridparrot.com\/blog\/?p=8938"},"modified":"2021-10-06T18:28:36","modified_gmt":"2021-10-06T18:28:36","slug":"checking-who-last-logged-in-and-when-on-ubuntu-server","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/checking-who-last-logged-in-and-when-on-ubuntu-server\/","title":{"rendered":"Checking who last logged in and when on Ubuntu Server"},"content":{"rendered":"<p>You might want to see a list of who logged into your Ubuntu server last or over a time period. Or maybe you want to take a look at more than just that and see more of an audit trail&#8230;<\/p>\n<p><strong>last<\/strong><\/p>\n<p>We can use the command <em>last<\/em> to display a &#8220;listing of last logged in users&#8221;. For example let&#8217;s just get the tail of the list using<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlast | tail\r\n<\/pre>\n<p>or ofcourse we might simple look through all entries using<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlast | less\r\n<\/pre>\n<p>What about if we know the user we&#8217;re interested in, then we can simply use<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlast -x Bob\r\n<\/pre>\n<p>Replacing <em>Bob<\/em> with the username you wish to look for.<\/p>\n<p>There&#8217;s options to specify listing data after a specific time or before a time and more see<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlast --help\r\n<\/pre>\n<p>What if we want even more information.<\/p>\n<p><strong>\/var\/log\/auth.log<\/strong><\/p>\n<p><em>Last<\/em> works well if you&#8217;re interested in users logging into the server, but what about if we just want to check who&#8217;s access a shared drive or the likes, then we can check the \/var\/log\/auth.log like this<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo cat \/var\/log\/auth.log\r\n\/\/ or \r\nsudo less \/var\/log\/auth.log\r\n\/\/ or\r\nsudo tail \/var\/log\/auth.log\r\n<\/pre>\n<p>As per standard piping of commands, I&#8217;ve included an example of using less and tail, but basically we want to list the contents of the auth.log file. Ofcourse as it&#8217;s a file we can grep it (or whatever) as required.<\/p>\n<p>This auth.log file lists sessions being opened and closed, cron jobs and lots more besides. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>You might want to see a list of who logged into your Ubuntu server last or over a time period. Or maybe you want to take a look at more than just that and see more of an audit trail&#8230; last We can use the command last to display a &#8220;listing of last logged in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[140],"tags":[],"class_list":["post-8938","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8938"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8938\/revisions"}],"predecessor-version":[{"id":8950,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8938\/revisions\/8950"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}