last

last

Post by Penna Ela » Sat, 12 Apr 2003 15:19:39



Hi!

Can the administrator change the last command (/usr/bin/last) settings
so that the user can see his last logins/logouts he has done in a
month instead of in a day?

 
 
 

last

Post by Chris F.A. Johnso » Sun, 13 Apr 2003 00:28:26



> Hi!

> Can the administrator change the last command (/usr/bin/last) settings
> so that the user can see his last logins/logouts he has done in a
> month instead of in a day?

    The last command shows all logins contained in the wtmp file
    (which may be in /var/log, or /var/adm, or ...).

    Older wtmp files are usually rotated. You can tell least to read
    them with the -f option:

last -f /var/log/wtmp.0 $USER

    Or:

for f in /var/log/wtmp.*
do
  last -f $f $USER
done

    How far back you can go will depend on how the log rotation is set
    up, and how many files are kept.

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

1. last character of the last line is a newline?

While helping to make sure the last character of the last line is a
newline, Laura Fairhead, a few years back, suggested the following. I
think it also check if the file is empty:

{cat filename.txt
   if [ "$( tail -c 1 filename.txt |tr -c '\12' x )" = "x" ]
   then echo
   fi

when I try it i get:

%:~/Desktop m1$ {cat filename.txt
-bash: {cat: command not found
%:~/Desktop m1$   if [ "$( tail -c 1 filename.txt |tr -c '\12' x )" = "x" ]
 >   then echo
 >   fi

%:~/Desktop m1$ }
-bash: syntax error near unexpected token `}'
%:~/Desktop m1$

I would like to make a simple function out of it. Where did I go wrong?

2. comments after #!/bin/sh ?

3. One last line - one last time

4. HP LaserJet IID an Solaris 2.5.1

5. get last char of last positional parameter

6. ncpmount fails

7. Removing last character from last line in a file

8. Local Bus support?

9. select field n to last? select last field?

10. How do I get last to report last login time.

11. convert first last to F.I. last

12. last.c sources to linux version of last available?

13. How to extract the last part of the path (was: Using 'cut' to extract the *last* field of a string