サーバーのよく使うコマンドメモ : lastlog

2016/10/24

Tips サーバー テクノロジー

t f B! P L

Summery

対象サーバーにログインした最終日時を表示する。

Construction

$ lastlog [options]

Option

-b, --before DAYS print only lastlog records older than DAYS -h, --help display this help message and exit -R, --root CHROOT_DIR directory to chroot into -t, --time DAYS print only lastlog records more recent than DAYS -u, --user LOGIN print lastlog record of the specified LOGIN

Sample

## user全て $ lastlog Username Port From Latest root pts/1 localhost Sat Jan 30 11:05:04 +0900 2016 daemon **Never logged in** bin **Never logged in** sys **Never logged in** sync **Never logged in** games **Never logged in** man **Never logged in** lp **Never logged in** mail **Never logged in** news **Never logged in** uucp **Never logged in** proxy **Never logged in** www-data pts/0 192.168.1.114 Sun Oct 23 06:41:45 +0900 2016 backup **Never logged in** list **Never logged in** irc **Never logged in** gnats **Never logged in** nobody **Never logged in** systemd-timesync **Never logged in** systemd-network **Never logged in** systemd-resolve **Never logged in** systemd-bus-proxy **Never logged in** sshd **Never logged in** mysql **Never logged in** web pts/0 192.168.1.114 Sun Oct 23 06:41:45 +0900 2016 bind **Never logged in** postfix **Never logged in** ntp **Never logged in** ## ユーザー指定 $ lastlog -u root Username Port From Latest root pts/1 localhost Sat Jan 30 11:05:04 +0900 2016

Discription

LASTLOG(8) System Management Commands LASTLOG(8) NAME lastlog - reports the most recent login of all users or of a given user SYNOPSIS lastlog [options] DESCRIPTION lastlog formats and prints the contents of the last login log /var/log/lastlog file. The login-name, port, and last login time will be printed. The default (no flags) causes lastlog entries to be printed, sorted by their order in /etc/passwd. OPTIONS The options which apply to the lastlog command are: -b, --before DAYS Print only lastlog records older than DAYS. -h, --help Display help message and exit. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -t, --time DAYS Print the lastlog records more recent than DAYS. -u, --user LOGIN|RANGE Print the lastlog record of the specified user(s). The users can be specified by a login name, a numerical user ID, or a RANGE of users. This RANGE of users can be specified with a min and max values (UID_MIN-UID_MAX), a max value (-UID_MAX), or a min value (UID_MIN-). If the user has never logged in the message ** Never logged in** will be displayed instead of the port and time. Only the entries for the current users of the system will be displayed. Other entries may exist for users that were deleted previously. NOTE The lastlog file is a database which contains info on the last login of each user. You should not rotate it. It is a sparse file, so its size on the disk is usually much smaller than the one shown by "ls -l" (which can indicate a really big file if you have in passwd users with a high UID). You can display its real size with "ls -s". FILES /var/log/lastlog Database times of previous user logins. CAVEATS Large gaps in UID numbers will cause the lastlog program to run longer with no output to the screen (i.e. if in lastlog database there is no entries for users with UID between 170 and 800 lastlog will appear to hang as it processes entries with UIDs 171-799).

人気の投稿

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。

ブログ アーカイブ