In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the usage of the Linux basic command last". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Last
Displays previously logged-in user information, and the last command searches the / var/log/wtmp file (or the file specified by the-f option) and lists all the user information in the file. If you prompt "last / var/log/wtmp ∶ NO such file or directory" when executing the last instruction, you need to create this file manually using the directive touch / var/log/wtmp
The lastb directive is used to display the login failed user information, which is the same as last, and the corresponding log file is / var/log/btmp
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Last [- R] [- num] [- n num] [- adFiowx] [- f file] [- t YYYYMMDDHHMMSS] [name...] [tty...]
Lastb [- R] [- num] [- n num] [- f file] [- adFiowx] [name...] [tty...]
2. List of options
Option
Description
-f file name
Specify the log file for login (default is / var/log/wtmp)
-num
Specify how many lines of information last displays
-n num
Same as "- num".
-R
Do not display host name
-a
Show hostname in the last column
-d
Convert non-locally logged-in user ip to hostname
-F
Displays all login and logout times and dates
-o
Read old log files
-w
Show user name and domain name
-x
Display the system shutdown information and the change information of the running level
-t [YYYYMMDDHHMMSS]
Display login information at the specified time
[name]
Displays the login information for the specified user
[tty]
Displays the login information of the specified terminal, last tty1 = last 1
3. Examples
1) display 5 pieces of information recently logged in
[root@localhost] # last-5 / / you can also use last-n 5
/ / Login user login terminal hostname login time logout time duration
Root pts/0: 0.0 Tue Sep 4 13:10 still logged in
Root pts/0: 0.0 Wed Aug 22 15:07-13:09 (12 / 22 Wed Aug 02)
Root pts/1: 0.0 Wed Aug 22 07:46-13:10 (130.05 Wed Aug 23)
Root pts/0: 0.0 Wed Aug 22 07:43-11:02 (03:18)
Root tty1: 0 Wed Aug 22 07:20 still logged in
Wtmp begins Wed Aug 8 18:02:52 2018
2) display the login information of users weijie and root on August 9
[root@localhost ~] # last-t 20180809090000 weijie / / you can see that user weijie is not logged in before 8.9
Wtmp begins Wed Aug 8 18:02:52 2018
[root@localhost ~] # last-t 20180809090000 root / / user root logged in several times before 8.9,
Root pts/0: 0.0 Wed Aug 8 20:19-down (00:05)
Root tty1: 0 Wed Aug 8 20:19-down (00:06)
Root pts/1: 0.0 Wed Aug 8 18:16-20:16 (01:59)
Root pts/0: 0.0 Wed Aug 8 18:08-20:15 (02:06)
Root tty1: 0 Wed Aug 8 18:04-20:16 (02:11)
Wtmp begins Wed Aug 8 18:02:52 2018
3) display the login information of the terminal tty1
[root@localhost ~] # last 1 / / equivalent to last tty1
Root tty1: 0 Wed Aug 22 07:20 still logged in
Root tty1: 0 Tue Aug 21 17:34-down (02:24)
...
Wtmp begins Wed Aug 8 18:02:52 2018
This is the end of the introduction to "the usage of the Linux basic command last". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.