Table of Contents

Controlling Processes

Viewing and debugging processes

               # Shows system calls made by running 'hostname'
               $ strace hostname


               # Shows what files are opened when running 'who'
               $ strace -e open who


               # Attach to an already running process; useful for watching
               # daemons in action:               
               $ ps aux | grep ssh
               root      1243  0.0  0.1   5488   968 ?        Ss   Mar12   0:00 /usr/sbin/sshd
               ...
               # Attach strace to the running /usr/sbin/sshd process by its PID (1243),
               # and watch the output as someone logs in via ssh:
               $ strace -p 1243
               # Shows all open files owned by jchung
               # (generally should run lsof as root)
               $ lsof | grep jchung | less

Lab Activity

Strace

On your Linux virtual machines, what do you see when you

 $ ping <your Linux system hostname>   # example: $ ping richardson

?

Run strace on your Linux virtual machines to investigate how ping goes about finding an IP address associated with your system hostname to send ping packets to.

Force ping to send just one ping packet, and force strace to send its output to a file called strace.out, so that you can look at strace output offline.