Linux Sysadmin Test Prep

Processes

Processes

ps

Try These:

  • ps
  • ps -f
  • ps -F
  • ps -u <username>
  • ps -g <groupname>
  • ps <PID>
  • ps -C <CMD>
  • ps -ef | head -3
  • ps aux | head -3
  • ps aux --sort=-pcpu | head -3
  • ps aux --sort=-pmem | head -3
  • ps -o pid,uname,comm,pcpu,pmem -C <CMD>
  • ps -eo pid,ppid,ni,pri,cmd,%cpu,%mem --sort=-%cpu | head -3
  • ps -eH
  • ps -u --forest
  • pstree (technically a different command)

pgrep

  • pgrep -lu <username> <CMD>
  • pgrep -lg <username> <CMD>

kill

    1. sleep 100 &
    2. pgrep sleep
    3. kill -v <sleep's PID>
    1. sleep 100 &
    2. pkill -v pkill sleep

-kill -L (List signal names)

SignalSignal #Meaning
TERM15Stonger than INT
KILL9Is unblockable
INT2Same as <Ctl-C> keyboard shortcut. Can be caught and ignored.
QUIT3Like TERM with default coredump.

nice/renice

CommandPRINICMD
nice -1 vim dog181vim dog
nice -5 vim dog145vim dog
nice -10 vim dog910vim dog
nice -19 vim dog019vim dog

renice -13 -p 3564 (by PID)

renice 14 -u ubuntu,daniel -g custom (all in two users and 1 group)


top

Top bar field meanings

Top Line Meaning (5 fields)

12345
Uptime# of users logged inone minutefive minutes15 minutes

Second Line is obvious to look at...

Third line is CPU time spent on: (7 fields)

1234567
“user space”Kernel "system""nice" processes"idle""waiting" for I/O"hardware interrupts""software interrupts"

Fourth and fifth lines are obvious.

White Bar Meaning (12 fields)

123456789101112
Process IDUsernamePriorityNice ValueVirtual Memory UsedResident Memory UsedShared Memory UsedStatusCPU UsedMemory UsedCPU Time UsedCommand

Status Initial Meaning

Status InitialMeaning
DUninterruptible sleep
RRunning
SSleeping
TTraced (stopped)
ZZombie

Interactive commands

KeySort by:
qquit
PList by %CPU
MList by %MEM
NList by PID
TList by TIME+
uFilter for a users process
cToggle COMMAND display
1Display individual CPU statistics
IOnly active tasks
nNumber of lines
rRenice a process
kKill a process (enter sigterm)
ADisplay four areas in the process list
aMove from area to area
WSave settings as default
dSet refresh rate
SpaceForce refresh

fg

  1. top
  2. <Ctrl. Z> (suspend)
  3. fg (bring jobs to forground)

Edit this page on GitHub