it.megocollector.com

  • Tips and Tricks
  • Linux
  • Scripts
    • AutoIT Scripts
    • INNO Scripts
  • WordPress
  • Misc
  • Software Packaging
  • Windows
  • Media

Remove the Last Login History

March 9, 2016

There are some interesting articles on how to clear out the last login history, however, all of them offer the same result.  From several approaches, I have formulated a short and efficient one-liner.

The three files are /var/log/wtmp (successful login/logout) /var/log/btmp (bad login attempts) and /var/log/lastlog (last logged in). The are respectively accessible via the last, lastb, and lastlog commands.

This approach is offered by many sites.

echo > /var/log/wtmp
echo > /var/log/btmp
echo > /var/log/lastlog

From that I tried the following and this didn’t work and produced an error /var/log/[bw]tmp: ambiguous redirect

echo > /var/log/[bw]tmp /var/log/lastlog

However, after trying a few things, I discovered the truncate command.  By using the -s switch and selecting the size of zero, we can achieve a working one-liner.

truncate /var/log/[wb]tmp /var/log/lastlog -s0

Source(s)

  • http://www.shellhacks.com/en/HowTo-Clear-or-Remove-Last-Login-History-in-Linux
  • https://www.cyberciti.biz/faq/howto-display-clear-last-login-information/
  • http://stackoverflow.com/questions/2423281/how-to-empty-truncate-a-file-on-linux-that-already-exists-and-is-protected-i
Tagged: lastlastblastlogLinuxlogin

Post navigation

««Monitor multiple logs simultaneously
ScreenFetch»»

About

Welcome to my world! Here you may find bits and pieces of information that I have found useful or have stumbled upon myself. It is essentially my knowledge base. If anyone finds anything of interest or useful, that would be a plus.

Categories

  • Linux (278)
  • macOS (2)
  • Media (11)
  • Misc (38)
  • Raspberry Pi (3)
  • Scripts (183)
    • AutoIT Scripts (19)
    • INNO Scripts (9)
  • Software Packaging (19)
  • Tips and Tricks (415)
  • Windows (19)
  • Wordpress (44)

Popular

  • i8042prt Event ID 7026 The following boot-start or system-start driver(s) failed to load (114,643)
  • Adobe Reader 9 or Adobe Acrobat 9 can not view PDF files in a Web Browser error and fix (78,133)
  • EPSON Scan jpeg plug-in unable to write to file error and fix (53,983)
  • #1045 – Access denied for user ‘root’@’localhost’ (using password: NO) fix (49,123)
  • Convert mAh to mWh and mWh to mAh for Notebook Laptop Batteries (48,277)
  • Install JDK (Java Development Kit) on a RedHat Linux System (46,129)
  • How to share a folder without password in Windows 10 home network (42,726)
  • Create a 7zip Self Extractor (7zS.sfx or 7z.sfx) (41,575)
  • eHome Infrared Receiver not recognized by Windows XP (31,641)
  • Microsoft Word Accept and Reject Change Options Greyed Out (28,158)
  • Access Red Hat Enterprise Linux 5 with XManager Remote Control (27,319)
  • Setup JBoss on Red Hat Enterprise Linux 5 (RHEL5) Server (23,724)
  • PHP 5.3.2 with IIS6 and FastCGI Installation Guide – Updated (21,983)
  • Unlock the McAfee VirusScan Enterprise 8.5i User Interface (21,458)
  • Internet Explorer 7 Gold RunOnce Removal (20,815)
  • Windows XP SESSION3_INITIALIZATION_FAILED stop error with 0x0000006F fix (19,701)
  • How to automate Selenium scripts (19,272)
  • atibtmon.exe Runtime Error! [Resolved] (19,191)
  • SVCHOST.EXE Application Error 0XC00000FD 0X76A9F4F9 100% CPU Resolved! (19,139)
  • How to enable and configure Java JRE to work in Firefox in CentOS 5 and RHEL 5 Linux (18,057)
  • How to install the Intel 82845G Graphics driver on Microsoft Vista (16,957)
  • Remove WGA Notifications with AutoIT (16,282)
  • How to Setup IIS6 with the Tomcat 5 Connector – Step by Step Guide. (16,068)
  • Disable firewall on Red Hat Enterprise Linux (RHEL) Server (15,766)
  • Internet Explorer 8 Beta RunOnce Removal (15,021)
  • Use netstat in Linux to determine port conflicts (14,451)
  • Setup JBoss on Ubuntu 8.0.4 LTS Server Edition (14,404)
  • How to Sort Text Using Notepad++ (14,310)
  • EPSON Print CD missing PICSDK.DLL (13,773)
  • DOS Batch – Find and Replace all occurrences of a string with another string (13,313)
  • dnf Module yaml error: Unexpected key in data (13,280)
  • Connect to VNCServer on Red Hat Enterprise Linux (12,725)
  • Proxmox Backup Server (PBS) with iSCSI [Resolved] (12,553)
  • Proxmox Backup Server (PBS) with NFS [Resolved] (12,269)
  • Microsoft Office 2003 missing SKU011.CAB (12,238)
  • Autorun JBoss on Red Hat Enterprise Linux 5 (RHEL5) Server (12,110)
  • Factory reset the Linksys PAP2 Phone Adapter for Vonage (11,636)
  • Unlock Western Digital WD80EB Drives (10,612)
  • Create a Bootable Windows XP SP3 Integrated with Post-SP3 fixes CD (10,396)
  • RDP into CentOS 7 with XRDP (9,986)
  • Vsftpd FTP Server With Virtual Users (CentOS 7) (9,624)
  • Setup JBoss on Ubuntu 8.1.0 Server Edition (9,469)
  • Install and use ncsd for name service caching (9,060)
  • Innounp, Inno Setup Unpacker 0.23 (Build: 080318) supports INNO Setup 5.2.3 (8,928)
  • Foxit Reader: Invert All Colors of Text (8,905)
  • Add Root Certificates to a CentOS Linux Server (8,591)
  • Hot to enable a Symantec Antivirus LiveUpdate that is grayed out (8,537)
  • Create a service for JIRA on CentOS 5 or RHEL 5 (8,523)
  • Event ID 1091 Group Policy … failed to log RSOP. (8,293)
  • Install Tomcat 5.5.28 on RHEL5 / CentOS5 (8,093)
Copyright © 2006-2025 it.megocollector.com