Help with unix commands for user logins

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Help with unix commands for user logins
# 1  
Old 05-06-2012
Help with unix commands for user logins

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

List the last 3 times you logged into the hottub and the command(s) you used to obtain this information


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
1) last agreen1 |head -n 3
2) tail -n 100 messages|grep agreen1


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

University of Illinois, O'Reilly School of Technology, Kelly Hoover, Linux/Unix 1: The Unix file system


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

So basically I telnet into a server called cold1 then ssh into a server called hottub, and then into one called bubble. I have root privilege in my bubble.

When i use the "last" command I was told that it only shows me where I have come from not where I am. If Im logged into the bubble it will show me my hottub logins. If Im on huttub it will show me my cold1 logins. So thats not the way.

So I logged into the hottub server and used cd /var/log to get to the log diectory. Then used the above command: tail -n 100 messages|grep agreen1.

This what my instructor said about my failed attempt: "You have the idea however we have a simpler command with a simpler output, that just shows logins and can specify only the last 3 logins.

Thanks for your help.
Al green
# 2  
Old 05-06-2012
See the man page for last. The last command tells you about logins on the current host; look for options to limit the output both by number of lines and by user. Look at the man page for hostname as that will help you determine where you are.

Last does include information about where you logged in from, but I think that's not important for your assignment. Yes, you are on the right track I think.
This User Gave Thanks to agama For This Post:
# 3  
Old 05-06-2012
Thank you for your help. Im not seeing anything in the last man page. I also was just looking at the tail man page. If I tail the file messages and pipe it through a search of my user name I get the info I need (at least it seems that way) but apparently there is an easier way or simpler command. I have reviewed my lesson several times and Im not seeing it. Ill messages her tomorrow if need be. I was trying for some help here because sometimes it starts a discussion and you can learn more from a group of people.

Thanks for your time.

Al
# 4  
Old 05-06-2012
Seems to me the -n option to last would be helpful as well as the ability to sepecify the user name on the command line to limit what last presents. It is quite possible that in your environment the last command is different. What environment are you running (shell and o/s)?
# 5  
Old 05-06-2012
Im using the bash shell and Im on a Linux os.
# 6  
Old 05-07-2012
Quote:
Originally Posted by iw2198
Im using the bash shell and Im on a Linux os.
Two hints: Suppose you go to the car shop to buy some replacement part. If the dealer asks you which car it is you don't answer "a red one" or "a Ford". You tell him the exact model and the year it was built.

If you are asked about the OS you don't answer "Linux", but ideally the output of uname -a, eventually followed by the distribution and version. For instance:

Code:
Linux brecht 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:32:27 UTC 2010 x86_64 GNU/Linux

This tells the kernel version (2.6.35-22), that it is a 64-bit system (x86_64) and the distribution (Ubuntu), from the kernel version one can deduce that it is Ubuntu 10.04.

The second hint: are you sure you read the right man page? Maybe man pages are not installed (install them) or are not installed properly? Are they indexed correctly? (I am not sure if this is necessary in Linux - in AIX after installing man pages root is supposed to issue catman -w.)

Just to make sure we talk about the same: this is the page you should see:

Code:
# man last
LAST,LASTB(1)                  Linux System Administrator's Manual                  LAST,LASTB(1)

NAME
       last, lastb - show listing of last logged in users

SYNOPSIS
       last  [-R]  [-num]  [  -n  num  ]  [-adFiox]  [  -f file ] [ -t YYYYMMDDHHMMSS ] [name...]
       [tty...]
       lastb [-R] [-num] [ -n num ] [ -f file ] [-adFiox] [name...]  [tty...]

DESCRIPTION
       Last searches back through the file /var/log/wtmp (or the file designated by the -f  flag)
       and  displays  a list of all users logged in (and out) since that file was created.  Names
       of users and tty's 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.

       When last catches a SIGINT signal (generated by the interrupt key, usually control-C) or a
       SIGQUIT signal (generated by the quit key, usually control-\), last will show how  far  it
       has searched through the file; in the case of the SIGINT signal last will then terminate.

       The  pseudo  user  reboot logs in each time the system is rebooted.  Thus last reboot will
       show a log of all reboots since the log file was created.

       Lastb is the  same  as  last,  except  that  by  default  it  shows  a  log  of  the  file
       /var/log/btmp, which contains all the bad login attempts.

OPTIONS
       -f file
              Tells last to use a specific file instead of /var/log/wtmp.

       -num   This is a count telling last how many lines to show.

       -n num The same.

       -t YYYYMMDDHHMMSS
              Display  the  state  of  logins as of the specified time.  This is useful, e.g., to
              determine easily who was logged in at a particular time -- specify that  time  with
              -t and look for "still logged in".

       -R     Suppresses the display of the hostname field.

       -a     Display the hostname in the last column. Useful in combination with the next flag.

       -d     For  non-local  logins,  Linux stores not only the host name of the remote host but
              its IP number as well. This option translates the IP number back into a hostname.

       -F     Print full login and logout times and dates.

       -i     This option is like -d in that it displays the IP number of the remote host, but it
              displays the IP number in numbers-and-dots notation.
       -o     Read an old-type wtmp file (written by linux-libc5 applications).

       -x     Display the system shutdown entries and run level changes.

NOTES
       The  files  wtmp  and  btmp  might not be found. The system only logs information in these
       files if they are present. This is a local configuration issue. If you want the  files  to
       be  used,  they  can  be  created  with  a  simple  touch(1)  command  (for example, touch
       /var/log/wtmp).

FILES
       /var/log/wtmp
       /var/log/btmp

AUTHOR
       Miquel van Smoorenburg, miquels@cistron.nl

SEE ALSO
       shutdown(8), login(1), init(8)

                                           Jul 31, 2004                             LAST,LASTB(1)

I hope this helps.

bakunin
# 7  
Old 05-07-2012
Sorry about that. I almost did post it. These are the os in the order I login to them.

Linux cold1.useractive.com 2.6.32-220.13.1.el6.x86_64 #1 SMP Tue Apr 17 23:56:34 BST 2012 x86_64 x86_64 x86_64 GNU/Linux

Linux hottub3.useractive.com 2.4.34.2-skas3 #7 SMP Fri Mar 21 14:53:59 CDT 2008 i686 i686 i386 GNU/Linux

Linux bubble151.private.useractive.com 2.4.32-bs3 #1 Thu Jun 1 13:41:53 CDT 2006 i686 unknown

---------- Post updated at 06:17 AM ---------- Previous update was at 06:09 AM ----------

This is the man page I have in my hottub and bubble. I have the man page you posted above in the first server, cold1.
Code:
                                                                                                                        
LAST,LASTB(1)  Linux System Administrator's Manual  LAST,LASTB(1)                                                       
                                                                                                                        
NAME                                                                                                                    
       last, lastb - show listing of last logged in users                                                               
                                                                                                                        
SYNOPSIS                                                                                                                
       last [-R] [-num] [ -n num ] [-adiox] [ -f file ] [name...]  [tty...]                                             
       lastb [-R] [-num] [ -n num ] [ -f file ] [-adiox] [name...]  [tty...]                                            
                                                                                                                        
DESCRIPTION                                                                                                             
       Last  searches  back  through the file /var/log/wtmp (or the file designated by the -f flag) and dis             
       plays a list of all users logged in (and out) since that file was created.  Names of users and  tty's            
       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.                                                        
                                                                                                                        
       When last catches a SIGINT signal (generated by the interrupt key, usually control-C)  or  a  SIGQUIT            
       signal (generated by the quit key, usually control-\), last will show how far it has searched through            
       the file; in the case of the SIGINT signal last will then terminate.                                                   
       
      The pseudo user reboot logs in each time the system is rebooted.  Thus last reboot will show a log of            
       all reboots since the log file was created.                                                                      
                                                                                                                        
       Lastb  is  the  same  as last, except that by default it shows a log of the file /var/log/btmp, which            
       contains all the bad login attempts.                                                                             
                                                                                                                        
OPTIONS                                                                                                                 
       -num   This is a count telling last how many lines to show.                                                      
                                                                                                                        
       -n num The same.                                                                                                 
                                                                                                                        
       -R     Suppresses the display of the hostname field.                                                             
                                                                                                                        
       -a     Display the hostname in the last column. Useful in combination with the next flag.                        
                                                                                                                        
       -d     For non-local logins, Linux stores not only the host name of the remote host but its IP number            
              as well. This option translates the IP number back into a hostname.                                       
                                                                                                                        
       -i     This  option  is like -d in that it displays the IP number of the remote host, but it displays            
              the IP number in numbers-and-dots notation.                                                               
                                                                                                                        
       -o     Read an old-type wtmp file (written by linux-libc5 applications).                                         
                                                                                                                        
       -x     Display the system shutdown entries and run level changes.

NOTES
       The files wtmp and btmp might not be found. The system only logs information in these files  if  they
       are  present. This is a local configuration issue. If you want the files to be used, they can be cre
       ated with a simple touch(1) command (for example, touch /var/log/wtmp).

FILES
       /var/log/wtmp
       /var/log/btmp

AUTHOR
       Miquel van Smoorenburg, miquels@cistron.nl

SEE ALSO
       shutdown(8), login(1), init(8)

                           Jul 29, 1999                         1

(END)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Disable multiple ssh logins for an OS user in Solaris

Hi folks, I am fairly a beginner when it comes to Solaris OS administration, but part of my job somehow has scope to provide L1-level of OS administration over a few solaris servers. Now, we have a requirement to limit the number of simultaneous ssh logins/sessions to the server, sort of... (0 Replies)
Discussion started by: engrcha
0 Replies

2. Solaris

[Resolved] Strange Issue with user logins

Ok got a strange one here. None of my user accounts are able to login into the system. When trying to ssh to the server i get the following. Could not chdir to home directory /home/<homedir>: Permission denied /bin/sh: Permission denied I checked the permissions on the home directory and even... (7 Replies)
Discussion started by: JoeDirte
7 Replies

3. Red Hat

Limit root user of SSH logins

Hi team, I tried to modify the /etc/security/limits.conf file to limit the root user for more one login. I added the line in limits.conf file like: @root hard maxlogins 1 I also tried to modify /etc/ssh/sshd_config to limit the root userlogin by adding this: ... (10 Replies)
Discussion started by: leo_ultra_leo
10 Replies

4. Solaris

Configure Solaris to accept Active Directory user logins

Is it possible to configure a Solaris server to authenticate users against an Active Directory server when logging in via ssh? I've seen some docs out there, I've followed their instructions, but it does not work. And I'm beginning to wonder if it is possible or even supported by Oracle. The... (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

5. Shell Programming and Scripting

Script that outputs user logins sorted by duration

Hello, I want to write a script that takes a username as input and outputs the user's logins sorted by duration. Also I want to exclude the "still logged in" entries. I use the "last" command but Im having problems sorting the entries based on the duration. Can you help me? Thanks a lot =) (4 Replies)
Discussion started by: ddante
4 Replies

6. Solaris

User Logins

Is the below logins are needed in the machine..... nuucp , uucp ,smmsp , svctag , listen , webservd , ip ( We are not using printers), Can you help in these? Regards, kumar (3 Replies)
Discussion started by: rajeshkumarvg
3 Replies

7. AIX

Logging user logins

I want to know how I can turn off and turn on login logging. We have a server that appears to have stopped logging user logins. Running the who command shows nothing and the last command shows no logins for a month. The var/adm/wtmp file isn't full and there is plenty of space in the var file... (2 Replies)
Discussion started by: daveisme
2 Replies

8. Solaris

stay in multi user mode but stop logins to system?

I want to apply patches in multiuser mode but stop logins of other users while I do it? What is the best way to do this? I will be connected to the system via a putty session over a serial cable from another system (console is messed up)... Should I put in a dummy passwd and shadow file... (7 Replies)
Discussion started by: NewSolarisAdmin
7 Replies

9. UNIX for Dummies Questions & Answers

Linmit user logins

Hello everyone, traditionally a user can log in on more than one machine as much as they want. In AIX 4.3, Is there a way to make it so that if the user is already logged on, the system will not let them log on, therefor not run their logon profile script again? (limit the user to one machine at a... (1 Reply)
Discussion started by: raidzero
1 Replies

10. Shell Programming and Scripting

Trapping user logins in python ( post #1)

I am writting a daemon in python which should start at system start up with all inet.d services on an NIS server. Then it should listen to any user login and then start a new process for that user on his login which will continue throughout his entire session. Can anyone give any help or any... (1 Reply)
Discussion started by: thinkgeek
1 Replies
Login or Register to Ask a Question