Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-27-2003, 11:15 AM   #1
LQ Newbie
Registered: May 2003
Posts: 28

Rep: Reputation: 15


Ive recently come across the 'top' command. I have a shell account with a company and on that machine when i load top it shows only the processes which are running under my uid. But on my own rh9 box, nomatter which user loads top, they see ALL processes. How would i go about limiting top to show only the uid who ran the programs processes?

Old 07-27-2003, 11:28 AM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
try running "man top" and see if any of the options is of any use for you
Old 07-27-2003, 11:32 AM   #3
Registered: Jul 2003
Location: Europe
Posts: 198

Rep: Reputation: 30
Use the command " man top " you will be presented with the on line documentation and setup process!
Old 07-27-2003, 11:47 AM   #4
LQ Newbie
Registered: May 2003
Posts: 28

Original Poster
Rep: Reputation: 15
Id already read the man, and put:


in the /etc/toprc file, but this doesnt seem to have any effect

Old 07-27-2003, 01:05 PM   #5
Registered: Jul 2003
Location: Europe
Posts: 198

Rep: Reputation: 30
Ok Simon, the " top " command to show user processes only is " top -U username " I suggest using a script in the /etc/profile.d/ directory to apply this setting when a user issues the command. I'm cooking the dinner now, but I'll write a script later and we can see if it works.
Old 07-27-2003, 01:16 PM   #6
LQ Newbie
Registered: May 2003
Posts: 28

Original Poster
Rep: Reputation: 15
oh, ok, thanks, i did see the -U command, but i assumed 'secure' mode would mean users would be restricted in what they could see. thanks
Old 10-29-2003, 09:33 AM   #7
LQ Newbie
Registered: May 2003
Posts: 28

Original Poster
Rep: Reputation: 15
I actually forgot about this, but i would still like this feature.

Ive re-read the "man top" and there is no mention of a -U option to show a specific users processes.

Typing top on my system shows ALL system user processes, however, typing it on a different shell i have access to shows:

31454 simonbel 5 0 924 924 748 R 1.9 0.1 0:00 top
1232 simonbel 1 0 608 608 500 S 0.7 0.1 0:37 muh
1714 simonbel 1 0 32704 31M 1580 S 0.3 6.2 90:18 eggdrop
31450 simonbel 0 0 1752 1720 1552 S 0.3 0.3 0:00 sshd
1178 simonbel 0 0 0 0 0 Z 0.0 0.0 0:00 sh <defunct>
31451 simonbel 0 0 1244 1244 1012 S 0.0 0.2 0:00 bash

and no other system processes. man top on this system also does not show a -U option.

Old 10-31-2003, 05:08 AM   #8
Registered: Jul 2003
Location: Europe
Posts: 198

Rep: Reputation: 30
here is the section from the gnu top program man page that refers to the -U -u switch, READ the man page properly!
You will be prompted for a UID or username. Only processes
belonging to the selected user will be displayed. This
option matches on the real, effective, saved, and filesys_
tem UID.
Old 10-31-2003, 08:13 AM   #9
LQ Newbie
Registered: May 2003
Posts: 28

Original Poster
Rep: Reputation: 15
hm. This is the output of "man top" on my system. I dont see any -U options:

TOP(1) Linux Userās Manual TOP(1)

top - display top CPU processes

top [-] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]

top provides an ongoing look at processor activity in real time. It
displays a listing of the most CPU-intensive tasks on the system, and
can provide an interactive interface for manipulating processes. It
can sort the tasks by CPU usage, memory usage and runtime. can be bet-
ter configured than the standard top from the procps suite. Most fea-
tures can either be selected by an interactive command or by specifying
the feature in the personal or system-wide configuration file. See
below for more information.

d Specifies the delay between screen updates. You can change this
with the s interactive command.

p Monitor only processes with given process id. This flag can be
given up to twenty times. This option is neither available inter-
actively nor can it be put into the configuration file.

q This causes top to refresh without any delay. If the caller has
superuser privileges, top runs with the highest possible priority.

S Specifies cumulative mode, where each process is listed with the
CPU time that it as well as its dead children has spent. This is
like the -S flag to ps(1). See the discussion below of the S
interactive command.

s Tells top to run in secure mode. This disables the potentially
dangerous of the interactive commands (see below). A secure top
is a nifty thing to leave running on a spare terminal.

i Start top ignoring any idle or zombie processes. See the interac-
tive command i below.

C display total CPU states instead of individual CPUs. This option
only affects SMP systems.

c display command line instead of the command name only. The default
behavior has been changed as this seems to be more useful.

H Show all threads.

n Number of iterations. Update the display this number of times and
then exit.

b Batch mode. Useful for sending output from top to other programs
or to a file. In this mode, top will not accept command line
input. It runs until it produces the number of iterations
requested with the n option or until killed. Output is plain text
suitable for display on a dumb terminal.

top displays a variety of information about the processor state. The
display is updated every 5 seconds by default, but you can change that
with the d command-line option or the s interactive command.

This line displays the time the system has been up, and the three
load averages for the system. The load averages are the average
number of process ready to run during the last 1, 5 and 15 min-
utes. This line is just like the output of uptime(1). The uptime
display may be toggled by the interactive l command.

The total number of processes running at the time of the last
update. This is also broken down into the number of tasks which
are running, sleeping, stopped, or undead. The processes and
states display may be toggled by the t interactive command.

CPU states
Shows the percentage of CPU time in user mode, system mode, niced
tasks, iowait and idle. (Niced tasks are only those whose nice
value is positive.) Time spent in niced tasks will also be
counted in system and user time, so the total will be more than
100%. The processes and states display may be toggled by the t
interactive command.

Mem Statistics on memory usage, including total available memory, free
memory, used memory, shared memory, and memory used for buffers.
The display of memory information may be toggled by the m interac-
tive command.

Swap Statistics on swap space, including total swap space, available
swap space, and used swap space. This and Mem are just like the
output of free(1).

PID The process ID of each task.

PPID The parent process ID each task.

UID The user ID of the taskās owner.

USER The user name of the taskās owner.

PRI The priority of the task.

NI The nice value of the task. Negative nice values are higher pri-

SIZE The size of the taskās code plus data plus stack space, in kilo-
bytes, is shown here.

The code size of the task. This gives strange values for kernel
processes and is broken for ELF processes.

Data + Stack size. This is broken for ELF processes.

TRS Text resident size.

SWAP Size of the swapped out part of the task.

D Size of pages marked dirty.

LC Last used processor. (That this changes from time to time is not
a bug; Linux intentionally uses weak affinity. Also notice that
the very act of running top may break weak affinity and cause more
processes to change current CPU more often because of the extra
demand for CPU time.)

RSS The total amount of physical memory used by the task, in kilo-
bytes, is shown here. For ELF processes used library pages are
counted here, for a.out processes not.

The amount of shared memory used by the task is shown in this col-

STAT The state of the task is shown here. The state is either S for
sleeping, D for uninterruptible sleep, R for running, Z for zom-
bies, or T for stopped or traced. These states are modified by
trailing < for a process with negative nice value, N for a process
with positive nice value, W for a swapped out process (this does
not work correctly for kernel processes).

depending on the availability of either /boot/psdatabase or the
kernel link map /boot/ this shows the address or the
name of the kernel function the task currently is sleeping in.

TIME Total CPU time the task has used since it started. If cumulative
mode is on, this also includes the CPU time used by the processās
children which have died. You can set cumulative mode with the S
command line option or toggle it with the interactive command S.
The header line will then be changed to CTIME.

%CPU The taskās share of the CPU time since the last screen update,
expressed as a percentage of total CPU time per processor.

%MEM The taskās share of the physical memory.

The taskās command name, which will be truncated if it is too long
to be displayed on one line. Tasks in memory will have a full
command line, but swapped-out tasks will only have the name of the
program in parentheses (for example, "(getty)").

A , WP
these fields from the kmem top are not supported.

Several single-key commands are recognized while top is running. Some
are disabled if the s option has been given on the command line.

Immediately updates the display.

^L Erases and redraws the screen.

h or ?
Displays a help screen giving a brief summary of commands, and the
status of secure and cumulative modes.

k Kill a process. You will be prompted for the PID of the task, and
the signal to send to it. For a normal kill, send signal 15. For
a sure, but rather abrupt, kill, send signal 9. The default sig-
nal, as with kill(1), is 15, SIGTERM. This command is not avail-
able in secure mode.

i Ignore idle and zombie processes. This is a toggle switch.

I Toggle between Solaris (CPU percentage divided by total number of
CPUs) and Irix (CPU percentage calculated solely by amount of
time) views. This is a toggle switch that affects only SMP sys-

n or #
Change the number of processes to show. You will be prompted to
enter the number. This overrides automatic determination of the
number of processes to show, which is based on window size mea-
surement. If 0 is specified, then top will show as many processes
as will fit on the screen; this is the default.

q Quit.

r Re-nice a process. You will be prompted for the PID of the task,
and the value to nice it to. Entering a positve value will cause
a process to be niced to negative values, and lose priority. If
root is running top, a negative value can be entered, causing a
process to get a higher than normal priority. The default renice
value is 10. This command is not available in secure mode.

S This toggles cumulative mode, the equivalent of ps -S, i.e., that
CPU times will include a processās defunct children. For some
programs, such as compilers, which work by forking into many sepa-
rate tasks, normal mode will make them appear less demanding than
they actually are. For others, however, such as shells and init,
this behavior is correct. In any case, try cumulative mode for an
alternative view of CPU use.

s Change the delay between updates. You will be prompted to enter
the delay time, in seconds, between updates. Fractional values
are recognized down to microseconds. Entering 0 causes continuous
updates. The default value is 5 seconds. Note that low values
cause nearly unreadably fast displays, and greatly raise the load.
This command is not available in secure mode.

f or F
Add fields to display or remove fields from the display. See below
for more information.

o or O
Change order of displayed fields. See below for more information.

l toggle display of load average and uptime information.

m toggle display of memory information.

t toggle display of processes and CPU states information.

c toggle display of command name or full command line.

N sort tasks by pid (numerically).

A sort tasks by age (newest first).

P sort tasks by CPU usage (default).

M sort tasks by resident memory usage.

T sort tasks by time / cumulative time.

W Write current setup to ~/.toprc. This



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
help with top amitbhawnani Linux - Newbie 3 03-27-2005 03:19 AM
Programs don't like "staying on top" or "always on top" -- any help? SBing Linux - Software 8 07-05-2004 05:41 AM
Top ? bohh Linux - Software 1 09-11-2003 09:57 PM
like-top eltongeoff Linux - Newbie 5 09-01-2003 06:38 PM
Always on top linuxBill Programming 0 08-27-2003 09:02 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:15 PM.

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