Number of times a user is "connected"?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Number of times a user is "connected"?
# 1  
Old 11-20-2010
Number of times a user is "connected"?

hi i wish make a shell to look for the number of times a user is connected then makes a "whatch dog" by crontab to handle this
i could do it through ps-fedal| grep user_name | wc-l ... etc.

but others suggested me another algorithm Smilie
and thought to use w, or finger, or who
but it have a problem
if I try (as root) open a command interpreter and use
su username
none of the above commands recognize me as the new user where I am, It still recognize as root Smilie

how could I fix this? or which other command allows me to see what actions or process a user doing on the machine? Smilie.

by the way im from colombia and im an Unix's (CentOS 5) novice user Smilie
thank you very much for your comprention and attention
# 2  
Old 11-21-2010
Are you worried that other users are doing bad things on your computer? Trying to monitor interactively (what you are asking) means you have to sit 24 hours a day and look at other processes.

This will give you what you just asked for, if I understood:
Code:
who | awk 'arr[$1]++;  END{for(i in arr){print i, arr[i] }}'

I don't think that is what you want to do. There are other solutions. What kinds of processes are you worried about? By that I mean are they internet connections, telnet connections, ssh connections, ftp connections....?

As a very general apporach I would learn about and install snort, and learn how to set up accounts for other users so they are restricted - like a restricted shell, or a chroot jail.
You have a lot of reading.....

Snort :: Home Page

Restricted shells
Restricted Shells

chroot jail for sftp and ftp howto:
https://help.ubuntu.com/community/BasicChroot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Issue with rsync: failed to set times on "/tmp/.": Not owner (1)

Hi, Here is my source host and folder details. $ hostname source-host $ id uid=600000208(src-user) gid=64688(src-user) groups=64688(src-user) $ ls -ltrd /web/Trn_File/data/ drwxrwxrwx 3 src-user src-user 4096 Feb 7 15:27 /web/Trn_File/data/ $ ls -ltrd /web/Trn_File/data/* drwxrwxrwx 8... (1 Reply)
Discussion started by: mohtashims
1 Replies

3. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

4. Shell Programming and Scripting

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line... (4 Replies)
Discussion started by: sudeep.id
4 Replies

5. Solaris

How to execute a ".profile" depending on the server from where the user is connected.

Hello, I have two Solaris servers on a cluster. I have created the same user "X"on the two nodes (same UID and same GID). The file ".profile" of this user "X" is located in a filesystem that is seen by the two nodes. Each server should have a ".profile" of this user different of the other... (6 Replies)
Discussion started by: adilyos
6 Replies

6. UNIX for Dummies Questions & Answers

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line to... (1 Reply)
Discussion started by: sudeep.id
1 Replies

7. Solaris

FC card showing "Not connected"

Hi there, I have a Sun StorageTek 2501 plugged into a V440 (Solaris 10) via fiber and a crossover cable. This array worked fine for the past year, until I tried to install a second fiber card last night. Both cards came up OK in the OS, but I was no longer able to see my array. I decided to... (1 Reply)
Discussion started by: paidbythehour
1 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. UNIX for Dummies Questions & Answers

return code capturing for all commands connected by "|" ...

Hi, While I am using "|" to join multiple commands, I am not getting the return code when there is error in one of the commnads. Eg: b=`find /path/a*.out | xargs basename` if ; then echo "Error" fi if there is error while finding the file or getting the basename, the $? is... (6 Replies)
Discussion started by: new_learner
6 Replies

10. Shell Programming and Scripting

communicating wth another user aside from "wall" and "write"

Hi, Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I... (6 Replies)
Discussion started by: Deanne
6 Replies
Login or Register to Ask a Question