LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 10-26-2011, 01:08 PM   #1
ramanababu
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
How to get access holders user names in a linux


I would like to know the user names, who has access to a box in linux and i would like to know it using shell script

Thanks in advance
 
Old 10-26-2011, 01:26 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,121

Rep: Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819
Easy enough:
Code:
awk 'BEGIN { FS=":" } { if ($3 > 999) print $1 }' /etc/passwd
Save that as say, user_names then
Code:
chmod 755 user_names
and run it.

Hope this helps some.
 
Old 10-26-2011, 01:35 PM   #3
ramanababu
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks a lot for your response,
In my query 'box' means a server where all my JVM's will run, when ever i am going to stop my JVM i want to send a mail to all the users who have aces to that particular server, so that they will know that server is going to stop and they will pause their work for some time

Will this code gives me the user names who has acces to that particular box/server?


Quote:
Originally Posted by tronayne View Post
Easy enough:
Code:
awk 'BEGIN { FS=":" } { if ($3 > 999) print $1 }' /etc/passwd
Save that as say, user_names then
Code:
chmod 755 user_names
and run it.

Hope this helps some.
 
Old 10-26-2011, 04:35 PM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,121

Rep: Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819
Quote:
Will this code gives me the user names who has acces to that particular box/server?
Probably not (you might have mentioned what you meant by "box").

The ball is back in your court -- how would you know a user is connected to a JVM? Do users log in with a user id and password? Is there some sort of utility that will tell you that a user is connected (similar to the Linux/Unix who utility)?
 
Old 10-27-2011, 02:16 AM   #5
ramanababu
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
No need of user to be connect to the server in this point, Actually Admin team will give stop,start (some sort of develeopment activities)access to particular members they will stop the server when they want to push some code changes into the JVM, so they give stopServer command and JVM name, so if anybody working on that particular server their work abnormally terminats because of server was stopped by some user, so to avoid this before stopping the server i will send a mail to the team of members who have acces rights to that server, so they will stop their work until further intimation, this will happen again once we give startServer command by passing JVM name

This is what my requirement, please do need full....

Quote:
Originally Posted by tronayne View Post
Probably not (you might have mentioned what you meant by "box").

The ball is back in your court -- how would you know a user is connected to a JVM? Do users log in with a user id and password? Is there some sort of utility that will tell you that a user is connected (similar to the Linux/Unix who utility)?
 
Old 10-27-2011, 08:18 AM   #6
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,121

Rep: Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819
Well, I can't help you with JVMs, don't know diddly-squat about 'em, but I can suggest that the folks that are doing shutdown be required to send a message (by whatever means works best in your organization) notifying users that machine X is going down in 10 minutes and now would be a real good time for you to save what you're working on and go do something else for a while. It's not a technological problem, more of a management one, eh?

Best I can come up with, sorry.
 
Old 10-27-2011, 10:23 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,469
Blog Entries: 4

Rep: Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525
Hi,

Look at 'shutdown';
Quote:
excerpt from 'man shutdown';

/sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]

DESCRIPTION
shutdown brings the system down in a secure way. All logged-in users are notified that the sys-
tem is going down, and login(1) is blocked. It is possible to shut the system down immediately
or after a specified delay. All processes are first notified that the system is going down by
the signal SIGTERM. This gives programs like vi(1) the time to save the file being edited, mail
and news processing programs a chance to exit cleanly, etc. shutdown does its job by signalling
the init process, asking it to change the runlevel. Runlevel 0 is used to halt the system, run-
level 6 is used to reboot the system, and runlevel 1 is used to put to system into a state where
administrative tasks can be performed; this is the default if neither the -h or -r flag is given
to shutdown. To see which actions are taken on halt or reboot see the appropriate entries for
these runlevels in the file /etc/inittab.

OPTIONS
-a Use /etc/shutdown.allow.

-t sec Tell init(8) to wait sec seconds between sending processes the warning and the kill sig-
nal, before changing to another runlevel.

-k Don't really shutdown; only send the warning messages to everybody.

-r Reboot after shutdown.

-h Halt or poweroff after shutdown.

-H Halt action is to halt or drop into boot monitor on systems that support it.

-P Halt action is to turn off the power.

-n [DEPRECATED] Don't call init(8) to do the shutdown but do it ourself. The use of this
option is discouraged, and its results are not always what you'd expect.

-f Skip fsck on reboot.

-F Force fsck on reboot.

-c Cancel an already running shutdown. With this option it is of course not possible to give
the time argument, but you can enter a explanatory message on the command line that will
be sent to all users.

time When to shutdown.
warning-message
Message to send to all users.

The time argument can have different formats. First, it can be an absolute time in the format
hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits).
Second, it can be in the format +m, in which m is the number of minutes to wait. The word now is
an alias for +0.

If shutdown is called with a delay, it creates the advisory file /etc/nologin which causes pro-
grams such as login(1) to not allow new user logins. Shutdown removes this file if it is stopped
before it can signal init (i.e. it is cancelled or something goes wrong). It also removes it
before calling init to change the runlevel.
'shutdown' with proper configuration, timing & warning message should be enough. You could use the '-k' option to issue a dummy shutdown message that system will be going down in ## minutes. Then issue the 'shutdown by admin at the end of that time.
HTH!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Yahoo Holders Re-Elect Board; Yang Gets 85% of Votes LXer Syndicated Linux News 0 08-02-2008 02:10 AM
SUSE linux 9.1: only root user can resolv domain names superfly Linux - Networking 2 07-14-2004 09:21 AM
External IDE drive holders that use 1394 or USB snerfu Linux - Hardware 1 10-16-2003 11:24 AM


All times are GMT -5. The time now is 05:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration