Linux command
last 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
last
Example
last username
Example
last -n 10
Example
last -F
Example
last -i
Example
last -s -7days
Example
last reboot
Example
lastb
说明
last searches back through the /var/log/wtmp file and displays a list of all users logged in and out since that file was created. The related lastb command shows failed login attempts from /var/log/btmp.
参数
- -a, --hostlast
- Display the hostname in the last column
- -d, --dns
- Translate IP addresses to hostnames for remote logins
- -f, --file FILE
- Use a different file instead of /var/log/wtmp
- -F, --fulltimes
- Print full login and logout times and dates
- -i, --ip
- Display IP addresses instead of hostnames
- -n, --limit NUM
- Show only the specified number of lines
- -R, --nohostname
- Do not display the hostname field
- -s, --since TIME
- Display logins since the specified time
- -t, --until TIME
- Display logins until the specified time
- -w, --fullnames
- Display full user and domain names
- -x, --system
- Display system shutdown entries and runlevel changes
- -p, --present TIME
- Display who was present at the specified time
- --time-format FORMAT
- Define output time format (notime, short, full, iso)
FAQ
What is the last command used for?
last searches back through the /var/log/wtmp file and displays a list of all users logged in and out since that file was created. The related lastb command shows failed login attempts from /var/log/btmp.
How do I run a basic last example?
Run `last` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --hostlast do in last?
Display the hostname in the last column