Anda di halaman 1dari 6

1.

Find Status of last run command in shell


For ksh bash $?
2.

$# -> 2

no of Argument

$* -> foo bar

array of argument

$0 -> myapp

application name

$1 -> foo

first argument

$2 -> bar

3. How many user we have


awk -F":" '{print $1,$4}' /etc/passwd

WHO command

NAME
who - show who is logged on

SYNOPSIS
who [OPTION]... [ FILE | ARG1 ARG2 ]

DESCRIPTION
Print information about users who are currently logged in.

-a, --all
same as -b -d --login -p -r -t -T -u

-b, --boot
time of last system boot

-d, --dead
print dead processes

-H, --heading
print line of column headings

--ips print ips instead of hostnames. with --lookup, canonicalizes based on stored IP, if available,
rather than stored hostname

-l, --login
print system login processes

--lookup
attempt to canonicalize hostnames via DNS

-m

only hostname and user associated with stdin

-p, --process
print active processes spawned by init

-q, --count
all login names and number of users logged on
-r, --runlevel
print current runlevel

-s, --short

print only name, line, and time (default)

-t, --time
print last system clock change

-T, -w, --mesg


add user's message status as +, - or ?

-u, --users
list users logged in

To Get Uid (User id) of current user


Id
Eg:oracle@ubuntu:/etc$ id
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

To find a user's UID or GID in Unix, use the id command. To find a specific user's UID, at
the Unix prompt, enter:
id -u username
oracle@ubuntu:/etc$ id -u oracle
1001
Replace username with the appropriate user's username. To find a user's GID, at the Unix
prompt, enter:
id -g username
eg:oracle@ubuntu:/etc$ id -g `whoami`
1001

If you wish to find out all the groups a user belongs to, instead enter:
id -G username
eg:oracle@ubuntu:/etc$ id -G `whoami`
1001 1002
If you wish to see the UID and all groups associated with a user, enter id without any
options, as follows:
id username

Finger
-s Finger displays the user's login name, real name, terminal name and write status
(as a ``*''
after the terminal name if write permission is denied), idle time, login time, office
location
and office phone number.

Login time is displayed as month, day, hours and minutes, unless more than six
months ago, in
which case the year is displayed rather than the hours and minutes.

Unknown devices as well as nonexistent idle and login times are displayed as single
asterisks.

-l Produces a multi-line format displaying all of the information described for the -s
option as
well as the user's home directory, home phone number, login shell, mail status, and
the contents
of the files .plan.project.pgpkey.forward

Phone numbers specified as eleven digits are printed as ``+N-NNN-NNN-NNNN''.


Numbers specified
as ten or seven digits are printed as the appropriate subset of that string. Numbers
specified

as five digits are printed as ``xN-NNNN''. Numbers specified as four digits are
printed as
``xNNNN''.

If write permission is denied to the device, the phrase ``(messages off)'' is


appended to the
line containing the device name. One entry per user is displayed with the -l option;
if a user
is logged on multiple times, terminal information is repeated once per login.

Mail status is shown as ``No Mail.'' if there is no mail at all, ``Mail last read DDD
MMM ##
HH:MM YYYY (TZ)'' if the person has looked at their mailbox since new mail arriving,
or ``New
mail received ...'', `` Unread since ...'' if they have new mail.
root@ubuntu:/home/tomhawk12/Scripts# finger -s
Login

Name

Tty

oracle

pts/0

oracle

pts/3

Idle Login Time

Office

Office Phone

Nov 26 04:29 (192.168.32.1)


11 Nov 26 06:00 (192.168.32.1)

tomhawk12 KUMAR

tty7

3:12 Nov 26 04:58 (:0)

tomhawk12 KUMAR

pts/1

1:31 Nov 26 05:54 (:0.0)

tomhawk12 KUMAR

pts/2

1:28 Nov 26 05:54 (:0.0)

root@ubuntu:/home/tomhawk12/Scripts# finger -l
Login: oracle
Directory: /home/oracle

Name:
Shell: /bin/bash

On since Mon Nov 26 04:29 (PST) on pts/0 from 192.168.32.1


On since Mon Nov 26 06:00 (PST) on pts/3 from 192.168.32.1
11 minutes 19 seconds idle
No mail.
No Plan.

Login: tomhawk12
Directory: /home/tomhawk12

Name: KUMAR
Shell: /bin/bash

On since Mon Nov 26 04:58 (PST) on tty7 from :0


3 hours 12 minutes idle
On since Mon Nov 26 05:54 (PST) on pts/1 from :0.0

1 hour 31 minutes idle


On since Mon Nov 26 05:54 (PST) on pts/2 from :0.0
1 hour 28 minutes idle
No mail.
No Plan.

Anda mungkin juga menyukai