• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

last Command Examples in Linux

by admin

The last command displays the history of user login and logout actions, along with the actual time and date. It also has options that enable you to filter users who have logged in through a specific terminal. For example, last 1 will display the details of users who logged in using the first terminal. The last command retrieves information from the /var/log/wtmp file.

Syntax

The syntax of the last command is:

# last [options]

last command examples in Linux

last Command Examples

1. To see the list of last logged in users:

# last 

2. To specify last to use mentioned file instead of /var/log/wtmp:

# last -f /path/file 

3. To restrict last to show specified number of lines:

# last -num 10
# last -n 10 

4. To display the state of logins for specified time:

# last -t YYYYMMDDHHMMSS
# last -t 20140627081600 

5. To suppress the display of hostname field:

# last -R 

6. To display the hostname in last column:

# last -a 

7. To translate the IP to hostname for remote logins:

# last -d

8. To print the full login and logout time and dates:

# last -F 

9. To display the IP in numbers and dots for remote logins:

# last -i 

10. To display the full user and domain name in output:

# last -w 

11. To display the system shutdown entries and run level changes:

# last -x 

Filed Under: Linux

Some more articles you might also be interested in …

  1. hwclock: command not found
  2. dos2unix: command not found
  3. imagemagick for image optimization
  4. CentOS / RHEL 6 : How to disable IPv6
  5. How to Install apt-transport-https package in Debian
  6. Volume “test_vg/lvol0” is not active locally – Error while running lvcreate
  7. btrfs filesystem Command Examples in Linux
  8. Linux rsync command with practical examples
  9. cloud-init : command not found
  10. “sudo: /etc/sudoers is world writable” – How to correct the permissions of sudoers file

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright