1.last, the default read is the/var/log/wtmp file content, showing the user login history and System restart history
-N #: Displays information about recent # times
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/84/4F/wKiom1eMmdKhn_XTAAHCM0K2_Qc596.jpg-wh_500x0-wm_3 -wmp_4-s_4000073811.jpg "title=" 1.jpg "alt=" Wkiom1emmdkhn_xtaahcm0k2_qc596.jpg-wh_50 "/>
2.LASTB, the default is to read the contents of the/var/log/btmp file, showing the user's wrong way of landing
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/84/4F/wKiom1eMmjjw-NSAAAJEA55cUGQ915.jpg-wh_500x0-wm_3 -wmp_4-s_2741250454.jpg "title=" 2.jpg "alt=" Wkiom1emmjjw-nsaaajea55cugq915.jpg-wh_50 "/>
3.lastlog: Displays the last successful login information for each user;
-U USERNAME: Displays recent login information for a specific user
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/84/50/wKiom1eMmvyRkLBkAAF8wKNBoIg063.jpg-wh_500x0-wm_3 -wmp_4-s_2116241765.jpg "title=" 1.jpg "alt=" Wkiom1emmvyrklbkaaf8wknboig063.jpg-wh_50 "/>
4.who Show users who are logged in
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/84/50/wKioL1eMm6ag4T1VAAB56NOTS5M803.jpg-wh_500x0-wm_3 -wmp_4-s_3237816354.jpg "title=" 1.jpg "alt=" Wkiol1emm6ag4t1vaab56nots5m803.jpg-wh_50 "/>
Test if a user is online if who | grep username&>/dev/null;then
echo "Online"
This article is from the "thick Product Thin Hair" blog, please make sure to keep this source http://joedlut.blog.51cto.com/6570198/1827455
Linux (17) View several commands for user login history