Professional Documents
Culture Documents
Today’s Agenda
$ who
root tty01 Jul 25 08:00
user1 tty02 Jul 25 10:37
user2 tty03 Jul 25 11:02
user35 tty05 Jul 25 09:21
zahid ttys7 Jun 25 18:49
$
who options
Options Description
-H Display headings above each column
-u List only users who are currently logged in
-i Users idle time
-q All login names and total no of users logged on
-w, -T message status + is for y and – is for n
#who –uH
NAME LINE TIME IDLE PID COMMENT
root console Dec 13 08:00 . 10340
user1 tty02 Dec 13 10:37 . 11929 Tech-89.2
user2 tty03 Dec 13 11:02 0:04 4761 Sales-23.4
user35 tty05 Dec 13 09:21 1:07 10426
zahid ttys7 Dec 11 18:49 old 10770
Topic Heading Class Meeting # Slide : 4
Linux Based Networks Zahid Shafique, Instructor
Field Description
Field Description
NAME Lists the user's login name.
LINE Lists the line or terminal being used.
TIME Lists the time the user logged in.
IDLE Lists the hours and minutes since the last activity
on that line. A period is displayed if activity
occurred within the last minute of system time. If
more than 24 hours has elapsed since the line was
used, the word old is displayed.
COMMENTS Lists the contents of the comment field if
comments have been included in /etc/inittab or if
there are network connections.
#w
ps commands Headings
The ps listing displays four default headings as indicators of the
information in the fields below each heading: PID, TTY, TIME, and
COMMAND.
Headings in the Output of ps
Field Explanation
PID The process identification number
TTY The terminal on which the process originated
TIME The cumulative execution time for the process, in minutes
and seconds
COMMAND The name of the command being executed
Process Status
• The process status can be shown under the STAT
column issued by ps or top.
Code Description
R Runable
D In disk (or
(or short-term)
short-term) wait
wait
I, S Sleeping (>20 sec, < 20 sec)
T Stopped
Z Zombie
Zombie
> Process has higher than normal priority
N Process has lower than normal priority
< Process is exceeding soft limit on memory use
X Process is being traced or debugged
L Some pages are locked in core
W Process is swapped out
+ Process is in the foreground of its control terminal
Topic Heading Class Meeting # Slide : 12
Linux Based Networks Zahid Shafique, Instructor
Flag Description
a Shows processes of other users also.
f Shows processes and sub processes.
h Specifies no header.
l Indicates the long format.
r Specifies running processes only.
txx Processes associated with tty terminal.
u Indicates the user format; gives username and start
time.
x Shows processes without controlling terminal.
$ ps -uax
$ps -u
$ ps -t ``1 2''
PID TTY TIME COMMAND
32 tty01 0:05 bash
36 tty02 0:09 bash
235 tty02 0:16 vi calendar
The kill command sends signals to the program to demand that a process
be terminated or killed. To use kill, use either of the following forms:
kill PID(s)
kill -signal PID(s)
killall
Examples:
0 0 * * 1 (cd /home/dccyril/project; make)
make the project only on Mondays mid-night.
20 1 * * * find /tmp –atime +3 –exec rm –f {}';'
remove all tmp files that have not been accessed in 72 hrs at 1:20am
everyday.
22 23 * * 1-4,7 /staff/dccyril/bin/acct-script
runs the acct-script at 11:55pm on Mon, Tue, Wed, Thu and Sun.
Scheduled Processes - at
• at: schedule the process.
– allows user to execute commands at a specified time.
at timeformat command
– Eg. at 6pm nightlyprocess
at 1am tomorrow command1
at 4pm +3 days command2
at 10am Jul 31 command3
at now next fri command4
at 14:45 Sep 14 00 command5
– Use atq command to list all the pending jobs
– Use atrm command to remove the jobs.
– The permission for using at is determined by the files
/etc/at.allow and /etc/at.deny.
• In Linux, you can add a set of commands after
issuing the at command.
Topic Heading Class Meeting # Slide : 23
Linux Based Networks Zahid Shafique, Instructor
Exercise:
Homework
• Homework this week:
• Next week: