vinmittal / SecurityTrainingPub

11 stars 5 forks source link

Linux Week 1 Scripts #5

Open vinmittal opened 8 years ago

vinmittal commented 8 years ago

@Akshayanti I guess you had started work on some scripts. Please communicate on which ones and what you are working on. Please also turn on notifications.

Akshayanti commented 8 years ago

Task- Submit the output of who logged in and when on a linux machine.

Linux use the following files to keep track of user login sessions: a] /var/run/utmp - List of current login sessions. b] /var/log/wtmp - List of previous login sessions. c] /var/log/btmp - List all the bad login attempt.

last command

The last command searches back through the file /var/log/wtmp file and displays a list of all users logged in (and out) since that file was created. Names of users and tty's (any terminal on Linux/Unix systems. It also means any serial port on Unix/Linux systems.) can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0. Also, the pts logs are also shown (PTS: Stands for pseudo terminal slave.)

Type the following command: last last username

Sample outputs:

Akshayanti pts/3 :0.0 Thu Oct 29 00:46 still logged in Akshayanti pts/0 :0.0 Wed Oct 28 23:14 still logged in Akshayanti pts/2 :0.0 Wed Oct 28 22:12 - 23:11 (00:58) Akshayanti pts/0 :0.0 Wed Oct 28 21:43 - 23:11 (01:27) Akshayanti tty7 :0 Wed Oct 28 21:41 still logged in

lastb command

The lastb command is the same as last command, except that by default it shows a log of all the bad login attempts, enter: lastb lastb username lastb Akshayanti lastb pts/2

I don't have sample outputs available for the same.