Users logged into the system


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Users logged into the system
# 1  
Old 06-29-2015
Users logged into the system

So I'm trying to write a single line command
Quote:
using pipe and several commands you have used so far that will list only the names of the users who have logged in to the system in the current month, sort the output, and remove any duplicate name entries
So I have to use last first in this command and I've figured out the format my professor wants it in, something like this
Code:
last | cut -d' ' -f1,15 | sort > check | uniq -c

.... and I never can get it right, when I just last command I get something like
Code:
mls25292 pts/1        75.140.205.119   Tue May 26 08:41 - 08:51  (00:10)
User8 pts/1        75.140.205.119   Tue May 26 08:38 - 08:41  (00:02)
User6 pts/0        98.174.221.132   Tue May 26 07:39 - 09:47  (02:08)
User4   pts/0        68.107.156.29    Mon May 25 09:26 - 09:29  (00:03)
User4   pts/0        68.107.156.29    Sun May 24 09:10 - 09:35  (00:25)
User4  pts/0        172.28.2.144     Sat May 23 13:17 - 13:37  (00:20)
reboot   system boot  2.6.32-131.12.1. Sat May 23 13:10 - 23:20 (36+10:09)
User4  pts/2        68.107.156.29    Tue May 12 08:18 - 08:21  (00:02)
User7 pts/3        68.229.96.26     Mon May 11 11:27 - 11:31  (00:03)
User7 pts/2        68.229.96.26     Mon May 11 10:20 - 13:08  (02:48)
User4  pts/5        68.107.156.29    Mon May 11 08:32 - 09:45  (01:13)
User3  pts/4        68.229.96.26     Mon May 11 08:29 - 12:13  (03:44)
User3  pts/3        68.229.96.26     Mon May 11 07:57 - 10:18  (02:20)
User3  pts/2        68.229.96.26     Mon May 11 07:29 - 09:45  (02:15)
User3   pts/3        70.160.86.189    Sun May 10 21:04 - 21:38  (00:34)
User3    pts/2        70.161.152.96    Sun May 10 16:33 - 06:33  (13:59)
User3  pts/4        68.229.96.26     Sun May 10 09:48 - 09:59  (00:10)
User3    pts/3        70.161.152.96    Sun May 10 09:41 - 16:33  (06:51)
User3   pts/2        70.161.152.96    Sun May 10 08:39 - 09:54  (01:14)
User2 pts/2        68.229.96.26     Sat May  9 07:48 - 07:54  (00:06)
User2 pts/5        68.229.96.26     Sat May  9 06:29 - 09:32  (03:02)
User2 pts/4        68.229.96.26     Sat May  9 06:19 - 08:22  (02:02)
User2 pts/3        68.229.96.26     Sat May  9 05:02 - 08:12  (03:10)
User2 pts/2        68.229.96.26     Sat May  9 04:25 - 06:56  (02:30)
User2 pts/2        68.229.96.26     Fri May  8 17:48 - 21:00  (03:12)
User2 pts/3        68.229.96.26     Fri May  8 12:09 - 14:43  (02:33)
User2 pts/2        68.229.96.26     Fri May  8 10:56 - 14:02  (03:06)
User2 pts/2        68.229.96.26     Thu May  7 22:01 - 00:43  (02:42)
User1 pts/2        68.229.96.26     Thu May  7 19:51 - 21:17  (01:26)
User1 pts/2        68.229.96.26     Thu May  7 16:41 - 18:15  (01:33)
User1 pts/4        68.229.96.26     Thu May  7 14:57 - 17:22  (02:24)
User1 pts/3        68.229.96.26     Thu May  7 14:16 - 16:52  (02:35)
User1 pts/2        68.229.96.26     Thu May  7 13:38 - 16:07  (02:28)
User1 pts/2        68.229.96.26     Thu May  7 12:10 - 13:05  (00:54)
User1  pts/2        172.26.33.192    Thu May  7 07:41 - 07:57  (00:16)

So when I used my command
Code:
last | cut -d' ' -f1,15 | sort > check | uniq -c

I get results like this
Code:
User1 Jun
User1 Jun
User1 Tue
wtmp
User2
User2
User2
User2
User2
User2
User2 Sun
User2 Sun
User2 Sun
User3
User3
User3

This one question is destroying me please give me insight if you can,

Last edited by rbatte1; 06-29-2015 at 07:32 AM.. Reason: Removed FONT formatting and added more appropriate CODE tags for clarity
# 2  
Old 06-29-2015
Hi DoubleAlpha,

There is a dedicated sub-board for these types of questions along with a template questionnaire to fill in (See the rules in the sticky thread):

https://www.unix.com/homework-and-coursework-questions/
# 3  
Old 06-29-2015
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Users not logged in for last 90 days

Hi, How to find the users who did not login into a UNIX box (thru ssh/ftp or any other way) for last 90 days? I think of using "finger" or "last" command to findout each user's last login and then find number of days between today and that day. Is there any other better way or anyone prepared... (1 Reply)
Discussion started by: reddyr
1 Replies

2. Red Hat

Current logged in users

I have 2 systems. (1) RHEL5 and (2) winXP pro from xpPRO putty i ssh into rhel5 : user root from xpPRO i ftp into rhel5 : user abc123 when i run #uptime it only shows 1 user when i do #ps -u abc123 : it shows vsftpd deamon PID is there a command that can be used to show all currently... (4 Replies)
Discussion started by: dplinux
4 Replies

3. Shell Programming and Scripting

Bash Help: users who are not logged into the system to display

A Newbie here, I am working on a script and am having problems with the else part of the script. I can't get the users who are not logged into the system to display on the screen with their username and the text "The user is not logged in". I am sure it is something simple and stupid, but I... (5 Replies)
Discussion started by: rchirico
5 Replies

4. UNIX for Dummies Questions & Answers

How many users are logged in?

How do I find this out? I have a feeling its a simple command such as who, but I just don't know what it is. I've had a search on here but either I can't put it into the right search criteria or there isn't a topic on it. Thanks. EDIT: Delete this thread, as I posted it I noticed the... (0 Replies)
Discussion started by: chris_rabz
0 Replies

5. Programming

Get the list of logged in users

How can I get the list of logged in users in the system programmatically? I can get the list with 'who' or 'users' commands but I need to get the list programmatically... May someone help, please? Thanks in advance. (2 Replies)
Discussion started by: xyzt
2 Replies

6. Shell Programming and Scripting

Users Not Logged in

I have searched the forums but have not mangaed to quite find what im looking for. I have used to /etc/passwd command to present me a list of all users the who command to present all users currently logged on, but what i want to know is what command can i use to display users that are registered... (12 Replies)
Discussion started by: warlock129
12 Replies

7. Post Here to Contact Site Administrators and Moderators

logged out users

how to find out users who logged out within 5 minutes (1 Reply)
Discussion started by: roshni
1 Replies

8. UNIX for Advanced & Expert Users

HP-UX users get logged off while idle.

Im "supporting" at least 2500 HP-UX workstations with CAD-related software with the B.11.11 build. I cant say anymore than that because of my companys sligtly paranoid security policy . The last few days a new problem has arised from nowhere. The problem is that users gets logged off when the... (5 Replies)
Discussion started by: Laoinjo
5 Replies

9. Shell Programming and Scripting

how many users logged

in unix what is the syntax to find out how many users are currently logged in (4 Replies)
Discussion started by: trichyselva
4 Replies
Login or Register to Ask a Question