Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Online coding site: Ancient Brain

coders   JavaScript worlds


CA170      CA668      CA686

Online AI coding exercises

Project ideas


Pipes and redirection

Very powerful features.

Filename completion

Start typing filename, hit special key to complete it.


ps                      See what processes are running
kill (process id)       Terminate some of your processes
kill -KILL (pid)        Definite kill
kill -1                 Kill all my processes

PPID              parent process of this process
xkill &                 Kill the next thing I click on      

nice			Run something at low priority deliberately
time			Time a run of some program    

Display of processes

ps in DCU

  1. Normal login in DCU labs:
    • You each have your own CPU and memory, sharing a central filesystem.
    • "ps" will show that the only processes running on the machine are yours and the Operating System's.

    • ps -Tf
      -T        associated with this terminal
      -f        full details

    • ps -u $USER -f
      -u $USER  associated with this user

    • ps -u $USER -o user,pid,ppid,comm,args
      -o  Show these fields

  2. If doing ssh to student.computing.dcu.ie:
    • Possibly shared CPU with other users.
    • student.computing.dcu.ie is a Linux cluster, so some users have their own CPU, others are on shared CPUs, by chance.

    • To see other people's processes:
      ps -Af
      -A  all processes

Exercise with ps

To be done in Linux in lab:
  1. Launch firefox from desktop.
  2. In command-line, type ps
  3. Is firefox in list of processes? If not, why not?
  4. How do you make a list of processes that includes firefox?

  5. Launch firefox from command-line.
  6. Use ps to find the path of the firefox program.
  7. Observe that it is in a directory that is not in the PATH!
  8. Explain how it ran, given that it is apparently not in the PATH.
  9. Clue: See the "which" command.


Usage seems to vary on different variants of UNIX and Linux. You may get something like:

Ctrl-S                  Pause
Ctrl-C                  Interrupt
Ctrl-D                  Kill, Logout

Ctrl-Z                  EOF
q		exit man, more

Command-line Philosophy

A computer for programmers.

GUI Philosophy

A computer for non-programmers.
(Or for a thing you want to do now for which a command-based approach is not appropriate.)

Note that user interface people say these dialogs are often ignored.
From Donald Norman, The Psychology of Everyday Things, 1988, Ch.5:

Human - Delete all my most important files.
System - Are you sure?
Human - Yes Yes.
System - Are you really sure?
Human - Yes Yes.
System - All your most important files deleted.
Human - Oh damnit.

Compare with UNIX:

Human - Delete all my most important files.
System - (Silence.)
Human - Oh damnit.

Command-line on Mac / Windows

From xkcd.

ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.

Wikipedia: Sometimes I link to Wikipedia. I have written something In defence of Wikipedia. It is often a useful starting point but you cannot trust it. Linking to it is like linking to a Google search. A starting point, not a destination. I automatically highlight in red all links to Wikipedia and Google search and other possibly-unreliable user-generated content.